Questions tagged as 'eloquent'

1
answer

Translate from SQL query to Eloquent

Hi, I'm new to eloquent and laravel, I have the following query, which runs perfectly from phpmyadmin: SELECT * FROM vips_categories JOIN vips_products JOIN vip_archivos WHERE vips_categories.parent_id = 1 AND vips_categories.parent_id = vips...
asked by 04.08.2017 / 20:49
1
answer

Apply filter in related tables laravel

Laravel's version is 5.4 Here I put the link of the project to download (Includes database to import, this in App / filtros_laravel.sql) link I will give a description of the problem. Let's start with the tables first. create table cl...
asked by 02.06.2017 / 05:22
1
answer

Laravel - Relationships using Eloquent

I'm trying to create a field relationship using eloquent de laravel, I currently have it working like this: $empleos = Empleos::latest()->paginate(50); return $empleos; I return all jobs correctly, my problem is that there are fields tha...
asked by 07.12.2018 / 00:57
1
answer

Optimize SQL query using Eloquent de Laravel

I hope you're all right, I have the following query on my system. public function visits() { foreach ($this->countrys as $country) { $query = Visit::where('country',$country)->count(); $visits[$country]=$quer...
asked by 08.10.2018 / 02:07
1
answer

how do I do this query in Eloquent

How can I make this query in Eloquent? select count(id) as NumeroPreguntas, user_id from preguntas group by user_id order by NumeroPreguntas DESC Limit 10; I tried pregunta::groupBy('categoria_id')->get()...
asked by 03.11.2018 / 00:06
1
answer

use 'where' with 'like' in an eloquent realation

hello I have two models Movement and Account In the Movement model I have the following relationship. public function cuenta() { return $this->hasOne(Cuenta::class); } What I am looking for is to bring all the Movements with their...
asked by 03.09.2018 / 01:04
1
answer

where in laravel with with

How can I use where to filter in queries with that relate multiple tables. $a = App\A::with(['bs', 'bs.cs', 'bs.cs.ds'])->get(); how can I make 'bs.cs.ds' attributeX = 40 and 'bs.cs' attributeY = true     
asked by 29.06.2018 / 20:53
2
answers

SQL query in Laravel

How can I pass the following query in Laravel 5.4 SELECT CONCAT( TRIM(SUBSTRING(NombreCliente,1,1)), TRIM(SUBSTRING(NombreCliente, locate( ' ',NombreCliente), 2) ) )INICIALES FROM 'cliente'     
asked by 14.06.2018 / 22:49
1
answer

Convert SQL query to Eloquent Laravel 5.6

I have the following SQL query to get grouped and ordered by months the sum of prices of three products, which makes no problem SELECT name, SUM(precio) AS total, mes FROM productos GROUP BY mes ORDER BY mes DESC; The result I get is...
asked by 28.06.2018 / 02:49
2
answers

problem with an eloquent query

my problem is the following I do not manage to capture the id to perform the update function I get the following error: undefined index: id this is the code: public function getUpdate() { $id = $_GET['id']; $blogPosts = BlogPost::find(...
asked by 11.07.2018 / 02:54