Query-builder Questions
Ad
Laravel subquery to another database table
I need to subquery where data doesn't exist in another db table. i tried with db::connection('dbconfigname') first db
Laravel Query Builder Foreach Loop how do I reference a field that exists in both join tables
The id field in the foreach loop exists in both of the tables that i am joining, i need to reference it to one table only (ie. program_types.id)
Rewriting SQL query in Laravel but getting error BadMethodCallException: Call to undefined method
I'm trying to do this query in laravel. select distinct curriculum.course_code, transcript.course_grade, transcript.course_comp,
How to do self join in query builder no eloquent
Having hard time to do self join with query builder but getting unexpected results or query while using tosql() or
Convert Query Builder to Eloquent Builder
I can not extract the result in groupby, the query builder below works very well but i want it to eloquent. i want to display only the folders
Laravel Many-to-Many (on the same users table/Model): Query scopes to include related for the specified user
Users can block each other. one user can block many (other) users, and one user can be blocked by many (other)
condition orWhere using laravel 6 not work
I have two tables, salaries and pointages, and a belongsto/hasmany relationship between them.
How to custom OrderBy in Laravel
I wanted to do a custom ordering for marketing_status_id in this: $prospect =
Laravel order by price with condition special price
I have table with next columns (price, special_price, is_special). +-------+------+-----------------+--------------+---------+ |
Laravel: insert array object in single SQL column
I have a single column in db named session and i want to insert all below data in single column in a form of array. data available
Ad
Invalid interger value (Unable to store value into database)
I would like to ask.i am having trouble where i could not get the id instead i am getting the whole row.
How to filt data by time using Laravel?
I have this query, i would like to obtain only the data created on the current month public function index(request $request) {
How to filter a record depending of the user connected using Laravel?
I have the next table..
How to find duplicate values in database with Laravel
How can i find duplicate values in database with laravel. i want the results like this: name_data - amount
How can I show and pagination two queries in the laravel blade?
I want to show $personnals and $users in a table in the blade. i know, i have to use @foreach.
how to run mysql query in Laravel
I want to transform my mysql query into a query in laravel but i really don't know how to do this. i don't know how to rename in from like in
How to send a query in a variable using laravel?
I have this function to register my users protected function validator(array $data) { return validator::make($data, [
Laravel Chunking Results utility
According to laravel documentation if you need to work with thousands of database records, consider
Is it possible to translate this "join" and "as" query to Laravel PDO functions?
I am struggling to make this sql query to a laravel pdo query. does anyone know how i can do this? (especially the 'as' statements
Use query Function inside blade without controller
How can i use query function inside blade without using controller something like this::-
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');
Ad
How to filter one-to-many relations with query builder
I have @entity('procedures') export class procedureentity { @primarygeneratedcolumn() id: number; @onetomany(type
Laravel Query Builder Subtract COUNT by Subquery in query grouped by ID
I got stuck in this problem i encountered in laravel query. firstly i have this query that i use in order to get transactions
Laravel - How to Sum relative table with limit result?
I have these 2 models. i want to get sum of 12 columns comment_count in youtube_video_insights table.
Translate a MySql query in a Laravel query builder
Select apartment_id, count(created_at) as n_view, date_format(created_at, '%y-%m-%d') as day_view from views where apartment_id=36 group
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
SQL Select data from two tables, one row -> multiple rows
I have the following two tables: customers: | phones: -------------------------------------- id | id name |
Laravel having column name in where clause static method
Recently i just realized that laravel generates a static method with column name when joined in a where clause using camel case example
Search in table using one or more of 3 parameters laravel
I have search page and there is 3 select lists as input. when user select one or more option and click search button, page will show result that
How to make a distinct in only one table of a join using Laravel Query Builder?
I have this query... and i would like to make a distinct only in (tbl_holdings) this is my query $holdings =
select a row for each column`s value
I have got a condition and i want to use mysql temporary tables. i have tasks table and jobs table.
Laravel eloquent Too few arguments to function 1 passed & 2 expected in my query
Here my code : $sum = $pipes->sum(function ($pipe) use ($filter) {
Ad
How to get all the user data from another table and include them on user list in laravel?
I am using 2 tables upon displaying my users in my users>index.blade these 2 user table
LARAVEL 5.8 - Multiple conditions for WHERE LIKE clause using array in foreach not giving complete results
I have a column in my db table which has multiple comma separated values and i have a comma separated array below:
Laravel - How to get rows of permissions from another table set in roles table
I am very new to laravel and trying to get the all permission rows from the permissions table that set into the roles -
How to get following users posts in Laravel 5.8
I have two models in my laravel 5.8 project, relationships is shown below in both model classes. how can i get every single post
How to implement a combined cross and inner joins in Laravel?
I have defined 3 tables in laravel as follow: schema::create('locales', function (blueprint
How count by the first letters in Laravel Query Builder?
I want to make a count by the first letters... i have this column
Laravel query LeftJoin show all categories even in right table have not that category
I have two table following: tb_category id |name | ---------------- 1 |category a| 2 |category b| 3 |category c| 4
How to exclude numbers from a count using Laravel Query Builder?
I can't exclude the number one and two from my count... i used wherenotin but didn't work, why? $data =
Laravel: Convert QueryBuilder to Eloquent:ORM
How to return, with eloquent, all files where column deleted_at is null. i can access the value of deleted_at like this
Unable to Sort data in dual foreach loop in Laravel
I am fetching data of user with the subject model and review model. there is a rating column in the
How to count two related dates in Laravel using Query Builder?
I have this list of dates
Ad
How to make tree joins at the same time with Laravel Query Builder?
I tried to make tree joins with this code, but didn't work... $av = db::table('rifcliente_filtro')
How to count two related tables using Laravel Query Builder?
I have two tables in my database my first table
How to delete all the data from a table after 5 seconds using Laravel Query Builder?
I have this query $data = db::table('incidencias') ->select(db::raw("str_to_date(fecha_notif, '%d/%m/%y %h:%i:%s') as
How count the hours between two diferent formats using Laravel Query Builder?
I would like to count how many hours are between this two formats using laravel query builder.. how could i do that? i would like to know if it
How to get an element in each row from a complete array in Laravel?
I'm inserting a group of elements in database, i'm trying to get one element for each row but i'm obtaining all elements in one row and every row
How to retrieve records from database table in Laravel and prevent those which are expired
So i have a table in mysql which looks like this
Laravel query builder: is this command excused from SQL injections?
Some time ago i've read here on stackoverflow an accepted answer which was claiming that select("sql query") is excused from sql
How to get the sum of columns from a group of records in a join?
I have a request that returns documents to me. i would like to join the sums of goods of each document and summarize them. it looks like
Laravel query builder. Column if not null = 1 else = 0 in select method
I using laravel and its \illuminate\database\eloquent\builder. i would like to select all columns from "table_1" a have custom column
Laravel Eloquent, get all datas in ids array with whereIn?
Here my code : $search = request()->get('search'); $conciergerieselect = request()->get('conciergerie'); $services
Laravel Eloquent, sort whereHas / width datas
Here my code : list($orderby, $orderdirection) = explode('.', request()->get('sort_by')); $prestations =
Ad
how to use increment function in laravel
I am using db to store values in database. i have "course fees" column i what to "increment" the "course_fees"
unexpected result in a query in laravel
I’m a beginner in laravel but have a problem at first. i wrote this query and i’m waiting for sonya bins as result
Laravel Eloquent, apply select on my queries in whereHas
Here my code : $prestations = prestation::with('service','facility','conciergeries.network') ->wherehas('service',
Laravel Eloquent Pagination, how to count before pagination with filters?
Here my code : $prestations = prestation::with('service','facility','conciergeries.network') ->wherehas('service',
Laravel Eloquent How to apply condition on "with" datas on the output?
Here my code : $prestations = prestation::with( [ 'service' => function($service) use($searchservice)
How to query my model in Laravel with relationships using query builder
I have three models: user image post and their relationship is: user hasmany
Laravel Eloquent use the orWhere query in my search system request
I tried to code a request with search system. here the code: $search =
How to count revisited customer ( more than 1 time) in laravel using query builder?
I need to count revisited customer in one month. it means need to count customer_id has more than one entry in table within a month. my
Efficient way to query database with multiple conditions in laravel
Is it possible to make this a single query? $yl_min = db::connection($this->db2)->table('historical')
Laravel Nova - Scope Relationship Fields
Is there a way of adding a scope to the belongstomany fields, such that when you attach related models you can only do so from restricted
How to merge two table data in laravel?
I need all users data in one blade, i have table1 and table2. table1
Ad
Using AES_DECRYPT in SELECT Query Builder - Laravel
I'm trying to decrypt the data from mysql database provided by our partner. they encrypted it using this in mysql aes_encrypt(fld_code,
Why do I get undefined offset when not listing all the rows in foreach?
I have a problem when trying to import some excel data into the database with query builder, i got undefined offset: 4 even though the column of
Laravel DB run two queries at once (SELECT/UPDATE)
I have one table which stores some records as json. i'm trying to increment the numeric value of a key from json column. below is the query i'm
Querying 65k+ records with whereIn
I have an export functionality and i want to query and export using given ids. i found a solution of querying using skip() and
Laravel Query Builder to Eloquent Builder
How can i convert following laravel db query builder to eloquent? is it possible to do laravel eloquent? $reports =
Laravel 5.7 | Passing data / variables used in a first function to build the view to a second function to generate a dompdf file
Important : i didn't get my data from a model, but from a query builder query. the following first function build a view
Laravel boolean returns "1"/"0" instead of true/false in query
I have a query that returns a boolean field (by the way, i'm on an sql server) on my rest api developed with laravel and a few days ago it was
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.
Laravel query format - Join To the Latest row
I have two tables for example users and orders. i have to join users with orders on users.id = orders.user_id - which is
Passing conditional param to Eager Loading in larave ends with error
My code is as followed: return user::wherehas('roles', function ($role, $query) {
How to select sub-query with left join inside using eloquent?
I'm very new to laravel, how can i make this query in laravel using eloquent model: select (
Ad
How to convert an SQL sub query in Laravel Query Builder?
The following is my sql query. i'm googling to convert laravel query builder but can't find a good solution. please help me.
converting query in Query Builder
How can i convert this query in query builder. public function ajaxsearch(string $value = null) //for search, from sidebar {
Laravel Eager Load Constraint issue
Edit: for clarity, this is laravel 5.8. this is for a hr app i'm working on. they requested a report to show people who have
Laravel Query Builder returns no results while generated SQL works perfect
I am actively working on a laravel project and have ran into some issues with the query builder. i am trying to avoid using db::raw but it is
Query that brings the most occurrences of a certain field in Laravel
I have the following query : $top_cont = db::table('quests') ->wherebetween('created_at',
How to make a union query using Laravel Eloquent and Laravel Query Builder?
I am using laravel eloquent to crud data. my problem is, i don't know how to make union queries using laravel eloquent orm. can you help me to
Get category and Sub_subcategories list using query builder
How to get a list of category and subcategories like this: 1 mobile apple samsung
How to write a query conditionally in laravel?
I am new to the laravel, i am joining three tables based on conditions every thing is working fine but i need to write conditionally if the $field
Query Builder filter for multi level deep relationship in Laravel
I have a selection of plots which each belong to a development by a hasmanythrough relationship through housetypes. i want to filter these by
Get database search results between two date time period
In my database, there is a table called vehicle_schedule, and all the vehicle schedules are stored there. in that table, there is two columns name
How to batch delete with query builder
I have array of id's i want to delete all of them with one query without foreach and eloquent, is there any way of it?
Ad
Laravel Query Builder does not run query correctly even thought it binds correctly
I have a problem with the laravel query builder. when i try to bind a variable, which would include some sort of sql code, into my binding
How can I perform where queries correctly in laravel eloquent query builder
Take a look at the following query: $testquery = customer::where('company_id', auth()->user()->company_id);
Query in laravel returns empty response
I am tying to retrieve data from my data base using leftjoin in laravel. i have two table name users and
How to use IN opearator in Laravel WHERE clause?
I am building an advanced table filter using laravel. the client sends an array of filters to the server to apply on a model and send back the
Laravel Query builder - select top 1 row from another table
I have this sql query for mysql which works fine. but i need to rewrite it using query builder and need to avoid db::raw() completely
How can I connect to the database with pypika?
Reading the documentation it's pretty much clear how to build queries, but i couldn't find any tutorial how to connect to the database - i.e.
Laravel | Override default DB::connection only once inside scope
I have multiple mysql connections to different databases in my laravel application. i understand that i cannot override the default connection
how to get latest records basis on timestamp but not duplicate from a table in laravel?
I have a table quotations id lead_id subject created_at 1 2 quotation 1
How to use pagination on DB::select(query) - Laravel
I have some query and i just know how to query on mysql (phpmyadmin) i got information if using db::select we cannot to use
laravel database query with multiple relationships
I would like to load posts from users of a certain age from the database. the user can save the minimum(users->profile->min_age) and maximum
row count from second table with more than one table join
I have three table: table1: jobposts (id,user_id,qualification_id) table2: appliedjobs (id,jobposts_id,message) table3:
Ad
I want to save data in DB using fill but I get an error
I want to read and overwrite existing data projectcontroller.php public function update(request
store result of raw DB in a variable in laravel
I want to run this custom query in laravel app and save the result in a variable select min(t1.id + 1) as nextid rom
Ad
Blog Categories
Ad