48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Tag;
|
|
use App\Traits\TaggableWithLocale;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class TaggableLocale extends Model
|
|
{
|
|
use HasFactory;
|
|
use TaggableWithLocale;
|
|
|
|
protected $table = 'taggable_locales';
|
|
|
|
protected static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
// updating created_by and updated_by when model is created
|
|
static::creating(function ($model) {
|
|
if (!$model->isDirty('updated_by_user')) {
|
|
$model->updated_by_user = Auth::guard('web')->user()->id;
|
|
}
|
|
});
|
|
|
|
// updating updated_by when model is updated
|
|
static::updating(function ($model) {
|
|
if (!$model->isDirty('updated_by_user')) {
|
|
$model->updated_by_user = Auth::guard('web')->user()->id;
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
protected $guarded = [];
|
|
|
|
public function tag()
|
|
{
|
|
return $this->belongsTo(Tag::class, 'taggable_tag_id', 'tag_id');
|
|
}
|
|
|
|
|
|
|
|
}
|