migrate to gtea from bistbucket
This commit is contained in:
79
public/restaurant/app/Entity/Dropdown.php
Normal file
79
public/restaurant/app/Entity/Dropdown.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Interfaces\DropdownInterface;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Dropdown implements DropdownInterface
|
||||
{
|
||||
protected string $tableName;
|
||||
|
||||
protected string $primaryColumn;
|
||||
|
||||
protected array $selectedColumns = [];
|
||||
|
||||
protected array $orderByColumnWithOrders = [];
|
||||
|
||||
private Builder $query;
|
||||
|
||||
public function setTableName(string $tableName): self
|
||||
{
|
||||
$this->tableName = $tableName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPrimaryColumn(string $primaryColumn): self
|
||||
{
|
||||
$this->primaryColumn = $primaryColumn;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSelectedColumns(array $selectedColumns): self
|
||||
{
|
||||
$this->selectedColumns = $selectedColumns;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setOrderByColumnWithOrders(array $orderByColumnWithOrders): self
|
||||
{
|
||||
$this->orderByColumnWithOrders = $orderByColumnWithOrders;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getQuery(): Builder
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
public function setQuery(Builder $query): self
|
||||
{
|
||||
$this->query = $query;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSelectableTableQuery(): self
|
||||
{
|
||||
$this->query = DB::table($this->tableName)
|
||||
->select($this->selectedColumns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDropdowns(): array
|
||||
{
|
||||
if (count($this->orderByColumnWithOrders)) {
|
||||
foreach ($this->orderByColumnWithOrders as $column => $columnOrder) {
|
||||
$this->query->orderBy($column, $columnOrder);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->query->get()->toArray();
|
||||
}
|
||||
}
|
||||
10
public/restaurant/app/Entity/FilePath.php
Normal file
10
public/restaurant/app/Entity/FilePath.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
class FilePath
|
||||
{
|
||||
public const PATH_USER_FILES = 'public/users/';
|
||||
|
||||
public const PATH_USER_AVATAR = self::PATH_USER_FILES.'avatars/';
|
||||
}
|
||||
Reference in New Issue
Block a user