<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
 * @method static create(array $array)
 * @method static findOrFail(int $id)
 */
class Organization extends Model
{
    use HasFactory;

    protected $table = 'organizations';
    protected $fillable = [
        'name',
        'owner_name',
        'address',
        'phone',
        'created_by'
    ];

    public function users() {
        return $this->belongsToMany(User::class);
    }

    public function herds()
    {
        return $this->hasMany(Herd::class,'organization_id');
    }

    public function employees(): \Illuminate\Database\Eloquent\Relations\HasMany
    {
        return $this->hasMany(Employee::class,'organization_id');
    }

}
