Its Laravel 5.3
Stuck in objects relationships I've some DB models like following
Here Customers can have multiple devices and devices can have multiple events
I want to get all events by customer, following code are my models having relationships defined..
When I try to get events like DeviceEvents::with(['customer'])->get(); it returns nothing but exception.. please help me to solve this ORM..
customer (Model: Customer)
========
id | name
function devices = $this->hasMany('App\CustomerDevices');
--------------------------------------------------------------------------------
devices (Model: Devices)
========
id | name
function events = $this->hasMany('App\DeviceEvents');
--------------------------------------------------------------------------------
customer_devices (Model: CustomerDevices)
================
id | customer_id | device_id
function customer = $this->belongsTo('App\Customer');
function device = $this->belongsTo('App\Device');
function events = $this->hasMany('App\DeviceEvents');
--------------------------------------------------------------------------------
event_logs (Model: DeviceEvents)
==========
id | device_id
function device = $this->belongsTo('Securmate\Devices');
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2kbgR5Y
via IFTTT
Aucun commentaire:
Enregistrer un commentaire