1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Models/Company.php
David Bomba e4f46c2a4e
Presenters, skinned views, model refactoring (#2464)
* Default database connection - set defaults for engine and strict

* Working on tests for refactored model

* Fixes for tests, use polymorphic relationships for Invitations

* skin the password reset pages
2018-10-22 23:04:37 +11:00

162 lines
3.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Traits\AccountTrait;
class Company extends Model
{
protected $fillable = [
'name',
'address1',
'address2',
'city',
'state',
'postal_code',
'country_id',
'industry_id',
'work_phone',
'work_email',
'language_id',
'vat_number',
'id_number',
'tax_name1',
'tax_rate1',
'tax_name2',
'tax_rate2',
'website',
'timezone_id',
'currency_id',
];
public function account()
{
return $this->hasOne(Account::class);
}
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();
}
}