27 lines
710 B
PHP
27 lines
710 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'];
|
|
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);
|
|
}
|
|
}
|