<?php

namespace App\Models\Botanic;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Wildside\Userstamps\Userstamps;

class Genre extends Model
{
    use SoftDeletes, Userstamps;

    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);
    }
}
