Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Mohammed's avatar

Need Help with spatie / laravel-model-status

Hello There, First thanks for your help ;)

So my problem is I have a project model and it has multiple statuses using laravel-model-status package.

Like Pending, Approved etc ...

So I want to query projects based on their last status, I tried this query and it gave me not only approved Projects and projects with another statuses.

 $projects = Project::with(['user', 'offers', 'statuses:name'])
            ->whereRelation('statuses', 'name',  'approved')
		->paginate(15)

Also tried something like


$projects = Project::with(['user', 'offers', 'statuses:name' => function ($query) {
            $query->where('name', '!=', 'pending');
        }])->paginate(15);

No luck.

Thank you.

0 likes
2 replies

Please or to participate in this conversation.