Reputation: 9442
I haven't found how I can force a model to re-query it`s children.
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Model1 extends Model
{
public function seasons() {
return $this->hasMany('App\Models\Seasons', 'series_id', 'id');
}
}
When I call $instanceModel1->seasons();
throughout my application logic I want an element removed along the way.
Is there a way when calling $instanceModel1->seasons();
a second time to force the Eloquent to do a query rather than returning the models already loaded?
Upvotes: 2
Views: 2843
Reputation: 1074
Simply reloading the relation works for me.
$instanceModel1->load('seasons');
Upvotes: 4