I store my array in config/product.php
return [
[
'id' => 1,
'title' => 'test1',
'name' => 'name1'
],
[
'id' => 2,
'title' => 'test2',
'name' => 'name2'
],
[
'id' => 3,
'title' => "test3",
'name' => 'name3'
]
];
In My controller I use pluck to show my title
$product = collect(config('products'))->pluck('title','id');
$data['product'] = $product;
$data['store'] = $this->store;
return view($this->route.'.create',$data);
in my view
{!!
Form::select('product',$product, null, [
'placeholder' => 'Select Product',
'class' => [
'form-control',
$errors->has('product') ? 'is-invalid' : '',
],
]);
!!}
But in this way It'll display only title How can I display Name and title some thing like this
Form::select('product',$product->title.$product, null, [
'placeholder' => 'Select Product',
'class' => [
'form-control',
$errors->has('product') ? 'is-invalid' : '',
],
]);