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
-
1
votes0
answers305
viewsSearch larger field in a table with Eloquent
I’m using Laravel for an API In my comic book I have a table called tbmanifestacao and in this table I have a column called nrmanifestacao I would like in my controller return the biggest…
-
1
votes1
answer86
viewsCheckbox value is null, Column 'situation' cannot be null
I have a field $table->enum('situacao', ['ativo', 'exonerado']);. I created a checkbox to register, but it returns the following error: 1048 Column 'situation' cannot be null. How can I solve?…
laravel laravel-5 laravel-eloquent laravel-5.3 laravel-bladeasked 6 years, 11 months ago Jonathan Silva Gomes 21 -
1
votes1
answer170
viewsAccess in the view the last values entered in the database
I am trying to access the last "Books" inserted in the bank, and display in the view. This controller function returns the view with the recovered values from the database. public function index(){…
-
1
votes1
answer1061
viewsRoute error when accessing the page in Laravel
People after I executed this command in my Standard the situation in some pages got bad, are no longer working, the command is as follows: Composer require mnabialek/Laravel-eloquent-filter Error…
-
1
votes0
answers33
viewsHow to make a select depending on some conditions that comes by parameters in Laravel 4.2?
My problem is this.... I have a route that receives the year and month to seek some information in the bank. When the month doesn’t come I need to be made the sum of all the months of the requested…
-
1
votes2
answers485
viewsLaravel 5.3: Auto_increment jump (id) (Gaps)
I did a basic CRUD using Eloquent. My problem is time to create (Create). I use the code below: public function store(Request $request) { $subscription = new Subscription; // Basic Data…
-
1
votes1
answer7082
viewsOpen existing project Laravel
I need to open a project previously done in Aravel. I’ve never worked with Laravel, so I don’t know where I might be going wrong. the project came in a file . zip when I unpacked it created a folder…
laravel laravel-5 laravel-eloquent laravel-4 laravel-5.3asked 6 years, 8 months ago Cesar Vinicius 145 -
1
votes1
answer92
viewsMake inclusions of the respective user Laravel 5.5 Auth Standard
I have a simple question, I am setting up some registrations for the purpose of studying the framework Aravel, with People, Accounts and etc.. I am using Laravel’s default authentication, and now I…
-
1
votes1
answer129
viewsOrganizing Laravel Migrations into a subfolder is bad practice?
I have created several Migrations that are related to each other, for having foreign keys and etc... but I don’t want to mix them with the Migrations related to auth, Permissions and etc. My…
-
1
votes1
answer69
viewsView does not show string value in the primary key field
Good people. I am trying to list the attributes of my table in Laravel 5.6 through a list view, but in the registration field (PK) the values contained are not presented completely. This field is a…
-
1
votes1
answer46
viewsDoes not display relationship data within WITH
I have a relationship Polymorphic between Customer and Car Class. Client class: public function carros() { return $this->morphMany(Carro::class, 'dono'); } Car Class: public function dono() {…
-
1
votes2
answers498
viewsEloquent Laravel - Column user_id
Hi, I’m learning Portable and I didn’t find this on any forums. I have some tables that have a foreign key called 'user_id', but when I save an object in the bank I always have to fill this column.…
-
1
votes1
answer5387
viewsHow to use hasmany relationship in Laravel 5.2?
I have 3 tables of funcionário, apontamentos and horastrabalhadas. My relationship is hasmany 1 employee has several apontamentos. When I show the result with a dd() comes the employee data twice…
-
1
votes1
answer873
viewsEloquent: relationships between blog tables
Someone would have a practical example of using relationships in Eloquent as follows: I have a blog with several categories, in these categories I will have several Posts, as I do to display a…
-
1
votes1
answer100
viewsFilter records within one month interval
I have several items sold in a month and would like to display only the items sold in the current month. Example: in September I had a total of 30 items sold, and in August, 20 items. How do I take…
-
1
votes2
answers44
viewsError using Many to Many
I have a group of Users who have relationship Many To Many, to create this relationship I did a function beLongsToMany within the model Usuarios. But every time I call this function I get the…
-
1
votes1
answer767
viewsMulti-Insert with Laravel 5.3 dynamic form
I am trying to do a multiple Insert with Laravel 5.3 in a table as follows: Form {!! Form::open(['route' => 'demanda.store', 'class' => 'form']) !!} <div class="form-group form-inline">…
laravel laravel-5 laravel-eloquent laravel-5.3asked 7 years, 9 months ago José Cicero Rocha Cavalcante 11 -
1
votes1
answer2555
viewsDifficulties creating update with Laravel 5.1?
I’m trying to create a update with Laravel 5.1 but is bringing the following error: Type error: Argument 1 passed to Illuminate\Database\Eloquent\Builder::update() must be of the type array, object…
-
1
votes2
answers2424
viewsTrying 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>…
-
1
votes1
answer61
viewsRelationship Doubt - Laravel?
I’m new to Laravel and PHP and I’m trying to create a simple voting system. It turns out, I’m having doubts about how to relate between my tables. For example: I have the table of Pessoa and the…
-
1
votes1
answer68
viewsWhat’s the difference between map() and mapSpread() Eloquent Collection’s
I’ve had the eloquent for a while, but I’ve read the documentation and I can’t understand the difference between the method map() and mapSpread(), there are other methods with 'Spread' in the name,…
-
1
votes1
answer35
viewsDoubt to level array after consulting SQL with Eloquent
Hey, guys, I put together the following code: $concat = array(); $products_categories = array(); $departament = $request->getParsedBodyParam('departamento'); $categories =…
-
1
votes1
answer109
viewsEloquent mapping, is it?
Is there any way to map a foreign key to a database out of my default database in Laravel Eloquent? Example: CREATE TABLE Banco1.Persons ( PersonID int, LastName varchar(255), FirstName…
-
1
votes1
answer51
viewsJoin with sum in Laravel
I am trying to bring a JSON result from my database. $products = DB::table('products') ->join('order_product', 'products.id', '=', 'order_product.product_id') ->select('products.sku',…
-
1
votes1
answer46
viewsHow to ignore the default Model $with in Laravel (Eloquent ORM)
I have a model with with already predefined calling some other models. public $with = ["itens", "filial", "cliente", "status", "produtos", "servicos", "composicoes", "execucoes", "tipo", "vendedor",…
-
1
votes1
answer66
viewsWhat is the difference between Eloquent Model::get() and Eloquent Model::all()?
What’s the difference in using Model::get() and Model::all()? Some of them are more recommended to bring all the bank records?
laravel-eloquentasked 5 years, 7 months ago JrD 1,319 -
1
votes1
answer467
viewsHow to create a relationship between 3 Laravel tables?
I own 3 tables that it is necessary to make Join’s to access the information. By the relationship of the Laravel I can create simple relationships, like belongsTo. I’m trying to access the…
-
1
votes1
answer2010
viewsHelp with relationships in the Flat
I am really enjoying using Laravel 5.4 and I have some doubts about the relationships and how best to use it have the tables evento -id -nome categorias_evento -id -id_evento -nome lotes_evento -id…
-
1
votes1
answer89
viewsInstantiate class within bootstrap/start.php file Laravel 4.2?
I have an app running Laravel 4.2, I have a class that takes care of IP's in a blacklist, and this one is safe on the bench. I need that when a user accesses my application the system validates if…
-
1
votes2
answers976
viewsResult field name instead of id on Laravel 5?
I have a relationship in Laravel but when I make an appointment comes the id and not the name of the field. Model Evento public function tipo_evento() { return…
-
1
votes0
answers99
viewsHow to pass a query to Eloquent?
I’m trying to translate a SQL for Eloquent, where she receives an id ($myid) and returns the combinations of clothing, IE, I have a table clothes and I have another table combinations_clothes and in…
-
1
votes2
answers940
viewsLaravel eloquent returning array of array
I have this consultation using eloquent $data= \App\Logs::select('id', 'created_at') ->get() ->groupBy(function($val) { return Carbon::parse($val->created_at)->format('d-M-');…
-
1
votes1
answer54
viewsGROUP_CONCAT (CONCAT... in Laravel?
I don’t know if anyone can help me I needed to execute this SQL in Laravel I just don’t know how to use the GROUP_CONCAT with the CONCAT within? select dictionaries.name,…
-
1
votes1
answer79
viewsnumber_format() generates error only in Return
Inside the table orders, I have a field valor defined as decimal(10,2). In the archive Order.php, I created a method to format the value: public function getValorAttribute($valor) {…
-
1
votes1
answer414
viewsSave in two tables with dynamic inputs (one-to-Many) Laravel
I couldn’t make a mistake: Errorexception in Parameterbag.php line 88: array_key_exists(): The first argument should be either a string or an integer My Controller: public function store(Request…
-
1
votes1
answer38
viewsRelating 3 Standard Tables
Hello. I have a small model attached here. My task is from users, to get the records of Orders that have some record in the payment with the id of that order and the id of that user. Basically, an…
-
1
votes1
answer330
viewsMass Attribution in Laravel
use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; class Sale extends Model { protected $guarded = ['id']; public function vendor() { return $this->hasMany('App\Vendor');…
-
1
votes1
answer367
viewsHow to save a foreign key in Laravel 5.3?
I am having trouble saving the foreign key in the database. I am working PHP, Laravel 5.3 and MySQL, below goes the code: Controller Product namespace App\Http\Controllers; use…
-
1
votes2
answers1429
viewsLaravel 5.4: List information from 4 tables related to the WITH clause
As you can see in convenio controller, I am listing the information of each agreement along with the information that are in other tables(phones, addressee), but I would also like to list the…
-
1
votes1
answer162
viewsRelationships Laravel Onetoone?
I’m doing some exercises, but there is one but I can’t understand why it’s not working when I do it with another name in the method. I have a method in the Model Location, where he does the…
-
1
votes1
answer4875
viewsHow to make specific sql queries using Laravel?
I need to make an appointment at the bank to see the birthday of the current month. A consultation of this type, see: SELECT * FROM membros WHERE day(dataNasc) = day(CURRENT_DATE) and…
-
1
votes1
answer156
viewsBelongstomany Laravel 5.4 Class 'Department::class' not found
I have several 4 tables Starting with Users -> Departments -> categoria_departamento -> category -> posts; Where the categoria_department table it serves as pivot for relation Many to…
-
1
votes1
answer787
viewsInsert Many To Many Laravel 5.4
I have a situation as follows. I have 4 user tables -> department -> categoria_department -> category -> posts Where in my view I have a select where it shows a data relation on ex…
-
1
votes1
answer246
viewsHow to make paging in a table that this related Laravel 5.4
There is a 2 tables and a pivot where she makes the relationship ManyToMany among the 2 tables. A table is called Postagems and the other table is called Departamentos, so I’m trying to do a related…
-
1
votes1
answer678
viewsSum of quantity multiplied by product value in daily sales
I have an order page, let’s take as a base a mercantil, where the person buys 3 sodas each with the value of R $ 6,00 and 2 cookies in the value of R $ 2,00 each. First I need to multiply these…
-
1
votes1
answer706
viewsLaravel / Eloquent - Consultation in more than one table
I have the following Tabelas/Models and I’m not getting a consultation: Model 1 id | Name ---+--------------- 1 | Model1.1 2 | Model1.2 3 | Model1.3 Model 2 id | Name | model1_id…
-
1
votes1
answer1236
viewsCan I use select in Relationship on the Windows?
I have a model that takes the data with a with in the Standard, to take correlated data, there is form of these correlated data come only some specific fields and not all the data of the table? I…
-
1
votes0
answers753
viewsHow to use Eloquent without losing performance (51.39%) in Lumen 5.4?
Developing an API that should handle a high performance website. Doing some tests I verified that the use of Eloquent is downloading the performance of the requests in the database Mysql in 51.39%…
-
1
votes1
answer417
viewsHow to set up sending email in Laravel within cron?
After the creation of cron (code below) is made a scan in the database behind changed data. I have to send an email with this data. How can I do that ??? Code of the cron: <?php namespace…
-
1
votes2
answers501
viewsI cannot use the foreach with object twice in the same view in the Laravel
I have a big problem that I can’t solve because I’m still a beginner in Laravel. The problem is I’m developing a web application and I need to list the cities object in two different select, but…