samedi 1 décembre 2018

Backpack for Laravel with Relationship giving an errort

I have a table of countries and a table of continents. The countries has a field "continent_id". The Country model has a method:

public function getContinent()
      {
        return $this->belongsTo('App\Models\Continent','continent_id','id');
      }

and if I test this with tinker I get the right response:

$co = App\Models\Country::with('getContinent)->first()

enter image description here

In my setup on CountryCrudController I want to add a field that shows the continent - and I will also want to add a selection of the 7 continents to the countries edit, so in the list part I defined:

  $this->crud->addColumn([
      'name' => "continent",
      'label' => "continent", // Table column heading
      'type' => "select",
      'entity' => 'getContinent ', // the method in your Model
      'attribute' => 'continent',
    ]);

but when I try to run it I get:

enter image description here

What I am doing wrong please?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire