<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use App\Models\Deposit;
use App\Models\Investment;
use App\Traits\GlobalModelEvents;

class Plan extends Model
{
    use HasFactory, Notifiable, GlobalModelEvents;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name',
        'description',
        'min_fund',
        'max_fund',
        'min_roi',
        'max_roi',
        'price',
        'limit_min',
        'limit_max',
        'period',
        'image',
    ];

    public function deposit()
    {
        return $this->hasMany(Deposit::class);
    }

    public function investment()
    {
        return $this->hasMany(Investment::class);
    }

    public function withdrawal()
    {
        return $this->hasManyThrough(Withdrawal::class, Investment::class);
    }


}
