Convert DB to Eloquent

I need some help to convert this Database Query into Eloquent format. $productos = DB::table('productos') ->join('subcategorias', 'produc...
01

Use Foreign key Name in email view

Please can some guide me on how to get a foreign key name not id when laravel mail class send a mail to user with email blade view. I have two form...
01

Eloquent casting int as string

Hi folks! So, I'm experiencing the following situation with two models: <?php namespace App\Models; use Illuminate\Datab...
01

[5.4] Setting a default variable value on a relation

Hello everyone, I've troubles with a required, default values on a relationship: Model User class User extends Model {...
00

Local Scopes Functioning Apparently Intermittently

In my Model-derived class, I have added two query scopes: public function scopeForSearch($query) { $query->leftJoin('clients'...
01

How to modify relation when converting to json?

I have a Parent that hasMany children: class Parent extends Model { public function children() { return $this->ha...
01

Eloquent casts array returns null instead of empty array

Hello, I have a model called Archive with casts protected $casts = [ 'params' => 'array' ];...
05

Add element to pivot table with different FK

Hey, I have two models (modelA, modelB), which are related through a many-to-many relationship (belongsToMany on both sides). My problem is that my...
02

Getting Model's morph class without an instance

When using a custom morphMap, you can get the morph class for a model using the getMorphClass() instance method. The inverse operation...
00

Retrieving a related model's details

Hey So my code works but I want to know if there is a neater way of doing this. Essentially I have two models: Issue...
03

Getting conflict with column name and model function name

In Laravel 5.4 , I am stuck in below problem //Request Table {id,source-id} // Request model public function sourceReq() { return $th...
01

Laravel and Complex Ranks/Permissions Tables

So... I'm trying to set up an ACL and rank management system in laravel, however, I'm having trouble getting my head around how I should assemble t...
02

Edit item

Hello, how can I edit item from database? I need edit and update methods , right? edit is similar like show, and update like store?? What should my...
02

Eloquent connections staying open and having “Too many connections” on Aurora

I've been trying to solve a problem for a few days and run out of ideas. I'm hoping somebody understands something about Eloquent I'm missing or ca...
03

Where In Array

I have some columns that contain an array of ids (as defined in the model) based on a remote database I only have access to via an API. Example, m...
09

Access query "wheres"

Title is vague, exuse me for that. Is there a way to get the current id you're looping through? As you can see in the example below, I need...
00

how to store jpg file into sql server?

Hi: my code is like below, the target column in sql server is of type "Image". And all pictures stored in sql server are just blac...
04

How to best use a pivot as a model?

Hi everyone! I have a pivot table which is also a resource of its own. As such, it has to be exposed in our API for instance. Currently it e...
04

How can I access the key from inside the model class?

Inside my model class, I need the key to perform a request. $this->id and $this->getKey() both return null. Any idea? Goal is to condition th...
00

Eloquent: Get relations' id (belongsToMany)

I'm trying to get an array of the associated role ids to a user. return $this->belongsToMany('App\Role')->select(['roles.id'])...
08