pdv.backend/app/Models/Supplier.php

32 lines
720 B
PHP

<?php namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Descripción
*/
class Supplier extends Model
{
protected $fillable = [
'business_name',
'rfc',
'email',
'phone',
'address',
'postal_code',
'notes'
];
public function inventoryMovements()
{
return $this->hasMany(InventoryMovement::class)->where('movement_type', 'entry');
}
public function suppliedProducts()
{
return $this->hasManyThrough(Inventory::class, InventoryMovement::class, 'supplier_id', 'id', 'id', 'product_id')
->where('inventory_movements.movement_type', 'entry')
->distinct();
}
}