add: full multi-tenancy control
This commit is contained in:
35
packages/Webkul/Attribute/src/Models/Attribute.php
Normal file
35
packages/Webkul/Attribute/src/Models/Attribute.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Webkul\Attribute\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\Attribute\Contracts\Attribute as AttributeContract;
|
||||
|
||||
class Attribute extends Model implements AttributeContract
|
||||
{
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name',
|
||||
'type',
|
||||
'entity_type',
|
||||
'lookup_type',
|
||||
'is_required',
|
||||
'is_unique',
|
||||
'quick_add',
|
||||
'validation',
|
||||
'is_user_defined',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the options.
|
||||
*/
|
||||
public function options()
|
||||
{
|
||||
return $this->hasMany(AttributeOptionProxy::modelClass());
|
||||
}
|
||||
}
|
||||
30
packages/Webkul/Attribute/src/Models/AttributeOption.php
Normal file
30
packages/Webkul/Attribute/src/Models/AttributeOption.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Webkul\Attribute\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\Attribute\Contracts\AttributeOption as AttributeOptionContract;
|
||||
|
||||
class AttributeOption extends Model implements AttributeOptionContract
|
||||
{
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'sort_order',
|
||||
'attribute_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attribute that owns the attribute option.
|
||||
*/
|
||||
public function attribute()
|
||||
{
|
||||
return $this->belongsTo(AttributeProxy::modelClass());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Webkul\Attribute\Models;
|
||||
|
||||
use Konekt\Concord\Proxies\ModelProxy;
|
||||
|
||||
class AttributeOptionProxy extends ModelProxy {}
|
||||
7
packages/Webkul/Attribute/src/Models/AttributeProxy.php
Normal file
7
packages/Webkul/Attribute/src/Models/AttributeProxy.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Webkul\Attribute\Models;
|
||||
|
||||
use Konekt\Concord\Proxies\ModelProxy;
|
||||
|
||||
class AttributeProxy extends ModelProxy {}
|
||||
85
packages/Webkul/Attribute/src/Models/AttributeValue.php
Executable file
85
packages/Webkul/Attribute/src/Models/AttributeValue.php
Executable file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Webkul\Attribute\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\Activity\Traits\LogsActivity;
|
||||
use Webkul\Attribute\Contracts\AttributeValue as AttributeValueContract;
|
||||
|
||||
class AttributeValue extends Model implements AttributeValueContract
|
||||
{
|
||||
use LogsActivity;
|
||||
|
||||
/**
|
||||
* Disable the default timestamps.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Cast the attributes to their respective types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'json_value' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that are fillable for the model.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'attribute_id',
|
||||
'text_value',
|
||||
'boolean_value',
|
||||
'integer_value',
|
||||
'float_value',
|
||||
'datetime_value',
|
||||
'date_value',
|
||||
'json_value',
|
||||
'entity_id',
|
||||
'entity_type',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that are used for logging activity.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $attributeTypeFields = [
|
||||
'text' => 'text_value',
|
||||
'textarea' => 'text_value',
|
||||
'price' => 'float_value',
|
||||
'boolean' => 'boolean_value',
|
||||
'select' => 'integer_value',
|
||||
'multiselect' => 'text_value',
|
||||
'checkbox' => 'text_value',
|
||||
'email' => 'json_value',
|
||||
'address' => 'json_value',
|
||||
'phone' => 'json_value',
|
||||
'lookup' => 'integer_value',
|
||||
'datetime' => 'datetime_value',
|
||||
'date' => 'date_value',
|
||||
'file' => 'text_value',
|
||||
'image' => 'text_value',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attribute that owns the attribute value.
|
||||
*/
|
||||
public function attribute()
|
||||
{
|
||||
return $this->belongsTo(AttributeProxy::modelClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent entity model (leads, products, persons or organizations).
|
||||
*/
|
||||
public function entity()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Webkul\Attribute\Models;
|
||||
|
||||
use Konekt\Concord\Proxies\ModelProxy;
|
||||
|
||||
class AttributeValueProxy extends ModelProxy {}
|
||||
Reference in New Issue
Block a user