2018-10-22 14:04:37 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use App\Models\Traits\AccountTrait;
|
2018-11-20 05:36:56 +01:00
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2018-11-02 11:54:46 +01:00
|
|
|
use Laracasts\Presenter\PresentableTrait;
|
2018-10-22 14:04:37 +02:00
|
|
|
|
2018-11-02 11:54:46 +01:00
|
|
|
class Company extends BaseModel
|
2018-10-22 14:04:37 +02:00
|
|
|
{
|
2018-11-02 11:54:46 +01:00
|
|
|
use PresentableTrait;
|
2018-11-20 05:36:56 +01:00
|
|
|
use MakesHash;
|
2018-11-02 11:54:46 +01:00
|
|
|
|
|
|
|
protected $presenter = 'App\Models\Presenters\CompanyPresenter';
|
|
|
|
|
2018-11-20 05:36:56 +01:00
|
|
|
protected $guarded = [
|
|
|
|
'id',
|
|
|
|
'company_id'
|
2018-10-22 14:04:37 +02:00
|
|
|
];
|
|
|
|
|
2018-11-20 05:36:56 +01:00
|
|
|
//protected $appends = ['company_id'];
|
2018-10-22 14:04:37 +02:00
|
|
|
|
2018-11-20 05:36:56 +01:00
|
|
|
public function getRouteKeyName()
|
|
|
|
{
|
|
|
|
return 'company_id';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCompanyIdAttribute()
|
|
|
|
{
|
|
|
|
return $this->encodePrimaryKey($this->id);
|
|
|
|
}
|
2018-10-22 14:04:37 +02:00
|
|
|
|
|
|
|
public function account()
|
|
|
|
{
|
2018-11-02 11:54:46 +01:00
|
|
|
return $this->belongsTo(Account::class);
|
2018-10-22 14:04:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function users()
|
|
|
|
{
|
|
|
|
return $this->hasMany(User::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
*/
|
|
|
|
public function clients()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Client::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
*/
|
|
|
|
public function contacts()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Contact::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
*/
|
|
|
|
public function invoices()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Invoice::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
*/
|
|
|
|
public function account_gateways()
|
|
|
|
{
|
|
|
|
return $this->hasMany(AccountGateway::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
*/
|
|
|
|
public function tax_rates()
|
|
|
|
{
|
|
|
|
return $this->hasMany(TaxRate::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
*/
|
|
|
|
public function products()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Product::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
|
|
|
public function country()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Country::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
|
|
|
public function timezone()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Timezone::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
|
|
|
public function language()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Language::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
|
|
|
public function currency()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Currency::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
|
|
|
public function industry()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Industry::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
|
|
|
public function payment_type()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(PaymentType::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function expenses()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Expense::class, 'account_id', 'id')->withTrashed();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function payments()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Payment::class, 'account_id', 'id')->withTrashed();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|