Answers for "laravel find model inside the same model"

PHP
0

laravel find model inside the same model

class Instrument extends Model
{
  protected $appends = ['benchmark'];
  
  public function getBenchmarkAttribute()
  {
    // this is equivalent to Instrument::find($this->benchmark_id)
    return self::find($this->benchmark_id);
  }
}
Posted by: Guest on January-22-2021

Browse Popular Code Answers by Language