I Have 2 tables first client_group with data like below second table client in Controller I have code like below: $client = DB::table(‘client_group’) ->where(‘client_group.user_id’…
Tag: laravel
How to use REPLACE with WhereRaw eloquent laravel?
I have a column in my database that saved with double quotation (“) now I want to replace it by space.I’m using REPLACE and whereRaw.but It dosent work. this is my code: actually using / for scaping (“).Any Idea? Answer I believe you found the answer in the comments another thing what I suggest is don’t append the value directly
How to get sum of weight as total_weight from one table and store it in another table
I had two similar fields namely total_weight that is in my phyto table and weight that is in my phyto_species table shown below CreatePhytosTable CreatePhytoSpeciesTable I have been trying to sum weight using array_sum() as total weight and then assign it to ‘total_weight’ => $totalweight] shown below however when I save the error says Undefined variable: totalweight. I would like
IlluminateDatabaseQueryException: SQLSTATE[42000]: Syntax error or access violation: 1064
i m trying to add this query into my code in laravel. it runs smoothly in phpmyadmin or with mysql command line but enable to get anything but this syntax error. my query : SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for
exists query does not return relevant result
I have a Laravel application with this Eloquent query: $products = Product::where(‘name’, ‘LIKE’, “%{$value}%”) ->whereHas(‘categories’, function($q) { $q->where( ‘slug’, ‘…
1064 You have an error in your SQL syntax; check the manual … for the right syntax to use near ‘WHERE reviews.yes_no = yes
I want to optimise the queries on my project and after many tentatives of using eager loading with datatables i just give up because there was no query reducing at all. Anyway now Im trying to achieve that using join, but the problem is that using WHERE clause in DB::RAW it gives me the following error: “Exception Message:nnSQLSTATE[42000]: Syntax error
Eloquent hasMany doesn’t load collection
I’m relatively new to eloquent, and have problems loading data from a hasMany relation in an app that uses eloquent as the database layer. My (simplified) code is as follows: The SQL Schema is like below I then do the following query: This results in a json like the following Raw SQL query shows me that I do have data
All the migrations are working inappropriately
This is the error I get after trying to open the form. Below are the codes. It takes me all day so please kindly help me out. SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘id’ in ‘field list’ (SQL: select max(id) as aggregate from admissions where admissions.deleted_at is null) Here is the migration Answer This represents that your primary key
Laravel query not using where clause for date
I have made a laravel query which gets all the data but does not use the where clause for $startdate. Without the start date working it just gets all the data which is not really the idea. Any idea how to fix? Answer Try this:
MySql Group By Count item count Distinct
I have a table looks like Here user id 1 exist in level 1 and level 2 Now when we count group by level then in counting we want ignore user_id 1 from level 1 cause it exist another group. we want to consider only one group existing and higher group. I have done only group count but cant understand