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
votes1
answer397
viewsConvert sql to query Builder - Laravel
I’m starting at Laravel and I have doubts about eloquent. Could someone help me convert that code SQL in eloquent? SELECT COUNT(d.id) as total, d.nome_disciplina FROM bd_assuntos as a INNER JOIN…
-
0
votes1
answer164
viewsIs it correct to use get/set and other methods in the model of the Laravel?
Example: In the model: public function getProduct() { return $this->where('price',100)->get(); } public function checkProduct($price) { if($price > 100){ return $price; } } On the…
-
0
votes1
answer120
viewsTransform query result into Json
I’m trying to convert a result of a database query to json yet every time I make a resquest to get the value of the same the server goes always below and I believe it is because it is a lot of…
-
0
votes0
answers206
viewsStrange memory consumption PHP Laravel
All right guys, I’m using Laravel for a project and I’m kind of worried about using memory in some classes. So I decided to do a basic test and discover that a method was consuming a lot of memory…
-
0
votes2
answers128
viewsLaravel directing HTTP method to wrong function in Controller
I have a project in Laravel and Vue.js where I have a role in Vue.js that sends a post with the data of a form, so far so good, only when the function this.$http.post() makes the request for the…
-
0
votes1
answer18
viewsCreate eloquent Query in Readable to query that take the longest date of the column and show a vehicle of each
I need to show a vehicle of each (Vehicle), which sort by larger datatime('datetime_write), how do I create this query with eloquent in the Laravel?…
-
0
votes1
answer290
viewsHow do I solve this problem of method create in Laravel
Well, I have a form that contains an html input of an image. When I send the form to Control, I do the image processing, taking his name and uploading to the image directory. More when I see in the…
-
0
votes1
answer276
viewsRelation Many to Many with id type UUID Laravel 5.4 Eloquent ORM
I’m following Laravel’s documentation to make that relationship with the id type uuid. In the relationship methods I specified the pivot table and the IDS fields, however I went to debug in Tinker…
-
0
votes1
answer228
viewsHow do I send a bank appointment to a View in the Laravel?
I have a model (table)called Member. I want to do the id count that exists in the bank. I have well managed to do it with Member::Count(?id'). It returns me all pretty the total id that I have on…
-
0
votes1
answer1565
viewsLaravel/Eloquent: How to create a primary key composed of two foreign keys?
I am creating a simple system for school management and I will have a table called 'class students', where the primary key should be composed by the student id and class id, which are foreign keys…
-
0
votes0
answers91
viewsHow to Work with more than one Laravel Table
Good morning. I am trying to use 2 mysql tables, as if they were 2 schemas, however I am not getting, I tried the examples:…
laravel-eloquentasked 7 years, 3 months ago Carlos Alexandre R Ramos 137 -
0
votes1
answer109
viewsError passing array as parameter for Eloquent object
I’m having trouble inserting a type 1:N record using Eloquent. When I pass the array with attributes to the object as the documentation guides an error is launched and when I print the error with…
-
0
votes0
answers127
viewsWhat is the right way to pass variables to the Create Laravel page
I’m making my TCC and I have a pre-registration page, where information like [nome, email, senha, token] and she saved on the table pre_register. Then a email for the person with a link, it contains…
-
0
votes2
answers851
viewsPHP - Laravel - Send a data entered in the database to another view
I’ve read questions about it, but I still can’t solve my problem. Here’s the thing, I have a separate Laravel view to register user. Ai in theory should redirect to another view where it will…
-
0
votes1
answer66
viewsI’m having a problem where I really don’t know how to do an event that hears an action on the Laravel
I have a slide show of images where the images registered in the database appear. The table is called events. In this table there is a field called end date, which would refer to the end of the…
-
0
votes1
answer1265
viewsCall stored Procedure in the Laravel using SQL Server with OUTPUT
I’m trying to call a stored file by Laravel 5.5 but I’m not getting it. I’m using SQL Server. Follow the stored Precedent: declare @CodigoRet int exec Generator 'LancaContaContabil', @Codigo =…
-
0
votes1
answer319
viewsQuery for searching with multiple tables
I need to search the data of a table of processes, and of other 2 tables one of authors and defendants of the process, the doubt is how to search in grouped form that I can go through with foreach…
-
0
votes1
answer190
viewsDoubt Join with paginate Adjustable
How to mount the following consultation with eloquent? SELECT * FROM nos.destinos d join nos.servidors s on (d.idservidor = s.idservidor) where s.servidor like '%nome%' My models class Servidor…
-
0
votes1
answer179
viewsError when trying to perform a Relationship belongsToMany in Laravel
I am trying to effect a relationship belongsToMany in my Model but is bringing the error: Queryexception SQLSTATE[42S02]: Base table or view not found: 1146 Table 'api.codigo' doesn’t exist (SQL:…
-
0
votes1
answer33
viewsError making the list
Trying to get Property of non-object: @foreach($civis as $civil) <tr> <td>01</td> <td>{{$civil->matricula}}</td> <td>{{$civil->nome}}</td>…
laravel laravel-5 laravel-eloquent laravel-5.3 laravel-bladeasked 6 years, 11 months ago Jonathan Silva Gomes 21 -
0
votes1
answer139
viewsRegister N for 1 and N for N?
How can I register in a relationship 1-N and of N para M, I’m doing it this way, but it’s not cool: $endereco = new endereco; $endereco->complemento = $request->complemento;…
laravel-5 laravel-eloquent laravel-5.3 laravel-bladeasked 6 years, 11 months ago Jonathan Silva Gomes 21 -
0
votes1
answer378
viewsCheck if registration already exists, if there is only link
I want to check if the address has already been registered, if it is already registered I just want to link it to a civilian, but if there is not yet want to register the new address and then link.…
laravel laravel-5 laravel-eloquent laravel-5.3 laravel-bladeasked 6 years, 11 months ago Jonathan Silva Gomes 21 -
0
votes1
answer61
viewsLaravel, problem with Float fields
Hello, I am using Laravel and need to make a select in a table, also create a field that brings the result of a function. my select is like this: return \DB::table("view_pins_ocorrencias")…
-
0
votes1
answer95
viewsPerform a related table search on Laravel and page
I would like to search all people of a certain class based on the class code using Laravel: And right after paginate, to make a list. Pupil public function turmas() { return…
-
0
votes1
answer12
viewsError saving a collection of checkboxes
Long live, I am using Laravel 5.1 and after submitting a form that has a collection of checkboxes array:3 [▼ 0 => "24" 1 => "26" 2 => "32" ] I save the record and then enter the block of…
-
0
votes1
answer965
viewsLaravel 5 Eloquent View Blade with Foreign Key?
I get the following error: Trying to get Property 'name' of non-object I have a list of Suppliers and Payments, and I am using the following syntax to retrieve the Vendor name through the foreign…
-
0
votes1
answer1574
viewsTrying to get Property 'name' of non-object Laravel Eloquent Error when pulling foreign key data
I am trying to use relationships to show data on screen but I get the following error: Trying to get Property 'name' of non-object In this command…
laravel laravel-eloquent laravel-blade foreign-key modelasked 6 years, 9 months ago Gabriel Alves 41 -
0
votes1
answer479
viewsGroup By Days Laravel Eloquent
I’m having trouble grouping data together for different days. I have some reports registered and with the standard Created_at and Updated_at I’d like to show these communiqués Separated day by day..…
-
0
votes0
answers35
viewsLimit relation by common attribute
I am working on Laravel and I have 3 tables (users, administrations and immobles). I would like to know, what would be the best way to relate (associate) users and properties that belong to the same…
-
0
votes1
answer44
viewsAger loading and custom queries
This question is a follow up of this and of this. But I’ll try to make them independent. I have the following tables, weathers: +--------+-------+---------+ | id | temp | id_freg |…
-
0
votes1
answer100
viewsHow to use Anxious Loading nested in Laravel 5.4 correctly? My related tables return "null"
I have the following search in my application: $results = Profile::with('profileCategories.categories', 'informations')->where('ativo', '=', "1")->where('nome', 'like', '%' .…
-
0
votes0
answers103
viewsdetach() method deleting more data
my detach method erases all data from the student table (it removes the data from the association table but deletes all data from another table) $team = Team::find($id);…
-
0
votes1
answer64
viewsJunction of Laravel searches
I have the function in my controller: public function pesquisa(Request $request) { if (! Gate::allows('celular')) { return abort(401); } $marcas = CelularMarca::orderBy('nome',…
-
0
votes1
answer223
viewsHow can I get information using Lockable with chained Join?
I have 3 layers of entities, of which I only want the third object. but based on the information of the first 2. For example, I have manufactures that manufactures cars and each car has a kind of…
-
0
votes1
answer47
viewsIterate an array to the end from a randomly generated index - PHP/Laravel
Good evening, everyone. I have an array with some bus stops with the following information: array:9 [▼ 0 => array:4 [▼ "id" => 35 "nome" => "Parada 35 - Copacabana" "endereco_completo"…
-
0
votes0
answers373
viewsCount multiple records for Chart on Laravel
How do I count multiple records with Laravel? Example: Table homicios, count the columns month, date, city separately and generate the chart in Chart. Chart 1: Jan - X quantity Feb - X quantity Etc.…
-
0
votes0
answers37
viewsAverage sales ticket using AVG Laravel
I’m trying to calculate the average sales value of a store but I’m facing some problems in calculating the total value of each sale, follow the code Controller: $valor_total =…
-
0
votes1
answer19
viewsEloquent ORM Manytomany error of Constraint 1452
I’m developing an application using the Eloquent ORM, but I’m having trouble with the N to N relation, This is the relationship: The records I’m using as a test in the Product table: The records I…
-
0
votes1
answer79
viewsRelationship error and method not found
I am studying Laravel and I have difficulties to realize the relationship of an associative table that connects 3 tables of domain. example of my model: The problem is that I can’t map from my…
-
0
votes0
answers55
viewsModel Relationship with Column Name Alias
I’m making an appointment with union in Laravel. $first = Friendship::selectRaw('id, userid, friendid, friendid as friend') ->where('userid', '=', $idUser) ->where('confirmed_friendship', '=',…
-
0
votes0
answers205
viewsHow to create a migrate and add a calculated column to an existing table in the database?
I have the ratings table that has the columns Nota1, nota2, nota3, nota4 created in the database and wanted to create a media column that already computes the media automatically, how to create that…
-
0
votes1
answer144
viewsLaravel activitylog, error in implementation
I’m following the documentation of the site: https://docs.spatie.be/laravel-activitylog/v2/basic-usage/logging-activity, but I’m not able to implement the option below: Setting a You can specify on…
-
0
votes1
answer677
viewsNot to pass an element ID through the Laravel URL
This is my route: Route::get('empresas/deletar/{notice}', 'EmpresaController@deletar'); This is the action of the button: This is my role in Controller: What happens if I pass this URL directly in…
-
0
votes1
answer130
viewsEloquent ORM select with belongToMany relation
Usuario Table usuarioid | nome 1 | joão 2 | jose 3 | maria Rede Table redeid | nome 1 | Subway 2 | McDonald's 3 | Burguer King Table Rede_usuario id | redeid | usuarioid 1 | 1 | 2 2 | 2 | 1 2 | 2 |…
-
0
votes0
answers83
viewsInitial SQL to list clients (PF and PJ). How to migrate a pure SQL Query to Laravel Eloquent?
I set up an initial SQL to pull the data. It’s working in pure SQL. I need to migrate this code to Laravel’s eloquent pattern. Can anyone help me? Thank you! Follow the example SQL: Code: SELECT…
-
0
votes0
answers519
viewsGroup data - Laravel Collection
I need to group the data of an SQL function in Indicators and Data, but in my attempt to group, I’m only getting by date(Column), for this reason the data is repeated. Model: public static function…
-
0
votes1
answer729
viewsHelp Update Laravel
Good evening, I’m starting to study Laravel and I came across a problem that has already taken me a few hours in search of a solution. I need to update a form, and when I give the Submit I get the…
-
0
votes2
answers342
viewsHow do I store 0 or 1 of a checkbox?
How do I store 0 or 1 of a checkbox with Laravel? Html <div class="custom-control custom-checkbox"> <input type="checkbox" name="dashboard" value="1" class="custom-control-input"…
-
0
votes0
answers1197
viewsProperty does not exist on this Collection instance
From what I’ve researched, it could be something related to the fact that you’re in a relationship 1:N, hasMany > belongsTo, but I don’t know what I have to do. I’m developing a API in Laravel…
-
0
votes0
answers163
viewsListing in
Hello, I have following modeling: A training table that has several training models (workouts). The models table has several exercises. At the Laravel, I need to list a particular workout (id 1, for…