mirror of
https://github.com/robonen/metr.git
synced 2026-03-20 02:44:42 +00:00
Offer relations controller
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filters;
|
||||
|
||||
use App\Enums\OrderTypesEnum;
|
||||
use App\Enums\RoomTypesEnum;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
@@ -13,7 +14,7 @@ class OfferFilter extends QueryFilter
|
||||
*/
|
||||
protected function type(string $type): Builder
|
||||
{
|
||||
if (RoomTypesEnum::tryFrom($type) !== null)
|
||||
if (OrderTypesEnum::tryFrom($type) !== null)
|
||||
return $this->builder->where('type', $type);
|
||||
|
||||
return $this->builder;
|
||||
@@ -23,10 +24,10 @@ class OfferFilter extends QueryFilter
|
||||
* @param int $rooms
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
protected function rooms(int $rooms): Builder
|
||||
protected function rooms(string $type): Builder
|
||||
{
|
||||
if ($rooms >= 1)
|
||||
return $this->builder->where('rooms', '>=', $rooms);
|
||||
if (RoomTypesEnum::tryFrom($type) !== null)
|
||||
return $this->builder->where('rooms', $type);
|
||||
|
||||
return $this->builder;
|
||||
}
|
||||
@@ -54,4 +55,28 @@ class OfferFilter extends QueryFilter
|
||||
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $space
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
protected function startSpace(int $space): Builder
|
||||
{
|
||||
if ($space >= 0)
|
||||
return $this->builder->where('space', '>=', $space);
|
||||
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $space
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
protected function endSpace(int $space): Builder
|
||||
{
|
||||
if ($space >= 0)
|
||||
return $this->builder->where('space', '<=', $space);
|
||||
|
||||
return $this->builder;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user