Ok... say I have 3 tables.
client
vendor
vendor_details
The vendor is specific vendor data... and the vendor_details contains vendor data specific for the client.
Vendor Model:
<?php namespace App\Vendors;
use Illuminate\Database\Eloquent\Model;
class Vendor extends Model
{
protected $table = 'vendor';
public function details()
{
return $this->hasMany('App\Vendors\VendorDetails', 'vendor_id', 'id');
}
}
Vendor Details Model:
<?php namespace App\Vendors;
use Illuminate\Database\Eloquent\Model;
class VendorDetails extends Model
{
protected $table = 'vendor_details';
public function __construct()
{
}
public function vendor()
{
return $this->belongsTo('App\Vendors\Vendor', 'vendor_id', 'id');
}
public function client()
{
return $this->belongsTo('App\Clients\Clients', 'client_id', 'id');
}
}
My question is, is how do I get specific data from the vendor detail, that is for the client 1 (say that is set in a session variable)?
client
[
id=1
name=Foo
]
client
[
id=2
name=Bar
]
vendor
[
id = 1
name = Ven1
]
vendor_details
[
id=1
vendor_id=1
client_id=1
vendor_code=11111
]
vendor_details
[
id=2
vendor_id=1
client_id=2
vendor_code=22222
]
Sorry, I hope my question makes sense...