Most voted "laravel-eloquent" questions
Eloquent is the Laravel ORM. Use this tag for questions specific to the use of Eloquent and its related models
Learn more…425 questions
Sort by count of
-
0
votes2
answers1209
viewsHow to make a ternary relationship in Laravel?
What is the best way to make a ternary relationship in Laravel? I am doing a "multi client/company" application (type Basecamp) and the following relationship appeared: one user has a (0 .. n)…
-
0
votes2
answers666
viewsModel delete method does not erase record
I have the code below on the route, but it doesn’t work! What am I doing wrong? It is returning users correctly but doesn’t delete. $Usuario = User::find(2); $Usuario->delete(); return…
-
0
votes1
answer191
viewsImproved image insertion in comics
How would be a way to minimize this image insertion code in the database? // controller/GaleriasController.php public function addGaleria { $galeria = new Galeria; $galeria->descricao = "galeria…
-
0
votes1
answer120
viewsForm::model+checkbox in view Edit
I’m using form::model for data editing. It works correctly but checkbox returns empty. How do I return the ones saved in bd? I want them to show the ones who are registered. For example: in the…
-
0
votes2
answers79
viewsHow to bring Model by IDS and sort at the same time
I am with the ids returned from an immense query to bring the posts with a search term... Already working bring the posts through the Model by the selected IDS but it always brings sorted by ID and…
-
0
votes1
answer289
viewsField return in Laravel
I have the following field stored in my database: When trying to return it in view by Laravel 5.2 he is returning only the 45 the rest is not. the field is defined this way in the bank: But other…
-
0
votes1
answer289
viewsEloquent + Object carrying itself
I’ve always used Eloquent very well with static methods. Yesterday, when creating a new concept of session registration for a new project, I came across a question that I could not clarify. I have a…
-
0
votes2
answers267
viewsDelete method returns unencumbered page
I use the form below to send the id of the row to be deleted in the table: <form method="DELETE" action="{{ URL::to('receitas/delete') }}" > <input type="hidden" name="id" value="{{…
-
0
votes2
answers3068
viewsDynamic Combobox with jQuery + Laravel
I am on a registration screen where there is a combobox of State and Cities. City has q be filled after the state is selected. I have create.blade.php <div class="form-group"> {!!…
-
0
votes1
answer856
viewsFilter a query using an attribute in Laravel
I have, briefly, the following structure:: Suppliers: id | cnpj | razao_social | endereco_id People: id | nome | tipo_pessoa | fornecedor_id Addressee: id | logradouro | cep Model - Supplier: public…
-
0
votes0
answers448
viewsConnection refused Lockable
When I send my form, after processing the data in the save method of the Laravel the following error happens: QueryException in Connection.php line 769: SQLSTATE[HY000] [2002] Connection refused…
-
0
votes1
answer174
viewsEloquent giving error 500 with many results
I’m performing a query in my base with some LEFT JOIN and some WHERE clauses, however, I’m having a lot of difficulties with the return of this query that, for having many results, simply after a…
-
0
votes0
answers813
viewsHow to build an Object with an Array inside, using Eloquent Laravel
Hello folks I need to build a array as follows for a plugin: var data = [{ "label": "Follows", "color": "#aad874", "data": [ ["Seg", 50], ["Ter", 84], ["Qua", 52], ["Qui", 88], ["Sex", 69], ["Sab",…
-
0
votes1
answer184
viewsUse of the Eloquent hasManyThrough
// Modelo Cliente public function plano() { return $this->hasManyThrough('App\Plano', 'App\Plano_cliente','cliente_id','id','plano_id'); } //Modelo Plano public function cliente() { return…
-
0
votes0
answers721
viewsLaravel 5 (Eloquent) JOIN between two consultations, is it possible?
The following SQL, executes two queries and "sums" the hard answers "laterally": select * from (select id,name from client where id = 20) as a join (select id,age from client where id = 20) as b ON…
-
0
votes0
answers85
viewsAJAX with Slim Frame
Project : https://github.com/noebezerra/survey-slim I have a problem with the AJAX request ( Resources/views/templates/app.Twig ) ajax - app.Twig $('.stars-default').click(function(e) {…
-
0
votes2
answers345
viewsResults per logged-in user id
have a users table with primary_key id and I have a people table with a user field I want to understand how to use the relationship of the Laravel for these tables and want to search the person with…
-
0
votes1
answer418
viewsLaravel does not return Belongsto
Opa galera I have two tables one with name Product and another with name Productocategoria. When I go to make the relationship in the models, only the Product object returns the products, the…
-
0
votes2
answers1153
viewsLaravel Relationship 5.2 Eloquent
Good morning, everyone, I’m having a problem in a relationship between tables with Elouquent (Laravel) I have two tables [clients / activities_commercial] (innoDB MYSQL) In the client table there is…
-
0
votes4
answers1103
viewsUpdate with Laravel does not take model id
I am trying to perform a simple function to change the password of the logged in user using the code: $user = User::find(\Auth::user()->idusuario); $user->password =…
-
0
votes1
answer382
viewsHow to make the CRUD by model in Laravel?
We can do in the controller the method save() the find($id) the update() and create(). How could I do in that Model had that accountability?…
-
0
votes0
answers93
viewsSum of working time of several employees
I have a collaborators table, and other 2 activity tables, each with a column of time used to perform that activity and I would like to add these tables to know the total time, example, employee A…
-
0
votes2
answers139
viewsI can’t find the model generated by Artisan
I used the command php artisan make:model Exemplo and I couldn’t find where he saved this generated model so I could change it. I looked in the app/html folder and found nothing. My db is ready, so…
-
0
votes1
answer119
viewsPagination in relation to Laravel
How to make pagination in Laravel in hasMany() method for relations between models in Laravel?
-
0
votes1
answer48
viewsHow to make several separate selects with the 4.2 Standard?
Hello I need to make a select on a table, however if I do not receive the month by the parameter I must do the SUM method to sum all months if($month != 0){ $dbRegister =…
-
0
votes0
answers906
viewsPass Controller data to a modal in the Laravel 5.5 view
I’m trying to pass data from a Controller to a Modal in the view. In the view I have this code populating a datatable as soon as the page loads: .... @foreach($exames as $exame) <tr>…
-
0
votes0
answers70
viewsHow to set timeout to dump in database.php?
I need to increase the timeout of MySQL for the execution of a dump bank. 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', '3306'),…
-
0
votes1
answer674
viewsPHP Artisan Migrate Error
I am having the following error while executing the command. In Connection.php line 647: SQLSTATE[HY000] [1049] Unknown database 'localhost' (SQL: select * from information_schema.Tables Where…
-
0
votes1
answer36
viewsWarning when calling orderby method statically
In the Phpstorm interface is displayed a warning message stating that I am calling the orderby method in a static way, however, this is not static. My call: Artigo::orderBy('edicao',…
-
0
votes0
answers659
viewsError Laravel 5.6 "Undefined Property"
I am trying to list an association table, in my case it is the class table, which associates employees (teachers) and students. I did a good search before posting this question but could not solve…
-
0
votes0
answers52
viewsNotifications equal to facebook notifications for PHP
What is the best way to develop notifications that work the same as on Facebook when someone likes posting? I’m using PHP & Laravel 5.5. Anyone knows or has seen this in…
-
0
votes3
answers214
viewsHow to create a PHP progress bar using the Laravel Framework?
Please, someone can help me. I need to create a progress bar for a PHP application using the Laravel framework. Example: when loading (display the BD list) from a table with three thousand records…
-
0
votes0
answers668
viewslocal.ERROR: SQLSTATE[23000]: Integrity Constraint Violation: 1452
Expensive, You can help me with this mistake: local.ERROR: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails…
-
0
votes1
answer344
viewsPick up data pivot table Laravel
How can I get the pivot table data using Laravel Eloquent? I need to know which setor_id of users and the group_id linked…
-
0
votes0
answers26
viewsParameter by name in the query
I have the following appointment SELECT * FROM myTable WHERE ip = 192.168.1.2 I would like to make a query by sending parameter by name using DB::raw() $dados = DB::raw("SELECT * FROM myTable WHERE…
-
0
votes1
answer74
viewsInsert multiple rows of a single query using FOR
I’m trying to input a lot of data using FOR but it’s not working. The impression is that he is not getting the data from FOR? The expectation is that this happens:…
-
0
votes0
answers77
viewsWith do Eloquent is not bringing any value
I am using Laravel 5.2, I am trying to make a 'Join' n to m with the 'With' of 'Eloquent' but it does not return any value, even if they exist in the database. Class Pessoa: class Pessoa extends…
-
0
votes0
answers249
viewsAre Getters and Setters automatically generated by Eloquent when we use reliese/Standard to generate Modules?
I have an application already functional. I am switching to Laravel 5.4. Since the database already exists and with actual data, my choice is not to use Migrations. One option would be to use the…
-
0
votes1
answer155
viewsTransform Mysql query into Eloquent (Laravel)
I have a simple query on MySQL, the query lists all the data of a table making a Group By in the field grupo_id and listing the latest data from Group By based on the created_at. In short, he lists…
-
0
votes0
answers477
viewsError Method save does not exist in Laravel
Good afternoon guys. I have an application that uses Polymorphic Relations according to Laravel’s doc. https://laravel.com/docs/5.4/eloquent-relationships#polymorphic-Relations I have the error…
-
0
votes1
answer158
viewsHow to create Scope in Laravel 5.4 with linked tables via belongsToMany
The structure of the table is this: pessoa id - integer nome - string unidade id - integer nome - string pessoa_unidade pessoa_id - integer unidade_id - integer I have the models: class Pessoa…
-
0
votes2
answers286
viewsDynamic URL in the Laravel
I’m working on a website project for writers. In this project there are 12 genres within the table "categories", for example: Poems, Acrostics, Chronicles, etc. I’m having trouble creating the…
-
0
votes0
answers44
viewsAccess to database functions using Laravel
Hi, I’m new to using Laravel and I have a question. To access pre-defined functions in a database, I do it directly from the controller or would have a more appropriate way for such a process?…
-
0
votes0
answers150
viewsGroup By | Relationship Many To Many Laravel 5
I am developing an application in Laravel 5 where I have the tables employees, companies, exams, employee_exams and their respective fields according to Migration below: :: Companies Table public…
-
0
votes1
answer168
viewsUUID in Arabic and eloquent
Well I know that in Laravel some new UUID methods have been added in this package use Illuminate\Support\Str; but what its not how to use in eloquent, can anyone help me to know how to modify the…
-
0
votes1
answer15
viewsCapture ID eloquently on JOIN
Good afternoon everyone, I have the following appointment: $acordo = tb_acordo::join('users', 'users_id', '=', 'users.id') ->join('tb_status_acordos', 'tb_status_acordos_id', '=',…
-
0
votes1
answer256
viewsFind element of the intermediate table using Laravel
I’m developing a system that has an N:N relationship situation and need to create a third table. The relationship is between Product and Coloured. inside the Product Model, I put this function:…
-
0
votes1
answer263
viewsHow to display Data in datatables in the Laravel with related tables
In the image we have the student table that is related to discipline and discipline with teachers. I want to know how to display the data of these tables in a datatables in the language…
-
0
votes1
answer108
viewsGet description of sub-category PHP Laravel Eloquent
Hello, I need to get the description of my parent category, but I can’t get the description in the same select, I can only get the id of the parent category. I have a table with the following…
-
0
votes1
answer44
viewsEloquent returning JSON as variable
I have mounted the following query inside my controller: public function __construct() { $informations = Informations::get()->first(); View::share( 'informations', $informations ); } The idea is…