Files
unified-restaurant-original/backend/app/Models/Factura.php
2021-07-14 03:58:17 -04:00

26 lines
642 B
PHP

<?php
namespace App\Models;
use App\Traits\UuidPrimaryKey;
use App\Exceptions\ModelNotFoundException;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Factura extends Model {
use UuidPrimaryKey, SoftDeletes;
protected $table = 'facturas';
protected $fillable = ['id', 'numero', 'monto_bruto', 'compra_id'];
public static function findOrFail($id) {
$factura = Factura::find($id);
if(!$factura) throw new ModelNotFoundException("factura", $id);
return $factura;
}
public function compra() {
return $this->belongsTo(Compra::class);
}
}