Файл: src/app/Models/Companies.php
Строк: 43
<?php
namespace AppModels;
use IlluminateDatabaseEloquentSoftDeletes;
use IlluminateDatabaseEloquentModel;
class Companies extends Model{
use SoftDeletes;
protected $table = "Companies";
protected $primaryKey = "CompanyID";
protected $fillable = ["Title","Address1","Address2","ZipCode","CountryID","ContactPerson","Email","isOwn","City","Phone"];
const CREATED_AT = "CreatedAt";
const UPDATED_AT = "UpdatedAt";
const DELETED_AT = "DeletedAt";
public function country(){
return $this->hasOne("AppModelsCountries","CountryID","CountryID");
}
public function invoices(){
return $this->hasMany("AppModelsInvoices","InvoiceID","InvoiceID");
}
public function getTotalInvoicesAttribute(){
return $this->hasMany("AppModelsInvoices","InvoiceID","InvoiceID")->count();
}
}
?>