Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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);
  }
}
 
PREVIOUS NEXT
Tagged: #laravel #find #model #model
ADD COMMENT
Topic
Name
7+5 =