From e644e27ac77b127c6d594d70293dd88390b1141b Mon Sep 17 00:00:00 2001 From: Egoist Date: Sun, 9 Apr 2023 20:04:56 +0300 Subject: [PATCH] Add type cast --- src/Traits/HasActive.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Traits/HasActive.php b/src/Traits/HasActive.php index 422fa52..c3fb91a 100644 --- a/src/Traits/HasActive.php +++ b/src/Traits/HasActive.php @@ -6,6 +6,15 @@ trait HasActive { + public function bootHasActive(): void + { + // append the is_active column to the fillable array + $this->fillable[] = 'is_active'; + + // add the is_active column to the casts array + $this->casts['is_active'] = 'boolean'; + } + public function scopeStatus(mixed $query, bool $status): Builder { return $query->where('is_active', $status);