Questions tagged as 'laravel-eloquent'

2
answers

Trying to get property of non-object?

This is my View : <tbody> @if(isset($pessoas)) @foreach($pessoas as $p) <tr> <td>{{$p->nome}}</td> <td>{{$p->idade}}</td> &...
asked by 02.03.2017 / 14:40
2
answers

Laravel, 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'); $table->string('nome_uf');...
asked by 20.06.2016 / 19:52
1
answer

Update of a single information in Laravel

I'm starting to work with Laravel and wanted to know if you can help me. I need to update a single value in the database, using 'name' in the where clause instead of id. This is for a situation of a real system that I need to migrate to Larav...
asked by 20.11.2018 / 22:02
1
answer

Reduced code for insert

Let's say you have the following fields in the users table:    ID , NOME , USUARIO , LOGIN and SENHA For me to insert a record into the table I do the following $usuario = new Usuario(); $usuario->nome...
asked by 23.05.2018 / 22:24
1
answer

How to change the laravel relationship keyword

I have the following problem, I logged into a project where the database already existed and is in production, so all the foreign keys of this database are under the nomenclature fk_ and Eloquent of Laravel , related the% of%...
asked by 05.03.2018 / 18:06
1
answer

Using count () in Laravel

I have controller that plays for my view the total number of courses registered in the portal. My doubts are due to the operation of the count() method. For example, output of both statements below are equivalent:...
asked by 07.11.2016 / 13:14
1
answer

Doubt join with paginate laravel

How to mount eloquent the following query? SELECT * FROM nos.destinos d join nos.servidors s on (d.idservidor = s.idservidor) where s.servidor like '%nome%' My templates class Servidor extends Model { protected $primaryKey = 'idserv...
asked by 31.10.2017 / 18:58
2
answers

Inquiry Laravel Eloquent

How do I generate the query below with Eloquent , since Group By of error in Eloquent . SELECT otimibus_gps.positions.id, otimibus_gps.positions.deviceid, otimibus_gps.positions.devicetime, otimibus_gps.positions.lat...
asked by 25.09.2017 / 18:51
1
answer

Sum of the multiplication of the quantity by value of the product in daily sales

I have a page of orders, we will take as base a mercantile, where the person buys 3 soft drinks each with the value of $ 6.00 and 2 cookies in the amount of $ 2.00 each. I first need to multiply these values (3 * 6) and (2 * 2) and then add th...
asked by 07.10.2017 / 19:11
1
answer

Select with Laravel / Eloquent

I have the following select in my controller: $turmaAlunos = DB::select(' SELECT alunos.ST_ALUNO_ALU, alunos.ID_ALUNO_ALU FROM alunos WHERE alunos.ID_ALUNO_ALU NOT IN ( SELECT turma_alunos.ID_ALUNO_ALU FROM turma_alunos...
asked by 14.08.2017 / 03:48