excuse me want to ask. I’m sorry in advance if my language is not neat I have a category table with colom -id (pk) -name -and others and i have a post table with colom -id (pk) -category_id(fk) and others I want to count the number of posts from each category along with the category name in laravel 8. this
Tag: laravel-8
How to group PHP arrays by key before sorting by another key?
I have an array that contains the key counted and placement which I am trying to group by before I sort. The array should be first sorted by counted and then, for each duplicate counted, should then sort by placement. My expected output here would be: I have tried to usort to achieve this: But this gives me an unexpected
Laravel: getting blade components syntax error, unexpected ‘endif’ (T_ENDIF), expecting end of file
I am learning laravel on Laracast however I am having some issues I have this code on file components/layout.blade.php And this on main.blade.php which is the page the view redirects to For some reason Laravel is returning this error: Answer I found what was causing the problem, I had a space between content and =”Hello There” by removing it and
Laravel 8.x – How to use updateOrCreate with a where clause?
I am trying to use Laravel updateOrCreate to update a record if its within this month and last month based on if an ID exists. If the ID exists, and the result is in this current month or last, a new record is created instead of updated. Expected input: 1 (which exists from last month) Expected output: Record is updated
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:
Authenticate users from more than two tables in laravel 8 api
As I know Auth::attempt is used to authenticate users from users table, but i want to authenticate another users from students table and teachers from teachers table. How to create multiple authentication for different users? I’m new in laravel api’s Answer I think there’s much stuff on the net, but may this could be useful for you: I’ve written medium
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
How to keep session after storing data in Laravel 8?
I’m new to Laravel. I have created custom Change Password in Laravel 8 using Livewire. But, after succeeded in updating the user password, my session is expired and redirected to login page. So, the question is how to keep the session alive and redirect to the current page? Here’s my code: ChangeUserPassword.php change-user-password.blade.php Any suggestion would really help. Thanks. Answer
Job processing number in terminal – queue in laravel
What is the number next to time in the terminal if it is for processing amount how can I rest it to start from 0 every time running the command php artisan queue:work it starts to continue from last number stop on it, also it possible to change it to string? I try to this command to clear caches php
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