Skip to content
Advertisement

Tag: eloquent

I am fetching data of user where role equals to teacher , status is active and other orWhere. This collection gives me super admin user also but why?

I am working on search. I am facing issue with the query. when ever i search super. It gives me super admin user also but i am using ->whereRelation(‘role’,’name’, ‘teacher’) Answer that because if any orWhere come with true, the record will be fetched, you should group your orWhere in one statment:

Select DISTINCT returns duplicates data Laravel 8

I’m trying to get groups that belong to a supervisor to be displayed for him. And I’m using join to get each gpid information base on supervisor_id, query its okay but returns duplicate data of the last row. I can’t figure out why it is duplicating the last record. Any help would be much appreciated. Result Answer You can try

Laravel Eloquent the same queries

I’ve faced this question on the interview recently. How many objects will be created? How many db queries will be executed? I’ll be thankful so much for any detailed explanation Answer In Either one of the code above, the query will just be 1 $a = Flight::find(1); is same as Since $a & $b are 2 different variables, though they

laravel id value changed after adding a nested loop

I used the following code to display the role of the user however, when I want to edit or delete it leads me to the deleted ids number 2/3 it return the same thing even when I change the for else with foreach Attempt to read property “id” on null (View: C:laravelgautoresourcesviewsdashboarduseredit.blade.php)! when I delete the nested foreach loop everything

laravel – unable to get data outside foreach

dump($data) outside the foreach loop gives me only 1 data where as dump($data) inside the foreach shows all arrays of rows of data . How can i get all rows of data outside the foreach too? EDIT: Error: Call to a member function paginate() on array Answer In Controller add new function for it After that crate that function for

Advertisement