Questions tagged as 'laravel-eloquent'

1
answer

Doubt with relationship One to Many

I have two tables, produtos and categorias . In my view of produtos I want to show the category name of that product, not your code. Category Template Category.php namespace MagicCommerce\Site\Cadastros; class...
asked by 07.01.2014 / 22:19
3
answers

How to solve foreign key error 150 in migration with laravel?

I'm having trouble creating the foreign key in migration. I'm working with PHP, LARAVEL 5.3 and MYSQL. You are giving me the following error: Below is my code: Table Migration of the categs class CreateCategsTable extends Migr...
asked by 28.07.2017 / 12:49
2
answers

Sort items from a Collection from a predefined value

I have a Collection of Eloquent and would like to sort it by two fields at the same time being one of them a predefined value. Ex: this Collection has several objects of type Categoria and I want to sort it so that catego...
asked by 18.07.2017 / 16:42
3
answers

I can not access the property of the object. Laravel / Eloquent ORM

I can not access the properties of the related object. Well, I have a class named FileClass , it has the following relationship with class FileServico : FileClass.php public function fileServico(){ return $this->has...
asked by 05.06.2014 / 18:59
2
answers

How to do a search with Query Builder in Laravel?

I need to display the name of the doctor who requested a patient report, but with Laravel I tried to show this information in View like this: {{laudo->paciente->medico->nome}} Then I received the error message:    Trying to g...
asked by 01.11.2017 / 15:19
1
answer

Laravel 5.2 with pagination

I have the following function inside the controller public function home() { $igrejas = Igreja::paginate(3); $igrejas->setPath('igrejas'); return view('admin/igrejas/home')->with('igrejas', $igrejas); } I need to be return...
asked by 02.08.2016 / 20:19
1
answer

Search for relationship Laravel whereHas?

I have a Query in my Criteria that returns the id belonging to relationship between models if ($this->request->has('notin_portal')) { $portal = $this->request->get('notin_portal'); if ($this-...
asked by 04.10.2016 / 21:47
1
answer

Do a HasMany by date with Laravel 5.3?

Is there any way to do HasMany by bringing records by date? public function despesas() { return $this->hasMany(Despesa::class); //registros apenas desse mês } I tried to use the following but did not scroll: public functio...
asked by 22.11.2016 / 11:38
1
answer

Save relationship 1: 1 in Laravel 5.3

In my scenario, I have the tables of users and teachers, where a teacher has a user, so I have a 1:1 relation. Migrations: create_users_table Schema::create('users', function (Blueprint $table) { $table->increments('id'...
asked by 07.01.2017 / 01:33
3
answers

Blade default value laravel 5.2

I have the following code <strong class="primary-font">Complemento</strong> <p>{{ $produto->complemento or 'Esta produto não tem complemento' }}</p> I need the system to display the text 'This product has no compl...
asked by 02.08.2016 / 21:15