From 50cb855579d0206ed799cbe268b36717bd1e5eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Thu, 13 Apr 2023 17:17:08 +0200 Subject: [PATCH] Filtering by is_custom --- app/Filters/DesignFilters.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/Filters/DesignFilters.php b/app/Filters/DesignFilters.php index d44cc2995147..8dc3291bb56a 100644 --- a/app/Filters/DesignFilters.php +++ b/app/Filters/DesignFilters.php @@ -64,4 +64,18 @@ class DesignFilters extends QueryFilters { return $this->builder->where('company_id', auth()->user()->company()->id)->orWhere('company_id', null)->orderBy('id', 'asc'); } + + /** + * Filter the designs by `is_custom` column. + * + * @return Illuminate\Database\Query\Builder + */ + public function custom(string $custom): Builder + { + if (strlen($custom) === 0) { + return $this->builder; + } + + return $this->builder->where('is_custom', filter_var($custom, FILTER_VALIDATE_BOOLEAN)); + } }