I am trying to map a relationship between the User and Order Model within Order Model.
An order has one project. The project has one team and the team has one owner/user
The relationship is four levels deep like following:
order > project > team > user
My database tables are as follows:
App\Order
id,
project_id
App\Project
id,
name,
team_id
App\Team
id
name
user_id
App\User
id
name
My Order Model:
class Order extends Model{
function customer(){
// trying to map the relationship here
}
}
I would like to access the customer like following:
$order = Order::find(1);
echo $order->customer->name;
Could you please tell me how to map the above-mentioned relationship?