<?php

namespace App\Models;

use App\Models\Concerns\BelongsToUser;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class Transfert extends Model
{
    use BelongsToUser, HasFactory, SoftDeletes;

    protected $guarded = [];

    protected $appends = ['hash_id'];

    protected $casts = [
        'date_transfert' => 'date',
        'quantite' => 'integer',
    ];

    public function magasinOrigine(): BelongsTo
    {
        return $this->belongsTo(Magasin::class, 'magasin_origine_id');
    }

    public function magasinDestination(): BelongsTo
    {
        return $this->belongsTo(Magasin::class, 'magasin_destination_id');
    }

    public function produit(): BelongsTo
    {
        return $this->belongsTo(Produit::class);
    }
}
