Skip to content
Advertisement

Tag: laravel

Laravel using where clause on a withCount method

I am trying to do a where clause on withCount method of laravel’s eloquent query builder using this piece of code. and this code is giving me this error. SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘upvotes_count’ in ‘where clause’ (SQL: select , (select count() from upvotes where upvotes.upvoteable_id = posts.id and upvotes.upvoteable_type = AppPost) as upvotes_count from posts where

How to convert Laravel migrations to raw SQL scripts?

Developers of my team are really used to the power of Laravel migrations, they are working great on local machines and our dev servers. But customer’s database admin will not accept Laravel migrations. He asks for raw SQL scripts for each new version of our application. Is there any tool or programming technique to capture the output from Laravel migrations

Laravel: getting a single value from a MySQL query

I’m trying get a single value from MySQL database using laravel but the problem I’m getting an array . this is my query result in MySQL command line: my laravel function: expected $data value is a string with value= Admin but what i get is : [{“groupName”:”Admin”}] Answer Edit: Sorry i forgot about pluck() as many have commented : Easiest

Laravel – seeding large SQL file

A memory exhaustion happens when I run my DB seed script in production. Below is my seed script. So what I did was add a no-limit on my seed script. The problem now is that when I run the script it logs the output into the terminal the content of the SQL script (which is very, very big). Is there

Counting related rows in a child table

I have been trying to do some queries and getting a count on related tables using eloquent. Tables: requests contact (belongs to requests) history (belongs to contact) As such X number of requests each have Y number of contacts which in term each have Z number of histories Using sql I can do something like this to get all the

Advertisement