Initial commit
This commit is contained in:
47
app/Models/TaggableLocale.php
Normal file
47
app/Models/TaggableLocale.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user