Questions tagged as 'laravel-eloquent'

1
answer

Create fake relationship in model Laravel

I have a model for my posts table, it looks something like this: $post = Post::where('titulo_url', $titulo_url)->first(); //$post->id //$post->categoria_id //$post->titulo_url //$post->titulo //$post->texto As you may have...
asked by 21.10.2015 / 03:36
2
answers

Send data only to sidebar.blade.php

I need to set up 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 query works on view categorias.blade.php , I just nee...
asked by 16.09.2015 / 18:56
1
answer

Error saving data from a form to different tables

I have two Entries and Company tables that have a 1 to 1 relationship I have a form that the user selects if it is pf or pj, if it is pj it opens the options to save the company. But when I give the $ company- > save () it generates an...
asked by 21.03.2014 / 04:38
2
answers

Populating database with Eloquent ORM

I have a database with some tables already populated, but now I have to populate the tables that have a foreign key, I'm trying like this: $tamanho = Tamanho::find(2); $genero = Genero::find(1); $categoria = Categoria::find(2); $estampa = Esta...
asked by 07.02.2014 / 16:50
1
answer

Using Foreign Keys Laravel 5.6

Good afternoon everyone. I created a migration "clients" in the laravel that receives 3 foreign keys coming from entities: modalities, requests and locals. In my view when registering a client and viewing in phpmyadmin I see that all the data...
asked by 20.09.2018 / 20:45
0
answers

Error adding constraint (General error 1215) - Laravel

I'm trying to create two related tables. When attempting to 'migrate' them, the error is returned: "SQLSTATE [HY000]: General error: 1215 Can not add foreign key constraint (SQL: alter table 'companies' add constraint companies_taxregimeid_forei...
asked by 06.09.2018 / 17:54
2
answers

Eloquent Laravel - Column user_id

Hello, I'm learning laravel and I do not find this in any forum. I have some tables that have a foreign key called 'user_id', but when I save an object in the database I always have to fill that column. Is there a way to do this? I want to be ab...
asked by 08.05.2018 / 03:36
0
answers

CRUD - LARAVEL 5.6

I'm developing a CRUD and in my controller I have the create function: public function create() { $neighborhood = new Neighborhood(); $city = new City(); return view( view: 'admin.cities.create', compact( varname: 'city', _:'neighb...
asked by 24.04.2018 / 03:13
0
answers

Laravel: how to insert into the database asynchronously?

I'm developing a website in PHP, using Eloquent for database, and I'm having a certain problem of slowing down the user time to log in to the database. What I mean is ... The user is taking almost 3 seconds to get logged in, and since I'm a b...
asked by 20.04.2018 / 21:03
1
answer

Is organizing laravel migrations in a subfolder bad practice?

I created several migrations that are related to each other, having foreign keys and etc ... but I do not want to mix them with migrations related to auth, permissions and etc. My question is: Can I create a subfolder to organize my migration...
asked by 07.03.2018 / 19:33