Questions tagged as 'eloquent'

1
answer

Error when relating tables in laravel 5.5

Veran I want to do with laravel 3 tables: Plants, User and Comments. The story is that a user can write comments about the plants to ask or answer questions about the plant. Migration of the Plants table: <?php use Illuminate\Support\Fa...
asked by 10.02.2018 / 15:24
1
answer

Laravel 5.4: I do not get data from Eloquent relationships

Using Laravel (with MySQL) I'm starting with Eloquent relationships. I try to get the related data but I do not get anything. My configuration is as follows: Migration providers: Schema::create('proveedores', function (Blueprint $table) {...
asked by 02.10.2017 / 03:28
1
answer

laravel 5.6 related models to related models

I have in the model Finca.php public function piscinas(){ return $this->hasMany(Piscina::class)->select('id' , 'finca_id', 'area' , 'name'); } And in the Piscina.php model public function finca(){ return $this->belong...
asked by 14.06.2018 / 00:48
0
answers

Problem to order related table laravel

I'm trying to sort a related table without success the original driver looks like this: $products = Product::orderBy('nombre', 'asc') ->where('user_id', auth()->user()->id)->with('Coment') ->get(); And the way I'm...
asked by 01.12.2018 / 14:12
1
answer

Filter in Laravel for work not done, incomplete or completed

I have been looking for a solution to this problem for some time but I have not found anything that I can adapt. There are two tables ordensiembras and siembras , one order can have several sowings. The Ordensiembras mod...
asked by 25.11.2018 / 18:15
1
answer

Obtain data from a Pivot laravel table

I'm trying to get the data from my pivot table. Right now the way I do it is like this $sala = Saluser::where('sala_id',$sala->id)->pluck('user_id'); $usuario = User::whereIn('id',$sala)->get(); The drawback is...
asked by 14.11.2018 / 22:34
1
answer

Is this controller code correct?

Is this driver code correct? $product = Product::find($id)->with('dsa'); using only this $product = Product::find($id); works correctly for me but when I try to add the related table I do not get it and tried it in a thousand ways a...
asked by 05.10.2018 / 12:30
1
answer

Get list of products with VAT included

I have a product model with the column price and VAT How can I get the final price (with percentage of VAT included) Especially when I do something like \App\Producto::where('marca_id', 4)->paginate(); Thanks     
asked by 06.12.2018 / 01:54
1
answer

Query with eloquent amount and limit to obtain

Hello, someone could help me with an eloquent query. User::with(['post','Y aun tengo más relaciones. ..']) ->where('nick',$nick)->first(); This way I get the information of a user X and I see the posts. but I need only show the las...
asked by 30.10.2018 / 02:58
1
answer

How to generate a proper join query that brings me data from two tables?

I am presenting inconveniences to show the data I require. I currently have two tables that are related as follows: Peliculas imagenes_peliculas -id <--> -pelicula_id -nombre -urlimg -descripcion by means of id I have tha...
asked by 12.04.2018 / 22:56