// your relationship
public function books() {
return $this->hasMany('App\Models\Book');
}
// Get the first inserted child model
public function first_book() {
return $this->hasOne('App\Models\Book')->oldestOfMany();
}
// Get the last inserted child model
public function last_book() {
return $this->hasOne('App\Models\Book')->latestOfMany();
}