samedi 21 juillet 2018

Trying to get property 'names' of non-object (Laravel)

How to get values from array using foreach. Here is my controller:

$names = array(
            'type' => ['PSO','NPSO']
        );
        return view('dashboard.page.schedule.create', compact('names'));

And Here is my view:

@include('dashboard.component.form.select', [
                    'name'=> 'scheduletype',
                    'placeholder' => 'Schedule Type',
                    'label'=> 'Schedule Type',
                    'datas'=> $names,
                    'datavalue'=> 'type',
                    'dataname'=> 'type',
                    'attrib' => 'required'
                ])

Usually I have used this code for get values from table and it works ! But I don't know how to solve this problem. The example that I used and working:

controller:

$sppbes = Sppbe::all();
return view('dashboard.page.schedule.create', compact('sppbes'));

view

@include('dashboard.component.form.select', [
                    'name'=> 'type',
                    'placeholder' => 'Type',
                    'label'=> '',
                    'datas'=> $sppbes,
                    'datavalue'=> 'id',
                    'dataname'=> 'name',
                    'attrib' => 'required'
                ])



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire