added source feature
This commit is contained in:
@ -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.
|
||||
|
Reference in New Issue
Block a user