Questions tagged as 'laravel-eloquent'

2
answers

Retrieving value in the pivot table as the property of a part of the relationship

I have the manyToMany relationship between Grupos and Usuarios and a pivot table grupo_usuario that stores the keys and an extra aprovador , Boolean field, which serves to indicate if the user in the relationship can...
asked by 05.08.2015 / 01:04
2
answers

How to relate two records elegantly?

At some point in my application I'm creating a post and relating it to the session user: public function adicionar(CadEditPost $request) { $request->merge(['user_id' => Auth::user()->id]); if(Post::create($request->...
asked by 17.12.2016 / 20:14
1
answer

How to bring only the latest records with Laravel 5.2

I need to return the last 10 records for a view .. return view('home.home', [ 'data' => $this->sale->get(), //aqui eu quero pegar os 10 últimos 'nav' => 'dashboard' ]); Is there any Eloquent method that does this?     
asked by 20.10.2016 / 15:59
2
answers

I can not use foreach with object twice in the same view in laravel

I have a big problem that I can not solve because I am still a beginner in Laravel. The problem is that I'm developing a web application and I need to list the cities object in two different select, however when I add the second foreach it gives...
asked by 26.10.2017 / 20:07
1
answer

Problem in recovering data in a large application

My table is constituted as follows: ╔════════════════════════╗ ║ USER ║ ╠═══════════╦════════════╣ ║ Id ║ Integer ║ ║ Name ║ String ║ ║ Address ║ String ║ ╚═══════════╩════════════╝ I have some dat...
asked by 12.11.2017 / 22:59
1
answer

RelationsShips Larval 5.4 Accessing search data with with?

I have a relationship of One To Many , I wanted to know how do I access data from the two tables. See: Album::with('imagemAlbums')->where('departamento_id', $id)->get(); Return from dd()    Now in my View...
asked by 24.08.2017 / 02:07
1
answer

Advanced search in Laravel 5

I'm starting at Laravel 5 and as learning I'm creating a simple employee's register. What I need is to retrieve from the bank an employee relationship with surveys based on search conditions. In the example below, I used When to...
asked by 24.06.2017 / 13:47
1
answer

Auth laravel error with another model?

Personally I changed the default model name of Laravel User.php to Colaboradores.php (of course, I set the $table and $primaryKey in the model), I also changed the config/auth.php to model . but login is...
asked by 21.05.2017 / 00:12
2
answers

Write to two different tables using the same View

I'm doing a supplier registration, and I need to record it in one table and its address in another. I use a single view vendors.blade to fill in all the data. How can I separate this data to write them to their respective tables? Suppliers...
asked by 07.09.2015 / 00:22
1
answer

What is a scope for in Laravel?

I saw in the documentation of Laravel an explanation about the use of Eloquent. There I saw a part where you talk about Local and Global Scopes . As I do not speak much English, I had some doubts about using it. What are these methods w...
asked by 24.08.2016 / 15:25