Saturday, May 12, 2018

remove local scope for another query eloquent - development

remove local scope for another query eloquent

I Have Two Model

User and Task which have many-to-many relationship.

In UserController:

public function show(User $user)
{
    return view('users.show', compact('user'));
}

in users/show.blade.php :

Posts: @include('users.show.tasks',['tasks'=>$user->tasks()]);

in users/show/tasks.blade.php :

Active Tasks Count :

Query:

select count(*) as aggregate from `tasks` inner join `user_task` on `tasks`.`id` = `user_task`.`task_id` where `user_task`.`user_id` = '1' and `status` = '4';

Pending Posts Count:

Query:

select count(*) as aggregate from `tasks` inner join `user_task` on `tasks`.`id` = `user_task`.`task_id` where `user_task`.`user_id` = '1' and `status` = '4' and `status` = '3';

When I Check The Query By laravel-debugbar , For the second count , I See I Have two status code in query



from Laravel Questions and Answers https://laravelquestions.com/php/remove-local-scope-for-another-query-eloquent/
via Lzo Media

No comments:

Post a Comment