Skip to content
Advertisement

Tag: eloquent

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

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

Advertisement