I’ve got a query that I’m running in my project on a model called Domain, it returns all domains where the status column of a domain matches complete and a date column is before or equal to a specific set of days. I’ve recently refactored the model columns and have included a new column called domain_alert_period which is an integer
Tag: laravel-query-builder
How to do this join query in Laravel way?
Answer
How do I select a value from different tables in Query Builder Laravel
So i’m trying to get “promo_type” value from mysql table to excel. However i need to use another table in order to get the value of this “promo_type”. So this is the main table booking, which contains the value of the promo code. Like shown below a user has a promo code of “1000”. Booking Table Now in this other
How to check if related table doesn’t have record
matches table has releationship with scores table. I need to get all matches without record in scores table. tryied smth, but didint worked: Answer If you use relationship, you can use doesntHave() , but if you use query builder as you write in your question, you may use these codes, I saw that your where condition need some adjustment to
Eloquent Laravel multiple like where and where clause
I have the below Mysql query that works. mysql: select * from operatories op left join locations al on op.location = al.location where op.opname like ‘%NP%’ or op.opname like ‘%OPEN%’ and al….
Convert string to date datatype in SQL Server in PHP Laravel
I’m trying to get a product by id between a specific date range but the problem I’m facing is: date is in string format for some weird reason dates are stored in the database with an incomplete …
Laravel joining tables in a database query
I have this code: $classic_games_money = DB::table(‘bets’) ->where(‘user_id’, $this->user->id) ->sum(‘price’); It displays the amount of income, but i need to display this …
Laravel add calculate the sum where the value is in another table
Basically i have two tables. answers and choices . In my choices table, I got a column choices.value which is has values 0-4. My current query like this $answers = DB::table(‘answers’) …
How to pass array as SELECT params for Laravel Query Builder
If I have an AJAX call that returns an array called $selectArray, which is [foo,bar,foobar], how do utilize it in a Laravel Query Builder so that it’s sanitized? Currently, I have It seems awfully unintuitive. Either there are better ways sanitizing the input or passing Array as SELECT without having multiple addSelect() methods, but I can’t find any. Answer You
Laravel equivalent of ->fetch?
I am working on a website that uses PHP and SQL to connect to the database, I’m trying to replace all the SQL with Laravel Query Builder commands. I am running into a problem with the following code:…