Files
opensem/app/Models/Botanic/Genre.php
Ludovic CANDELLIER 516ec2232e [WIP] Add some classes
2020-04-25 01:06:04 +02:00

32 lines
627 B
PHP

<?php
namespace App\Models\Botanic;
use Illuminate\Database\Eloquent\Model;
class Genre extends Model
{
protected $guarded = ['id'];
protected $table = 'botanic_genres';
public function family()
{
return $this->belongsTo('App\Models\Botanic\Family');
}
public function species()
{
return $this->hasMany('App\Models\Botanic\Specie');
}
public function varieties()
{
return $this->hasManyThrough('App\Models\Botanic\Variety', 'App\Models\Botanic\Specie');
}
public function scopeByName($query,$name)
{
return $query->where('name', $name);
}
}