Merge branch 'master' of github.com:akaunting/akaunting
# Conflicts: # resources/views/banking/reconciliations/create.blade.php
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use App\Traits\Tenants;
|
||||
use Laratrust\Models\LaratrustPermission;
|
||||
use Laratrust\Traits\LaratrustPermissionTrait;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
@ -9,10 +10,12 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
|
||||
|
||||
class Permission extends LaratrustPermission
|
||||
{
|
||||
use LaratrustPermissionTrait, SearchString, Sortable;
|
||||
use LaratrustPermissionTrait, SearchString, Sortable, Tenants;
|
||||
|
||||
protected $table = 'permissions';
|
||||
|
||||
protected $tenantable = false;
|
||||
|
||||
/**
|
||||
* The accessors to append to the model's array form.
|
||||
*
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use App\Traits\Tenants;
|
||||
use Laratrust\Models\LaratrustRole;
|
||||
use Laratrust\Traits\LaratrustRoleTrait;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
@ -9,10 +10,12 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
|
||||
|
||||
class Role extends LaratrustRole
|
||||
{
|
||||
use LaratrustRoleTrait, SearchString, Sortable;
|
||||
use LaratrustRoleTrait, SearchString, Sortable, Tenants;
|
||||
|
||||
protected $table = 'roles';
|
||||
|
||||
protected $tenantable = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use App\Traits\Tenants;
|
||||
use App\Notifications\Auth\Reset;
|
||||
use App\Traits\Media;
|
||||
use Date;
|
||||
@ -15,10 +16,12 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use LaratrustUserTrait, Notifiable, SearchString, SoftDeletes, Sortable, Media;
|
||||
use LaratrustUserTrait, Notifiable, SearchString, SoftDeletes, Sortable, Media, Tenants;
|
||||
|
||||
protected $table = 'users';
|
||||
|
||||
protected $tenantable = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Models\Common;
|
||||
|
||||
use App\Traits\Media;
|
||||
use App\Traits\Tenants;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
@ -10,10 +11,12 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
|
||||
|
||||
class Company extends Eloquent
|
||||
{
|
||||
use Media, SearchString, SoftDeletes, Sortable;
|
||||
use Media, SearchString, SoftDeletes, Sortable, Tenants;
|
||||
|
||||
protected $table = 'companies';
|
||||
|
||||
protected $tenantable = false;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected $fillable = ['domain', 'enabled'];
|
||||
|
@ -133,9 +133,9 @@ class Contact extends Model
|
||||
{
|
||||
$amount = 0;
|
||||
|
||||
$collection = in_array($this->type, $this->getCustomerTypes()) ? 'invoices' : 'bills';
|
||||
$collection = $this->isCustomer() ? 'invoices' : 'bills';
|
||||
|
||||
$this->$collection()->accrued()->notPaid()->each(function ($item) use (&$amount) {
|
||||
$this->$collection->whereNotIn('status', ['draft', 'cancelled', 'paid'])->each(function ($item) use (&$amount) {
|
||||
$unpaid = $item->amount - $item->paid;
|
||||
|
||||
$amount += $this->convertToDefault($unpaid, $item->currency_code, $item->currency_rate);
|
||||
|
@ -9,5 +9,7 @@ class Media extends BaseMedia
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $tenantable = false;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
}
|
||||
|
@ -68,6 +68,50 @@ class Category extends Model
|
||||
return $query->whereIn($this->table . '.type', (array) $types);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to include only income.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeIncome($query)
|
||||
{
|
||||
return $query->where($this->table . '.type', '=', 'income');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to include only expense.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeExpense($query)
|
||||
{
|
||||
return $query->where($this->table . '.type', '=', 'expense');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to include only item.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeItem($query)
|
||||
{
|
||||
return $query->where($this->table . '.type', '=', 'item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to include only other.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeOther($query)
|
||||
{
|
||||
return $query->where($this->table . '.type', '=', 'other');
|
||||
}
|
||||
|
||||
public function scopeName($query, $name)
|
||||
{
|
||||
return $query->where('name', '=', $name);
|
||||
@ -81,6 +125,6 @@ class Category extends Model
|
||||
*/
|
||||
public function scopeTransfer($query)
|
||||
{
|
||||
return $query->where('type', 'other')->pluck('id')->first();
|
||||
return $query->where($this->table . '.type', '=', 'other')->pluck('id')->first();
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,17 @@
|
||||
namespace App\Models\Setting;
|
||||
|
||||
use App\Scopes\Company;
|
||||
use App\Traits\Tenants;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
|
||||
class Setting extends Eloquent
|
||||
{
|
||||
use Tenants;
|
||||
|
||||
protected $table = 'settings';
|
||||
|
||||
protected $tenantable = true;
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user