added source feature
This commit is contained in:
@ -20,7 +20,7 @@ class Role extends LaratrustRole
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name', 'display_name', 'description'];
|
||||
protected $fillable = ['name', 'display_name', 'description', 'created_from', 'created_by'];
|
||||
|
||||
/**
|
||||
* Scope to get all rows filtered, sorted and paginated.
|
||||
|
@ -5,6 +5,8 @@ namespace App\Models\Auth;
|
||||
use App\Traits\Tenants;
|
||||
use App\Notifications\Auth\Reset;
|
||||
use App\Traits\Media;
|
||||
use App\Traits\Owners;
|
||||
use App\Traits\Sources;
|
||||
use App\Traits\Users;
|
||||
use App\Utilities\Date;
|
||||
use Illuminate\Contracts\Translation\HasLocalePreference;
|
||||
@ -18,7 +20,7 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
|
||||
|
||||
class User extends Authenticatable implements HasLocalePreference
|
||||
{
|
||||
use HasFactory, LaratrustUserTrait, Notifiable, SearchString, SoftDeletes, Sortable, Media, Tenants, Users;
|
||||
use HasFactory, LaratrustUserTrait, Media, Notifiable, Owners, SearchString, SoftDeletes, Sortable, Sources, Tenants, Users;
|
||||
|
||||
protected $table = 'users';
|
||||
|
||||
@ -27,7 +29,7 @@ class User extends Authenticatable implements HasLocalePreference
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name', 'email', 'password', 'locale', 'enabled', 'landing_page'];
|
||||
protected $fillable = ['name', 'email', 'password', 'locale', 'enabled', 'landing_page', 'created_from', 'created_by'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
@ -258,6 +260,30 @@ class User extends Authenticatable implements HasLocalePreference
|
||||
return (bool) $this->can('read-admin-panel');
|
||||
}
|
||||
|
||||
public function scopeSource($query, $source)
|
||||
{
|
||||
return $query->where($this->table . '.created_from', $source);
|
||||
}
|
||||
|
||||
public function scopeIsOwner($query)
|
||||
{
|
||||
return $query->where($this->table . '.created_by', user_id());
|
||||
}
|
||||
|
||||
public function scopeIsNotOwner($query)
|
||||
{
|
||||
return $query->where($this->table . '.created_by', '<>', user_id());
|
||||
}
|
||||
|
||||
public function ownerKey($owner)
|
||||
{
|
||||
if ($this->isNotOwnable()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $this->created_by;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user's preferred locale.
|
||||
*
|
||||
|
@ -25,7 +25,7 @@ class Account extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'name', 'number', 'currency_code', 'opening_balance', 'bank_name', 'bank_phone', 'bank_address', 'enabled', 'created_by'];
|
||||
protected $fillable = ['company_id', 'name', 'number', 'currency_code', 'opening_balance', 'bank_name', 'bank_phone', 'bank_address', 'enabled', 'created_from', 'created_by'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
|
@ -18,7 +18,7 @@ class Reconciliation extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'account_id', 'started_at', 'ended_at', 'closing_balance', 'reconciled', 'created_by'];
|
||||
protected $fillable = ['company_id', 'account_id', 'started_at', 'ended_at', 'closing_balance', 'reconciled', 'created_from', 'created_by'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
|
@ -43,6 +43,7 @@ class Transaction extends Model
|
||||
'payment_method',
|
||||
'reference',
|
||||
'parent_id',
|
||||
'created_from',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
|
@ -36,7 +36,7 @@ class Transfer extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'expense_transaction_id', 'income_transaction_id', 'created_by'];
|
||||
protected $fillable = ['company_id', 'expense_transaction_id', 'income_transaction_id', 'created_from', 'created_by'];
|
||||
|
||||
/**
|
||||
* Sortable columns.
|
||||
|
@ -10,6 +10,7 @@ use App\Models\Document\Document;
|
||||
use App\Traits\Contacts;
|
||||
use App\Traits\Media;
|
||||
use App\Traits\Owners;
|
||||
use App\Traits\Sources;
|
||||
use App\Traits\Tenants;
|
||||
use App\Traits\Transactions;
|
||||
use App\Utilities\Overrider;
|
||||
@ -21,7 +22,7 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
|
||||
|
||||
class Company extends Eloquent implements Ownable
|
||||
{
|
||||
use Contacts, Media, Owners, SearchString, SoftDeletes, Sortable, Tenants, Transactions;
|
||||
use Contacts, Media, Owners, SearchString, SoftDeletes, Sortable, Sources, Tenants, Transactions;
|
||||
|
||||
protected $table = 'companies';
|
||||
|
||||
@ -34,7 +35,7 @@ class Company extends Eloquent implements Ownable
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected $fillable = ['domain', 'enabled', 'created_by'];
|
||||
protected $fillable = ['domain', 'enabled', 'created_from', 'created_by'];
|
||||
|
||||
protected $casts = [
|
||||
'enabled' => 'boolean',
|
||||
@ -554,14 +555,19 @@ class Company extends Eloquent implements Ownable
|
||||
return static::getCurrent() !== null;
|
||||
}
|
||||
|
||||
public function scopeSource($query, $source)
|
||||
{
|
||||
return $query->where($this->table . '.created_from', $source);
|
||||
}
|
||||
|
||||
public function scopeIsOwner($query)
|
||||
{
|
||||
return $query->where('created_by', user_id());
|
||||
return $query->where($this->table . '.created_by', user_id());
|
||||
}
|
||||
|
||||
public function scopeIsNotOwner($query)
|
||||
{
|
||||
return $query->where('created_by', '<>', user_id());
|
||||
return $query->where($this->table . '.created_by', '<>', user_id());
|
||||
}
|
||||
|
||||
public function ownerKey($owner)
|
||||
|
@ -48,6 +48,7 @@ class Contact extends Model
|
||||
'currency_code',
|
||||
'reference',
|
||||
'enabled',
|
||||
'created_from',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
|
@ -18,7 +18,7 @@ class Dashboard extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'name', 'enabled', 'created_by'];
|
||||
protected $fillable = ['company_id', 'name', 'enabled', 'created_from', 'created_by'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
|
@ -13,7 +13,7 @@ class EmailTemplate extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'alias', 'class', 'name', 'subject', 'body', 'params'];
|
||||
protected $fillable = ['company_id', 'alias', 'class', 'name', 'subject', 'body', 'params', 'created_from', 'created_by'];
|
||||
|
||||
/**
|
||||
* Scope to only include contacts of a given type.
|
||||
|
@ -27,7 +27,7 @@ class Item extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'name', 'description', 'sale_price', 'purchase_price', 'category_id', 'enabled', 'created_by'];
|
||||
protected $fillable = ['company_id', 'name', 'description', 'sale_price', 'purchase_price', 'category_id', 'enabled', 'created_from', 'created_by'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
|
@ -16,7 +16,7 @@ class ItemTax extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'item_id', 'tax_id'];
|
||||
protected $fillable = ['company_id', 'item_id', 'tax_id', 'created_from', 'created_by'];
|
||||
|
||||
public function item()
|
||||
{
|
||||
|
@ -2,15 +2,17 @@
|
||||
|
||||
namespace App\Models\Common;
|
||||
|
||||
use App\Traits\Owners;
|
||||
use App\Traits\Sources;
|
||||
use App\Traits\Tenants;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Plank\Mediable\Media as BaseMedia;
|
||||
|
||||
class Media extends BaseMedia
|
||||
{
|
||||
use SoftDeletes, Tenants;
|
||||
use Owners, SoftDeletes, Sources, Tenants;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected $fillable = ['company_id'];
|
||||
protected $fillable = ['company_id', 'created_from', 'created_by'];
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class Recurring extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'recurable_id', 'recurable_type', 'frequency', 'interval', 'started_at', 'count'];
|
||||
protected $fillable = ['company_id', 'recurable_id', 'recurable_type', 'frequency', 'interval', 'started_at', 'count', 'created_from', 'created_by'];
|
||||
|
||||
/**
|
||||
* Get all of the owning recurable models.
|
||||
|
@ -17,7 +17,7 @@ class Report extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'class', 'name', 'description', 'settings', 'created_by'];
|
||||
protected $fillable = ['company_id', 'class', 'name', 'description', 'settings', 'created_from', 'created_by'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
|
@ -17,7 +17,7 @@ class Widget extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'dashboard_id', 'class', 'name', 'sort', 'settings', 'created_by'];
|
||||
protected $fillable = ['company_id', 'dashboard_id', 'class', 'name', 'sort', 'settings', 'created_from', 'created_by'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
|
@ -51,6 +51,7 @@ class Document extends Model
|
||||
'notes',
|
||||
'footer',
|
||||
'parent_id',
|
||||
'created_from',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
|
@ -13,7 +13,7 @@ class DocumentHistory extends Model
|
||||
|
||||
protected $table = 'document_histories';
|
||||
|
||||
protected $fillable = ['company_id', 'type', 'document_id', 'status', 'notify', 'description'];
|
||||
protected $fillable = ['company_id', 'type', 'document_id', 'status', 'notify', 'description', 'created_from', 'created_by'];
|
||||
|
||||
public function document()
|
||||
{
|
||||
|
@ -30,6 +30,8 @@ class DocumentItem extends Model
|
||||
'tax',
|
||||
'discount_rate',
|
||||
'discount_type',
|
||||
'created_from',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,7 @@ class DocumentItemTax extends Model
|
||||
|
||||
protected $table = 'document_item_taxes';
|
||||
|
||||
protected $fillable = ['company_id', 'type', 'document_id', 'document_item_id', 'tax_id', 'name', 'amount'];
|
||||
protected $fillable = ['company_id', 'type', 'document_id', 'document_item_id', 'tax_id', 'name', 'amount', 'created_from', 'created_by'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
|
@ -13,7 +13,7 @@ class Module extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'alias', 'enabled'];
|
||||
protected $fillable = ['company_id', 'alias', 'enabled', 'created_from', 'created_by'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
|
@ -13,5 +13,5 @@ class ModuleHistory extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'module_id', 'version', 'description'];
|
||||
protected $fillable = ['company_id', 'module_id', 'version', 'description', 'created_from', 'created_by'];
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class Category extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'name', 'type', 'color', 'enabled', 'created_by'];
|
||||
protected $fillable = ['company_id', 'name', 'type', 'color', 'enabled', 'created_from', 'created_by',];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
|
@ -30,6 +30,7 @@ class Currency extends Model
|
||||
'symbol_first',
|
||||
'decimal_mark',
|
||||
'thousands_separator',
|
||||
'created_from',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
|
@ -24,7 +24,7 @@ class Tax extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'name', 'rate', 'type', 'enabled', 'created_by'];
|
||||
protected $fillable = ['company_id', 'name', 'rate', 'type', 'enabled', 'created_from', 'created_by'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
|
Reference in New Issue
Block a user