I wish to store classes in my Laravel model.
For example, say I have a model called M
with an attribute b
, which takes a class called Foo
.
I wish to be able to to do something like this.
$foo = new Foo();
// ...
$m = new M();
$m->b = $bar;
$m->save();
However this gives me a Object of class Bar could not be converted to string
error.
Furthermore I should be able to do the opposite.
e.g.
M::first(5)->b; // Returns the associated `Bar` object who has id 5.
How do I do this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire