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
-
2
votes1
answer59
viewsHelp with a simple Join
Good evening, I don’t know what I’m doing wrong, I have two models, in Migration I created like this Schema::create('endereco_tipos', function (Blueprint $table) { $table->increments('id');…
-
2
votes1
answer750
viewsInvalid Handle returned - Laravel connection to SQL Server
I was developing an application with Laravel 5.5 with a Mysql database. Everything was working normally, however, now the database has been modified to SQL Server. When I perform the test, returns…
-
2
votes1
answer1104
viewsHow to set up remote database in Laravel 5.4
I am setting up bank in Laravel 5.4, but the same is hosted on another served, configured in Navicat is accessing normally, but Laravel does not connect. APP_NAME=Laravel APP_ENV=local…
-
2
votes1
answer1478
viewsClasura Where em campo tipo json no (Laravel + Eloquent)
The problem is the following, I have to bring from a select the permissions that a profile has, only that the permissions are in a json field, and because it is several permissions we have a…
-
2
votes2
answers218
viewsLaravel/Eloquent - Undefined variable: idPedido
I have two queries searching the model. The first one is working normally: $pedidos = Pedido:: orwhere(function($query){ $query->where('user_id', $_SESSION['idUsuario']) ->where('status',…
-
2
votes1
answer210
viewsData Recovery Problem in a Portable Application
My table is as follows: ╔════════════════════════╗ ║ USER ║ ╠═══════════╦════════════╣ ║ Id ║ Integer ║ ║ Name ║ String ║ ║ Address ║ String ║ ╚═══════════╩════════════╝ I have some data already…
-
2
votes2
answers808
viewsHow to automatically move data to the view in Laravel Resource Controller?
I am using Laravel 5.6 with Resource Controller. My show method: public function show(Artigo $artigo) { $artigo = $artigo->first(); return view('painel.revista.detalhes', compact('artigo')); } It…
-
2
votes0
answers170
viewsConvert sql into eloquent
How can I convert this code sql in the eloquent? SELECT CONCAT(FLOOR(sum(diferenca)/60),'h',MOD(sum(diferenca),60),'m') as tempo FROM (SELECT TIMESTAMPDIFF(MINUTE, m1.created_at, min(m2.created_at))…
-
2
votes1
answer48
viewsSQL with data associated with Laravel?
I have the following tables listed below Products id product value validity Consultation id user_id Consults_products id query product Whenever a user performs a query, the history is saved in the…
-
2
votes1
answer141
viewsCreate Groups and Group Items Within Them
I have the following problem, I have a table with items and I need to create groups and name each item to its own group. I have already distributed them by categories, which in this case I call…
-
2
votes1
answer363
viewsConsultation Eloquent select total
I am trying to group to bring totals in my query that is in mysql SELECT COUNT(*) as total ,e.descricao FROM pedido_cliente p INNER JOIN estabelecimentos e on e.id = p.estabelecimento_id GROUP BY…
-
2
votes1
answer24
viewsI’m trying to do a validation on the Laravel but it’s not going
When I leave the registration form fields without filling in, rule messages are displayed. This is the customer registration code: <?php namespace App\Http\Controllers; use…
-
2
votes1
answer774
viewsTake column name with foreign key
I have a product table that refers to id table categories, but do not want to take the number id of the foreign table, and yes the name of this reference. My controller is like this: public function…
-
2
votes1
answer49
viewsHow to enter stipulated amount of the same record in the database with different id in LARAVEL
I have a form that already creates one record at a time in the bank. I would like to inform in this same form through a quantity field ($request->Quant) where I can enter the amount to be created…
-
2
votes1
answer341
viewsRelationship N to N with 4 tables in Laravel 5.6
Good afternoon, you guys, I started using the framework Laravel a little while ago and I’m having difficulties in implementing a relationship N/N using 4 different tables. The scenario is as…
-
2
votes2
answers49
viewsQuery to return minimum amount of "different" values
I have a table called clientes and this table has a column status which may have +/- 3 types (novo, cancelado, pendente...) need to display a quantity of information separated by status, and instead…
-
1
votes2
answers318
viewsPopulating database with Eloquent ORM
I have a database with some tables already populated, but now I have to popular the tables that have foreign key, I’m trying so: $tamanho = Tamanho::find(2); $genero = Genero::find(1); $categoria =…
-
1
votes2
answers1449
viewsQuery in related tables
How would be an example of a bd query with related tables and an insertion of data in them. I have the tables : Produtos Tamanhos Generos I need to display in the view produtos.blade.php a list of…
-
1
votes1
answer294
viewsSearch for cross-results in related tables
I created several tables: Users: chave primária email senha Physical Detail: user_id altura Personal Data: user_id estado_civil Now I’m having a hard time getting mixed results. Example: find users…
-
1
votes1
answer161
viewsHow to concatenate value into a dropdownlist in Laravel 5?
How to add the first default value to a dropdownlist? I tried to do this way: {!! Form::select('Usuario.est_id',array('null' => 'Selecione') + $estados, null, ['class' => 'form-control']) !!}…
-
1
votes1
answer437
viewsError saving form data to different tables
I have two tables Entries and Company that have relationship from 1 to 1 I have a form that the user selects if it is pf or pj, if it is pj opens the options to save the company. However, when I…
-
1
votes2
answers141
viewsError making a Post
I am trying to save the information that comes from my registration form with this function: public function postCreate() { $this->beforeFilter('csf', array('on' => 'post')); $validator =…
-
1
votes1
answer530
viewsMaking exceptions in the Eloquent ORM Observers
I have the following code in my model: public static function boot(){ parent::boot(); // Não deixa excluir caso possua registros vinculados. static::deleting(function($content_area){ if($total =…
-
1
votes1
answer637
viewsEloquent Relationship of Laravel
I have 3 tables: -- tipos id nome -- usuarios id tipo_id nome email -- atividades id usuario_id descricao I’m using Eloquent to capture activity and activity user data: $results =…
-
1
votes3
answers9425
viewsEloquent with does not Inner Join?
I remember in the old days "discovering" that in a query using Eloquent, if I used the with Laravel made a inner join. Today by chance I went to check the queries of a project and... [2014-11-20…
-
1
votes1
answer552
viewsRelationship between various tables in Eloquent
I am trying to create the models in Lumen based on my current database for a virtual store, but I am having difficulties to configure the relationships between them. So far I have the following…
-
1
votes1
answer102
viewsProblems entering entire data into Sybase using Laravel
Hello, I’m having trouble inserting values into tables with entire data type columns using Laravel 5.1 and Sybase. Error 257 is listed when the exception is thrown. In the Sybase manuals it seems to…
php laravel laravel-eloquent laravel-5 sybaseasked 9 years, 3 months ago Ademir Mazer Jr - Nuno 2,258 -
1
votes1
answer609
viewsRelationship N:N in Laravel does not record object attributes
My tables have, briefly, the following structure: minutes: id | vigencia products: id | nome | descricao ata_produto: ata_id | produto_id | vlr_produto | qtd_produto The same product may have…
-
1
votes2
answers501
viewsSend data to sidebar.blade.php only
I need to build a menu using the registered categories. How can I do this without using a view? I have my layout.blade.php with a @include('sidebar') My consultation works on view…
-
1
votes1
answer70
viewsCreate Fake Relationship/Relationship in Laravel model
I have a model for my post table, it looks like this: $post = Post::where('titulo_url', $titulo_url)->first(); //$post->id //$post->categoria_id //$post->titulo_url //$post->titulo…
-
1
votes2
answers245
viewsData Display Issues Laravel 5.1
I’m a beginner in Laravel and I’m trying to bring data from a BD with multiple Postgresql schemas with Laravel 5.1 and is bringing me an error What configuration should be done for the model to…
-
1
votes1
answer499
viewsDynamic list in alphabetical order?
Within that array of my dynamic list, its contents are returning in a way disorderly, how do I put it alphabetically? <div class="form-group"> <label for="nome">Categoria do…
-
1
votes2
answers493
viewsSpecify columns in a relationship with Laravel
I have a relationship of User with Role. User::with('role')->get() In the case, User has the columns: id, name, role_id, created_at and updated_at. And Role has: id, name, slug, created_at,…
-
1
votes1
answer1648
viewsExample of importing XML using Lavarel
Does anyone have a clear example to import XML using Laravel Parser or Simplexml ...? I have a scenario where I have to import an XML from an external system that contains various information…
-
1
votes3
answers753
viewsCPF Regex with Laravel
The system where I am doing maintenance has Cpfs registered in two ways, with and without score, due to a bad development start that did not impose a standard. The problem is that the CPF cannot…
-
1
votes1
answer1800
viewsRelationship Many-to-Many Laravel 5
Good afternoon. I am developing a system in Laravel 5.3 with the following tables: From the commission id, I need to bring all the related data in a view where I will list in a table which…
-
1
votes2
answers1613
viewsLaravel, foreach and database
I have the following table in the database public function up() { Schema::create('cidades', function (Blueprint $table) { $table->increments('id'); $table->integer('uf');…
-
1
votes1
answer186
viewsCreate alias for columns of a table in Laravel
Is it possible to create alias for the columns name of a table in using the Laravel Model? Example: I have a table questao with the columns: id questao disciplinas_id serie_id professor_id It would…
-
1
votes1
answer455
viewsConsultation in Related Tables | Laravel 5.4
I have the following relationship in a test system that I’m doing. :: MODEL EMPLOYEE public function users(){ return $this->hasMany('lbo\User'); } :: MODEL USER public function employees(){…
-
1
votes1
answer222
viewsLaravel: how to retrieve a model’s primary key after saving it
would like to know if it is possible to recover the ID of a model at the time it is saved in the bank. I am using the following Eloquent method: $modelo = Modelo::create(['ATT1' => 'valor1',…
-
1
votes1
answer523
viewsProblem with model Aravel 5.2
Well I’m having a problem with my model, I don’t really know what’s going on, I’m creating a packaging CRUD where I add everything dynamically with the requests in the signature of the function.…
-
1
votes2
answers1365
viewsConsulta Laravel Eloquent
How to query below with Eloquent, in view of the fact that the Group By of error in the Eloquent. SELECT otimibus_gps.positions.id, otimibus_gps.positions.deviceid,…
laravel-eloquentasked 7 years, 1 month ago Carlos Alexandre R Ramos 137 -
1
votes2
answers434
viewsRemove Orange Result Quotes 5.4
I’m getting a result via Request in the Laravel thus: "2,1", I need to remove double quotes of the result, because when I enter as parameter in the query the whereIn understands as a string instead…
-
1
votes1
answer465
viewsLaravel 5.2 - Relationship Many To Many between records of the same table
The tables: The table users, records users who may have N functions that are stored in the table funcoes (student, responsible, teacher, etc). The table funcao_user is pivot that makes the…
database laravel laravel-eloquent relationship laravel-5.2asked 8 years, 2 months ago Julio Alves 83 -
1
votes1
answer181
viewsHow to insert multiple rows of a single query using the same ID
I’m trying to make multiple Inserts using the same ID with the Laravel but it is doing only 1 Insert. The idea would be something like this. ped_cod|est_cod|ped_qtde 8 |2 |9 8 |3 |2 8 |4 |2 8 |9 |15…
-
1
votes2
answers73
viewsBug change position of banners site Laravel
I’m developing a website where it has a banner modal and I want to define a field in the database of type "order", where I can define which banner appears in first, second, third ... on my admin…
php database laravel laravel-5 laravel-eloquentasked 8 years, 2 months ago Danilo Tiago Thai Santos 409 -
1
votes1
answer297
viewsHow to hide fields in queries using eloquent Join method
From a question, I was given a way to make queries with children objects using the Join of the eloquent, The query is below: $dados = Roda::join('veiculos', function($query) {…
-
1
votes1
answer2006
viewsHow to get all users currently logged in to Laravel 5.4
I need to loop all users who are currently logged in to the system. How could I do that? I know with auth()->check() we can know if a user is logged in. More I wanted to know of everyone who is…
-
1
votes1
answer544
viewsHow to perform a double consultation in the Standard?
I have a query in SQL Ansi: select * from payments as P, receipts as R where P.created_at < CURRENT_DATE AND P.updated_at < CURRENT_DATE AND R.created_at < CURRENT_DATE AND R.updated_at…
-
1
votes1
answer1184
viewsRelationship of Laravel Tables
I have a bank with the following relationships: I’d like to bring the relationship of Menu as per the Perfil of the user. In tiker I do the following steps: $user = App\Models\User::find(1); $perfil…