jeudi 20 octobre 2016

show to pass predefined data from model to view in laravel

i have some predefined data in the form of array. which i wants access into my views. im using following approach for this purpose. i define a function in model, which return array.

//function in my model calss of cars.

public function colors(){
  return ['white', 'blue','gray'];
}

when i access this function like that

$cars->colors();

it shows me following error Relationship method must return an object of type

so please guide me that whats the proper way to handle such type of situation of i wants to array or any data from my model object or alternate way.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire