Answers for "one-through-many"

PHP
0

one-through-many

mechanics
    id - integer
    name - string

cars
    id - integer
    model - string
    mechanic_id - integer

owners
    id - integer
    name - string
    car_id - integer
Posted by: Guest on May-06-2021
0

one-through-many

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Mechanic extends Model
{
    /**
     * Get the car's owner.
     */
    public function carOwner()
    {
        return $this->hasOneThrough(Owner::class, Car::class);
    }
}
Posted by: Guest on May-06-2021

Code answers related to "one-through-many"

Browse Popular Code Answers by Language