I’m trying to create a simple filter system with a search box, service, category and a way to sort the items in my laravel controller. However, I am getting an error links() when I try to filter anything even though I think I have paginated correctly. Here’s my function: Can anyone give me some advice on this problem? Thanks! Edit:
Tag: eloquent
How to active and inactive boolean in Laravel
I want to know how to make a Boolean data true or false in database whenever my button is clicked. I already can perform a true when button is clicked, I want to know how to make it false. I hope I can get a answer thank you! BTW, this is my first time to post a question here and
Eloquent Sort By depend on the field
I have a query like this: I want to sort the result but i have problem. if the result of withMin if null i want to sort it by another field (lets say ‘product.sale_price’). Or how can i make a new field, lets say ‘final_price’, if promotion_price is null use sale_price. What i already tried: add this after get() the
Compare two columns from two related tables using scopes in Laravel 9
I’m trying to create a scope that will compare two columns on two related tables. Based on these tables I would like to be able to get all instances of the ServiceCall model where the next_service_date is within the next 15 days, where the Customer model either has a null value for the last_contact_date or where it’s before the ServiceCall’s
Laravel relationship where clause is returning records outside relationship
I have a problem where i try to get all users from Site which is defined relationship in Site model and on where clause it returns users that belong to other Site Lets say that my $site_id = 2 and my $searchParam = ‘Tom’. It returns Tom that belongs to Site with site_id=1 but it also returns other Tom that
update one row of table in the future (Laravel)
the update method in Laravel (version 8) edit fields at the execution time, but I want to update fields at a specefic date for exemple : I have company table with pack field : when the customer pay another pack, the pack field would be edited after the end of the current pack. there is a solution for this ?
Eloquent – Update eloquent relations with foreach loop
I have a controller function to send multiple devices for repair (essentially an update request against multiple existing devices_repairs records). When I try to retrieve the devices from the devices table alongside the repair details (Devices table, devices_repairs table), the records are retrieved but when I try to update the values the update request doesn’t save the new data. This
Query More than one relationship from a model with() in Laravel
I need help to query a model base on its relationship: I have a model called StoreStock, this model is related to a Product model, which has two model relationships, MasterList and Price. I want to get all storeStock with two Product relationships. I know i can do something like With this, i can only pick either price or masterlist
Laravel eloquent update, 500 Internal Server Error
I want to update my database with Laravel eloquent update, but response is always 500 This is my model This is the function This is the route Exception: Thanks before, for helping.. Answer Loking at the exception: Seems like you don’t have updated_at column in your database table. There are two solutions for this: I: Create/update your migration to include
How to calculate date time different in Laravel Eloquent based on dynamic column minutes
I’m trying to query based on two databases and columns. response_time contains an integer of minutes, ie: 15 If the anotherTable.created_at – response_time (ie, sub 15 mins) is less than the current time, return the row. I’ve tried the above but I’m having no luck and no idea how to debug my query. Any help appreciated. Example query that should