<?php

namespace Modules\Order\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Modules\Canteen\Models\Canteen;
use Modules\PaymentWay\Models\PaymentWay;
use Modules\Shipping\Models\Shipping;
use Modules\ShippingWay\Models\ShippingWay;
use Modules\User\Enums\AccountStatusEnum;
use Modules\User\Models\Address;
use Modules\User\Models\User;
use Modules\User\Models\Visitor;
use Modules\User\Services\AccountService;
use Modules\Way\Models\Way;

class Order extends Model
{
    //use soft delete
    use SoftDeletes;

    protected $fillable =
    [
        'total',
//        'total_points',
        'tax_cost',
        'total_management',
        'total_products',
        'canteen_id',
        'child_id',
    ];

    public function getDateAttribute()
    {
        $date = date('d',strtotime($this->created_at));
        $date .= ' '.__('web.monthes.'.date('m',strtotime($this->created_at)));
        $date .= ' '.date('Y',strtotime($this->created_at));
        return $date;
    }

    public function canteen()
    {
        return $this->belongsTo(Canteen::class,'canteen_id')->withTrashed();
    }

    public function child()
    {
        return $this->belongsTo(User::class,'child_id')->withTrashed();
    }

    public function products()
    {
        return $this->hasMany(OrderProduct::class);
    }

}
