I have two tables, students and parents, student table references parent id, I need when i register a parent when it come to register a student i select first the parent name of a particular student. Please anyone who can help me
I have managed to create both tables the models and its relationship
Here is my student model
namespace App;
use Illuminate\Database\Eloquent\Model;
class Student extends Model
{
protected $fillable = [
'parentt_id','admission', 'fname',
'mname','lname','dob','gender','form_admitted',
'transfered_from',
'transfered_to'
];
public function student()
{
return $this->belongsTo(Parentt::class);
}
public function fee()
{
return $this->belongsTo(Student::class);
}
}
This is by parent model
namespace App;
use Illuminate\Database\Eloquent\Model;
class Parentt extends Model
{
protected $fillable = [
'fname', 'mname','lname','occupation',
'residence','address','phone',
];
public function parentt()
{
return $this->hasMany(Student::class);
}
}
This is my view component at student component
<div class="form-group">
<select class="form-control" >
<option v-for ="parentt in parentts" :key="parentt.id">
{{parentt.fname}}
</option>
</select>
</div>