I am new to Laravel. Here is my schema:
Schema::create('cluster_info', function (Blueprint $table) {
$table->increments('id');
$table->string('code')->unique();
$table->string('pa_lastname');
$table->string('pa_firstname');
$table->string('pa_middlename');
$table->string('pa_suffix');
$table->integer('branch_id');
$table->timestamps();
});
Schema::create('cluster_grouping', function (Blueprint $table) {
$table->increments('id');
$table->integer('cluster_id');
$table->integer('client_id');
$table->timestamps();
});
Schema::create('branch', function (Blueprint $table) {
$table->increments('id');
$table->string('code')->unique();
$table->string('name');
$table->string('region');
$table->timestamps();
});
I want to join cluster_info to the branch. So in my Cluster_Info Model:
public function Branches(){
return $this->hasOne('App\Branch');
}
and when I call it in my control it has null values
$cluster = new App\Cluster_Info;
dd($cluster->Branches());
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire