add: full multi-tenancy control

This commit is contained in:
Cauê Faleiros
2026-02-02 15:31:15 -03:00
commit c6ec92802b
1711 changed files with 258106 additions and 0 deletions

View 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());
}
}

View 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());
}
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Webkul\Attribute\Models;
use Konekt\Concord\Proxies\ModelProxy;
class AttributeOptionProxy extends ModelProxy {}

View File

@@ -0,0 +1,7 @@
<?php
namespace Webkul\Attribute\Models;
use Konekt\Concord\Proxies\ModelProxy;
class AttributeProxy extends ModelProxy {}

View 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();
}
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Webkul\Attribute\Models;
use Konekt\Concord\Proxies\ModelProxy;
class AttributeValueProxy extends ModelProxy {}