Skip to content
Advertisement

Tag: eloquent

laravel write multiple where clause to filter files

I don’t know how to filter this in my laravel 9 app using eloquent. I am having a files table and file_metadata (pivot) – where files has multiple metas: ex: file_metadata for 3 files: So files 5 ,6 ,7 have 2 metas (3 active, 6 signed). File 7 is active but not signed. How to write the where clause to

Eloquent relationship where not in sub-query

I have got a relationship where I select all row’s based on the category, however I need to exclude some of these if they are within a sub query. So above is my code, nearly works as I want it, however it seems that the $q variable doesn’t have the table name within the query, below is the query outputted:

Laravel, search exact same substring in eloquent query

I have a table like this Teacher Table What I am trying to do is to get the row which contains the subjects 1(or any other number like 7,8 etc.) This is what I have tried in my controller. The problem here is that, I am getting all the rows which contains subjects as ‘1’,e.g. if it is ‘3,11,22’ or

Laravel 8 – Listen to eloquent events made during a specific request

Currently, I’m trying to wire a telemetry library (OpenTelemetry php lib) to the Laravel event model. The idea is to forward traces to a third party service. A single trace consistents of a request and all database calls that have been made during the request. I’ve created three middleware components: BeforeRequest: starts a trace OnRequest: call event listener which listened

Laravel 8 eloquent query delete

How to delete the aircon in database when there is no any data. Order and Aircon are many to many relationship. Answer try whereDoesntHave Edit: You can also add new column aircons_count will old number of aircons for every order which will be faster than the above query and run the query like the following: Note: make sure to add

Advertisement