Its common to give user an option to filter the data which they wanted when the data amount is huge and normally you may provide different conditions to filter the data. In this article, I will show you how to build a condition based query in Laravel. Its pretty easy to be done by the query builder.
for example: you may give user two options to filter the data. one is the status of your order and other is the general search for the different fields.
for the status option ,we can provide a dropdown list and the general search we can provide a input field to the user.
If you use a livewire upload file filed in a modal dialoge, after you close the modal or upload the file you may see the upload filed is still the old one unless you choose an other file or refresh the page. I try to set the file upload variable to null to solve, but it is still the same. Livewire may not recognize the file upload filed is changed, so we can reset it by add a different id to it.
in the view file, add a iteration to reset the file upload filed.
Sometimes after login, you will still get a 419 page expired error. This is because the server can not match the token send from the client. To avoid this error, you can use the following method:
We have two model class, one is User the other one is Division, user belongs to one division and division has many users. Users table only has one column named division_id, the other division information like “division name” we can get from Divisions table.
useIlluminate\Contracts\Auth\MustVerifyEmail; useIlluminate\Database\Eloquent\Factories\HasFactory; useIlluminate\Foundation\Auth\UserasAuthenticatable; useIlluminate\Notifications\Notifiable; useLaravel\Sanctum\HasApiTokens; useIlluminate\Database\Eloquent\Model; //by default this line is not here, you need to add it manually
Instead you should use user->division->name to get the name of the division, but if you directly use the property name name it will throw an other error, beacuse the default Laravel user model do not import Eloquent Model.
1
Attempt to read property "name" on null
To solve this problem we need to add a this line to your User model file.