Skip to content

Commit

Permalink
Add type cast
Browse files Browse the repository at this point in the history
  • Loading branch information
relliv committed Apr 9, 2023
1 parent e217f9a commit e644e27
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Traits/HasActive.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e644e27

Please sign in to comment.