[WIP] Add some classes
This commit is contained in:
@@ -3,9 +3,12 @@
|
||||
namespace App\Models\Botanic;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class Family extends Model
|
||||
{
|
||||
use HasRelationships;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'botanic_families';
|
||||
|
||||
@@ -14,6 +17,16 @@ class Family extends Model
|
||||
return $this->hasMany('App\Models\Botanic\Genre');
|
||||
}
|
||||
|
||||
public function species()
|
||||
{
|
||||
return $this->hasManyThrough('App\Models\Botanic\Specie', 'App\Models\Botanic\Genre');
|
||||
}
|
||||
|
||||
public function varieties()
|
||||
{
|
||||
return $this->hasManyDeep('App\Models\Botanic\Variety', ['App\Models\Botanic\Genre', 'App\Models\Botanic\Specie']);
|
||||
}
|
||||
|
||||
public function scopeByName($query,$name)
|
||||
{
|
||||
return $query->where('name', $name);
|
||||
|
||||
@@ -19,6 +19,11 @@ class Genre extends Model
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user