|TandaTangan active() * @method static \Illuminate\Database\Eloquent\Builder|TandaTangan newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|TandaTangan newQuery() * @method static \Illuminate\Database\Eloquent\Builder|TandaTangan query() * @method static \Illuminate\Database\Eloquent\Builder|TandaTangan whereCreatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|TandaTangan whereFileTtd($value) * @method static \Illuminate\Database\Eloquent\Builder|TandaTangan whereIdTandaTangan($value) * @method static \Illuminate\Database\Eloquent\Builder|TandaTangan whereIdUser($value) * @method static \Illuminate\Database\Eloquent\Builder|TandaTangan whereIsActive($value) * @method static \Illuminate\Database\Eloquent\Builder|TandaTangan whereUpdatedAt($value) * @mixin \Eloquent */ class TandaTangan extends Model { protected $table = 'tanda_tangan'; protected $primaryKey = 'id_tanda_tangan'; public $incrementing = false; protected $keyType = 'string'; protected $fillable = ['id_user', 'file_ttd', 'is_active']; protected static function booted() { static::creating(function ($model) { if (empty($model->{$model->getKeyName()})) { $prefix = 'TTD-' . date('ym') . '-'; $model->{$model->getKeyName()} = $prefix . strtoupper(Str::random(5)); } }); } public function user() { return $this->belongsTo(User::class, 'id_user'); } public function scopeActive($query) { return $query->where('is_active', true); } }