how can i join those two tables in laravel elequent and make them as one table ?
Table 1(base info ) :
id baseId Site_ID region city address
1 123 321 west wakanda street2
Table 2(basecounts) :
base_id First Second third
1 54 52 51
i have those two models idk if they are correct or not :
class base extends Model
{
public function Counts() {
return $this->hasOne(CountInBase::class, 'base_id');
}
}
class CountInBase extends Model
{
public function bases() {
return $this->belongsTo(base::class ,'base_id','id');
}
}
in controller i am trying to make this query but i am not getting the expacted result , i am just getting the results of the first table :
$data = base::where('region' ,'=' ,'west')->with(['Counts'])->get();
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire