Files
unified-restaurant-original/backend/app/Models/Factura.php
2021-07-20 15:27:55 -04:00

27 lines
719 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 $hidden = ['created_at', 'updated_at', 'deleted_at', 'pivot'];
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);
}
}