Answers for "laravel find with relation"

PHP
0

laravel where on relationsship column

Player::whereHas('roleplay', function($q){
   $q->where('column_name', 'value');
})->get();
Posted by: Guest on December-30-2020
0

laravel relations find

/**
 * Get the user's most recent order.
 */
public function latestOrder()
{
    return $this->hasOne(Order::class)->latestOfMany();
}
Posted by: Guest on June-10-2021
0

laravel relations find

class Project extends Model
{
    public function deployments()
    {
        return $this->hasManyThrough(
            Deployment::class,
            Environment::class,
            'project_id', // Foreign key on the environments table...
            'environment_id', // Foreign key on the deployments table...
            'id', // Local key on the projects table...
            'id' // Local key on the environments table...
        );
    }
}
Posted by: Guest on June-10-2021
0

laravel relations find

/**
 * Get the user's oldest order.
 */
public function oldestOrder()
{
    return $this->hasOne(Order::class)->oldestOfMany();
}
Posted by: Guest on June-10-2021
0

laravel relations find

return $this->hasMany(Comment::class, 'foreign_key');

return $this->hasMany(Comment::class, 'foreign_key', 'local_key');
Posted by: Guest on June-10-2021
0

laravel relations find

/**
 * Get the user's largest order.
 */
public function largestOrder()
{
    return $this->hasOne(Order::class)->ofMany('price', 'max');
}
Posted by: Guest on June-10-2021

Code answers related to "laravel find with relation"

Browse Popular Code Answers by Language