I have two tables:
goods: id | name
imported_goods: id | good_id | amount
imported_goods has foreign key values from table goods, And what i'm trying to do is:
Display all goods records Except the records that has foreign key values in imported_goods.
Example (CSV):
goods
1,orange
2,apple
3,bannana
4,mango
imported_goods
1,1,20 kg
2,2,40 kg
3,3,60 kg
Expected Result:
4,mango
And all other records discarded
Good Model
class Good extends Model
{
/**
* Get the Imported Goods for this Good.
*/
public function imported_goods()
{
return $this->hasMany('App\Models\Imported_good','good_id');
}
}
Imported_Good Model
class Imported_good extends Model
{
/**
* Get the Good info for this Imported Good.
*/
public function good()
{
return $this->belongsTo('App\Models\Good','good_id');
}
}