<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class CompanyMainPaymentMode extends Model
{
    use HasFactory, softDeletes;

    protected $guarded = ['id'];

    /**Each Payment Mode is Created by a Single User**/
    public function user(){
        return $this->belongsTo(User::class, 'created_by', 'id');
    }

    /**Each Mode has many Sub-Modes**/
    public function subModes(){
        return $this->hasMany(CompanySubModesOfPayment::class, 'mode_id', 'id')->orderBy('name');
    }
}
