laravel find model inside the same model

Solutions on MaxInterview for laravel find model inside the same model by the best coders in the world

showing results for - "laravel find model inside the same model"
Youssef
22 Oct 2020
1class Instrument extends Model
2{
3  protected $appends = ['benchmark'];
4  
5  public function getBenchmarkAttribute()
6  {
7    // this is equivalent to Instrument::find($this->benchmark_id)
8    return self::find($this->benchmark_id);
9  }
10}