share with us your code to understand what you want to do and provid an alternative
How to remove item from relationship collection
L5.2
I have a model with a hasMany relationship like this
public function lines()
{
return $this->hasMany('TransactionLine', 'transactionid', 'id');
}
I have loaded the relationship and want to remove an item from the collection, I can do that with something like
$this->lines = $this->lines->filter ( ... );
That works OK, however if I save the model after doing that
$this->save()
it tries to include -lines- in the database query and I get a SQL error -
QueryException in Connection.php line 713:PDOException in Connection.php line 462: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'lines' in 'field list'
I guess it's seeing -lines- as a property now rather than a method/relationship so tries to include it in the DB query?
I need to know how to remove an item from the collection returned by the relationship, in such a way that I can still save the model.
Any help is much appreciated. Thanks :)
Please or to participate in this conversation.