add: full multi-tenancy control
This commit is contained in:
63
packages/Webkul/DataTransfer/src/Models/Import.php
Executable file
63
packages/Webkul/DataTransfer/src/Models/Import.php
Executable file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Webkul\DataTransfer\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Webkul\DataTransfer\Contracts\Import as ImportContract;
|
||||
|
||||
class Import extends Model implements ImportContract
|
||||
{
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'state',
|
||||
'process_in_queue',
|
||||
'type',
|
||||
'action',
|
||||
'validation_strategy',
|
||||
'validation_strategy',
|
||||
'allowed_errors',
|
||||
'processed_rows_count',
|
||||
'invalid_rows_count',
|
||||
'errors_count',
|
||||
'errors',
|
||||
'field_separator',
|
||||
'file_path',
|
||||
'error_file_path',
|
||||
'summary',
|
||||
'started_at',
|
||||
'completed_at',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'summary' => 'array',
|
||||
'errors' => 'array',
|
||||
'started_at' => 'datetime',
|
||||
'completed_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the options.
|
||||
*/
|
||||
public function batches(): HasMany
|
||||
{
|
||||
return $this->hasMany(ImportBatchProxy::modelClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file name.
|
||||
*/
|
||||
public function getFileNameAttribute(): string
|
||||
{
|
||||
return preg_replace('/^.*?\/\d+-/', '', $this->file_path);
|
||||
}
|
||||
}
|
||||
48
packages/Webkul/DataTransfer/src/Models/ImportBatch.php
Executable file
48
packages/Webkul/DataTransfer/src/Models/ImportBatch.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Webkul\DataTransfer\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\DataTransfer\Contracts\ImportBatch as ImportBatchContract;
|
||||
|
||||
class ImportBatch extends Model implements ImportBatchContract
|
||||
{
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'state',
|
||||
'data',
|
||||
'summary',
|
||||
'import_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'summary' => 'array',
|
||||
'data' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the import that owns the import batch.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function import()
|
||||
{
|
||||
return $this->belongsTo(ImportProxy::modelClass());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Webkul\DataTransfer\Models;
|
||||
|
||||
use Konekt\Concord\Proxies\ModelProxy;
|
||||
|
||||
class ImportBatchProxy extends ModelProxy {}
|
||||
7
packages/Webkul/DataTransfer/src/Models/ImportProxy.php
Normal file
7
packages/Webkul/DataTransfer/src/Models/ImportProxy.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Webkul\DataTransfer\Models;
|
||||
|
||||
use Konekt\Concord\Proxies\ModelProxy;
|
||||
|
||||
class ImportProxy extends ModelProxy {}
|
||||
Reference in New Issue
Block a user