Site related updates
This commit is contained in:
@@ -23,7 +23,7 @@ trait NextKey
|
||||
$model->id = self::NextId();
|
||||
|
||||
if (! $model->site_id)
|
||||
$model->site_id = config('SITE')->site_id;
|
||||
$model->site_id = config('site')->site_id;
|
||||
});
|
||||
|
||||
static::saved(function($model)
|
||||
@@ -41,14 +41,14 @@ trait NextKey
|
||||
|
||||
$mo = new Module;
|
||||
$mo->name = $model::RECORD_ID;
|
||||
$mo->site_id = $model->site_id ?: config('SITE')->site_id;
|
||||
$mo->site_id = $model->site_id ?: config('site')->site_id;
|
||||
$mo->save();
|
||||
}
|
||||
|
||||
if (! $mo->record) {
|
||||
$mo->record = new Record;
|
||||
$mo->record->module_id = $mo->id;
|
||||
$mo->record->site_id = $model->site_id ?: config('SITE')->site_id;
|
||||
$mo->record->site_id = $model->site_id ?: config('site')->site_id;
|
||||
}
|
||||
|
||||
$mo->record->id = $model->id;
|
||||
|
@@ -39,7 +39,7 @@ trait OrderServiceOptions
|
||||
$o->forceFill(array_undot($x));
|
||||
|
||||
// @todo Make this automatic
|
||||
$o->site_id = config('SITE')->site_id;
|
||||
$o->site_id = config('site')->site_id;
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
29
app/Traits/SiteID.php
Normal file
29
app/Traits/SiteID.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Ensures we retrieve and save models with the correct site_id
|
||||
*/
|
||||
namespace App\Traits;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
use App\Models\Scopes\SiteScope;
|
||||
|
||||
trait SiteID
|
||||
{
|
||||
/**
|
||||
* This model is site scoped
|
||||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
static::addGlobalScope(new SiteScope);
|
||||
}
|
||||
|
||||
public function save(array $options = [])
|
||||
{
|
||||
if (! Arr::get($this->attributes,'site_id'))
|
||||
$this->site_id = config('site')->site_id;
|
||||
|
||||
return parent::save();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user