Formatting fixes and cleanup.
This commit is contained in:
parent
a1e14a3e60
commit
51fb71e469
41 changed files with 394 additions and 392 deletions
|
|
@ -34,7 +34,7 @@ class CardExport extends Command
|
|||
public function handle()
|
||||
{
|
||||
$data = collect();
|
||||
foreach(Card::with(['character', 'raid'])->get() as $card) {
|
||||
foreach (Card::with(['character', 'raid'])->get() as $card) {
|
||||
|
||||
$row = collect([
|
||||
'message' => $card->body,
|
||||
|
|
|
|||
|
|
@ -39,12 +39,12 @@ class CardImport extends Command
|
|||
|
||||
try {
|
||||
$json = json_decode($data, false, 8, JSON_THROW_ON_ERROR);
|
||||
} catch(\JsonException $ex) {
|
||||
} catch (\JsonException $ex) {
|
||||
$this->error("Json: " . $ex->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($json as $item) {
|
||||
foreach ($json as $item) {
|
||||
|
||||
$data = [
|
||||
'body' => $item->message,
|
||||
|
|
|
|||
|
|
@ -34,4 +34,4 @@ class InstallLogo extends Command
|
|||
|
||||
Storage::disk('resources')->copy('logos/' . $filename, 'images/logo.png');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class Kernel extends ConsoleKernel
|
|||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// Prune old game settings.
|
||||
$schedule->command('model:prune', [ '--model' => [ \App\Models\Setting::class ] ])
|
||||
$schedule->command('model:prune', ['--model' => [\App\Models\Setting::class]])
|
||||
->description("Prune expired settings")
|
||||
->twiceDaily(2, 8);
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ class Kernel extends ConsoleKernel
|
|||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
$this->load(__DIR__ . '/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class GameBoard
|
|||
/**
|
||||
* Return the state
|
||||
*/
|
||||
public function getState() : GameBoardState
|
||||
public function getState(): GameBoardState
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ class GameBoard
|
|||
/**
|
||||
* Get the size of the board.
|
||||
*/
|
||||
public function getSize() : int
|
||||
public function getSize(): int
|
||||
{
|
||||
return $this->state->getSize();
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ class GameBoard
|
|||
/**
|
||||
* Clear the game board.
|
||||
*/
|
||||
public function clear() : void
|
||||
public function clear(): void
|
||||
{
|
||||
$this->state->clear();
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ class GameBoard
|
|||
* Check if the board is in an ended state.
|
||||
* E.g: all cards is in a winning state.
|
||||
*/
|
||||
public function hasGameEnded() : bool
|
||||
public function hasGameEnded(): bool
|
||||
{
|
||||
return $this->state->isFull(GameBoardState::STATE_WIN);
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ class GameBoard
|
|||
*
|
||||
* @throw NotEnoughCardsException
|
||||
*/
|
||||
public function regenerate(GameSettings $settings) : self
|
||||
public function regenerate(GameSettings $settings): self
|
||||
{
|
||||
$num_cards = $this->getSize();
|
||||
$cards = Card::getBySettings($settings, $num_cards);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class GameBoardState
|
|||
/**
|
||||
* Set the state of a cell.
|
||||
*/
|
||||
public function set(int $pos, bool $pressed = true) : self
|
||||
public function set(int $pos, bool $pressed = true): self
|
||||
{
|
||||
if ($this->hasGameEnded()) {
|
||||
return $this;
|
||||
|
|
@ -62,7 +62,7 @@ class GameBoardState
|
|||
/**
|
||||
* Toggle pressed state of a cell.
|
||||
*/
|
||||
public function toggle(int $pos) : self
|
||||
public function toggle(int $pos): self
|
||||
{
|
||||
return $this->set($pos, !$this->isPressed($pos));
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ class GameBoardState
|
|||
/**
|
||||
* Check if a cell is pressed or not.
|
||||
*/
|
||||
public function isPressed(int $pos) : bool
|
||||
public function isPressed(int $pos): bool
|
||||
{
|
||||
return isset($this->state[$pos]);
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ class GameBoardState
|
|||
/**
|
||||
* Check if a cell is part of a winning row/column.
|
||||
*/
|
||||
public function isWin(int $pos) : bool
|
||||
public function isWin(int $pos): bool
|
||||
{
|
||||
return isset($this->state[$pos]) && $this->state[$pos] == self::STATE_WIN;
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ class GameBoardState
|
|||
/**
|
||||
* Get the sate of the cells.
|
||||
*/
|
||||
public function getState() : array
|
||||
public function getState(): array
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ class GameBoardState
|
|||
/**
|
||||
* Get the size of the board.
|
||||
*/
|
||||
public function getSize() : int
|
||||
public function getSize(): int
|
||||
{
|
||||
return $this->width * $this->height;
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ class GameBoardState
|
|||
/**
|
||||
* Clear the board.
|
||||
*/
|
||||
public function clear() : self
|
||||
public function clear(): self
|
||||
{
|
||||
$this->state = [];
|
||||
$this->winning = 0;
|
||||
|
|
@ -110,7 +110,7 @@ class GameBoardState
|
|||
}
|
||||
|
||||
// TODO: Rename
|
||||
public function getNumWinRows() : int
|
||||
public function getNumWinRows(): int
|
||||
{
|
||||
return $this->winning;
|
||||
}
|
||||
|
|
@ -118,13 +118,13 @@ class GameBoardState
|
|||
/**
|
||||
* Check if the board only has winning cards
|
||||
*/
|
||||
public function hasGameEnded() : bool
|
||||
public function hasGameEnded(): bool
|
||||
{
|
||||
if (count($this->state) < $this->width * $this->height) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach($this->state as $pos) {
|
||||
foreach ($this->state as $pos) {
|
||||
if ($pos !== self::STATE_WIN) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -135,14 +135,14 @@ class GameBoardState
|
|||
/**
|
||||
* Check if the board is full and all positions is in a given state.
|
||||
*/
|
||||
public function isFull($state) : bool
|
||||
public function isFull($state): bool
|
||||
{
|
||||
// Board not filled, impossible to have all positions set.
|
||||
if (count($this->state) < $this->width * $this->height) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach($this->state as $pos) {
|
||||
foreach ($this->state as $pos) {
|
||||
if ($pos !== $state) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -153,15 +153,15 @@ class GameBoardState
|
|||
/**
|
||||
*
|
||||
*/
|
||||
protected function update() : void
|
||||
protected function update(): void
|
||||
{
|
||||
foreach($this->state as $pos => $_) {
|
||||
foreach ($this->state as $pos => $_) {
|
||||
$this->state[$pos] = self::STATE_PRESSED;
|
||||
}
|
||||
|
||||
$patterns = $this->checkWinningState();
|
||||
foreach($patterns as $cards) {
|
||||
foreach($cards as $pos) {
|
||||
foreach ($patterns as $cards) {
|
||||
foreach ($cards as $pos) {
|
||||
$this->state[$pos] = self::STATE_WIN;
|
||||
}
|
||||
}
|
||||
|
|
@ -171,12 +171,12 @@ class GameBoardState
|
|||
/**
|
||||
* Check if the board is in a winning state.
|
||||
*/
|
||||
protected function checkWinningState() : array
|
||||
protected function checkWinningState(): array
|
||||
{
|
||||
$win = [];
|
||||
|
||||
// Rows
|
||||
for($y=0; $y < $this->height; $y++) {
|
||||
for ($y = 0; $y < $this->height; $y++) {
|
||||
$c = $this->checkRow($y);
|
||||
if (count($c)) {
|
||||
$win[] = $c;
|
||||
|
|
@ -184,7 +184,7 @@ class GameBoardState
|
|||
}
|
||||
|
||||
// Columns
|
||||
for($x=0; $x < $this->width; $x++) {
|
||||
for ($x = 0; $x < $this->width; $x++) {
|
||||
$c = $this->checkCol($x);
|
||||
if (count($c)) {
|
||||
$win[] = $c;
|
||||
|
|
@ -197,12 +197,12 @@ class GameBoardState
|
|||
/**
|
||||
* Check if a row is in a winning state (all cells pressed)
|
||||
*/
|
||||
protected function checkRow($y) : array
|
||||
protected function checkRow($y): array
|
||||
{
|
||||
$cards = [];
|
||||
|
||||
$y = $y * $this->width;
|
||||
for($x = 0; $x < $this->width; $x++) {
|
||||
for ($x = 0; $x < $this->width; $x++) {
|
||||
$pos = $x + $y;
|
||||
if (!$this->isPressed($pos)) {
|
||||
return [];
|
||||
|
|
@ -216,11 +216,11 @@ class GameBoardState
|
|||
/**
|
||||
* Check if a column is in a winning state (all cells pressed)
|
||||
*/
|
||||
protected function checkCol($x) : array
|
||||
protected function checkCol($x): array
|
||||
{
|
||||
$cards = [];
|
||||
|
||||
for($y = 0; $y < $this->height; $y++) {
|
||||
for ($y = 0; $y < $this->height; $y++) {
|
||||
$pos = $x + ($y * $this->width);
|
||||
if (!$this->isPressed($pos)) {
|
||||
return [];
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class GameService
|
|||
/**
|
||||
* Get the current session
|
||||
*/
|
||||
public function session() : GameSession
|
||||
public function session(): GameSession
|
||||
{
|
||||
return $this->session;
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ class GameService
|
|||
/**
|
||||
* Generate a new Game session
|
||||
*/
|
||||
public function newSession(?GameSettings $settings = null) : self
|
||||
public function newSession(?GameSettings $settings = null): self
|
||||
{
|
||||
if (!$settings) {
|
||||
$settings = $this->session()->getSettings();
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class GameSession
|
|||
/**
|
||||
* Get the board
|
||||
*/
|
||||
public function getBoard() : GameBoard
|
||||
public function getBoard(): GameBoard
|
||||
{
|
||||
return $this->board;
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ class GameSession
|
|||
/**
|
||||
* Get the board state
|
||||
*/
|
||||
public function getBoardState() : GameBoardState
|
||||
public function getBoardState(): GameBoardState
|
||||
{
|
||||
return $this->getBoard()->getState();
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ class GameSession
|
|||
/**
|
||||
* Get Cards
|
||||
*/
|
||||
public function getCards() : Collection
|
||||
public function getCards(): Collection
|
||||
{
|
||||
return $this->getBoard()->getCards();
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ class GameSession
|
|||
/**
|
||||
* Get Settings
|
||||
*/
|
||||
public function getSettings() : GameSettings
|
||||
public function getSettings(): GameSettings
|
||||
{
|
||||
return $this->settings;
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ class GameSession
|
|||
/**
|
||||
* Set new settings
|
||||
*/
|
||||
public function setSettings(GameSettings $settings) : self
|
||||
public function setSettings(GameSettings $settings): self
|
||||
{
|
||||
$this->settings = $settings;
|
||||
return $this;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class GameSettings
|
|||
}
|
||||
}
|
||||
|
||||
public function toArray() : array
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'classes' => $this->classes->toArray(),
|
||||
|
|
@ -54,7 +54,7 @@ class GameSettings
|
|||
];
|
||||
}
|
||||
|
||||
public function all() : Collection
|
||||
public function all(): Collection
|
||||
{
|
||||
return collect([
|
||||
'classes' => $this->classes->all()->toArray(),
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use App\Http\Livewire\Form\CardForm;
|
|||
|
||||
class CardController extends BaseController
|
||||
{
|
||||
protected $_datatable = [
|
||||
protected $_datatable = [
|
||||
'model' => Card::class,
|
||||
'default_sort' => 'id',
|
||||
'route_create' => 'admin.card.create',
|
||||
|
|
@ -16,21 +16,21 @@ class CardController extends BaseController
|
|||
'restore_enabled' => true,
|
||||
'columns' => [
|
||||
'id' => '#',
|
||||
'body' => 'Body',
|
||||
'subject' => 'Subject',
|
||||
'subject_type' => 'Subject Type',
|
||||
'body' => 'Body',
|
||||
'subject' => 'Subject',
|
||||
'subject_type' => 'Subject Type',
|
||||
'raid.name' => 'Raid',
|
||||
],
|
||||
'sort_columns' => [
|
||||
'id' => 'id',
|
||||
'body' => 'body',
|
||||
'body' => 'body',
|
||||
'subject' => ['character.name', 'class', 'role'],
|
||||
'raid.name' => 'raid.name',
|
||||
]
|
||||
];
|
||||
|
||||
static public function getForm() : string
|
||||
{
|
||||
return CardForm::class;
|
||||
}
|
||||
static public function getForm(): string
|
||||
{
|
||||
return CardForm::class;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ use App\Http\Controllers\Controller;
|
|||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
/**
|
||||
/**
|
||||
* Show login page
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('auth.login');
|
||||
}
|
||||
public function create()
|
||||
{
|
||||
return view('auth.login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy an authenticated session.
|
||||
|
|
|
|||
|
|
@ -31,18 +31,18 @@ class Kernel extends HttpKernel
|
|||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class
|
||||
];
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,45 +7,45 @@ use Livewire\Component;
|
|||
|
||||
class AlertContainer extends Component
|
||||
{
|
||||
/**
|
||||
* List of alert types.
|
||||
*/
|
||||
protected array $_types = [
|
||||
'info',
|
||||
'success',
|
||||
'warning',
|
||||
'danger'
|
||||
];
|
||||
/**
|
||||
* List of alert types.
|
||||
*/
|
||||
protected array $_types = [
|
||||
'info',
|
||||
'success',
|
||||
'warning',
|
||||
'danger'
|
||||
];
|
||||
|
||||
/**
|
||||
* Event listeners
|
||||
*/
|
||||
protected $listeners = [
|
||||
// Add message when "alert" event is fired.
|
||||
'alert' => 'addMessage'
|
||||
];
|
||||
/**
|
||||
* Event listeners
|
||||
*/
|
||||
protected $listeners = [
|
||||
// Add message when "alert" event is fired.
|
||||
'alert' => 'addMessage'
|
||||
];
|
||||
|
||||
/**
|
||||
* Alert messages.
|
||||
*/
|
||||
public array $messages = [];
|
||||
/**
|
||||
* Alert messages.
|
||||
*/
|
||||
public array $messages = [];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
// Load messages from session
|
||||
foreach($this->_types as $type) {
|
||||
if (Session::has($type)) {
|
||||
$this->addMessage($type, Session::get($type));
|
||||
}
|
||||
}
|
||||
// Load messages from session
|
||||
foreach ($this->_types as $type) {
|
||||
if (Session::has($type)) {
|
||||
$this->addMessage($type, Session::get($type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a message to the container.
|
||||
*/
|
||||
public function addMessage(string $type, string $message)
|
||||
/**
|
||||
* Add a message to the container.
|
||||
*/
|
||||
public function addMessage(string $type, string $message)
|
||||
{
|
||||
$this->messages[] = [ $type, $message ];
|
||||
$this->messages[] = [$type, $message];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,197 +5,202 @@ namespace App\Http\Livewire;
|
|||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Datatable extends Component
|
||||
{
|
||||
use WithPagination, Traits\WithSort, Traits\Alert;
|
||||
use WithPagination, Traits\WithSort, Traits\Alert;
|
||||
|
||||
/**
|
||||
* Query string settings.
|
||||
*/
|
||||
protected $queryString = [
|
||||
'sort' => ['except' => 'id'],
|
||||
'dir' => ['except' => 'asc'],
|
||||
'page' => ['except' => 1],
|
||||
'trashed' => ['except' => false]
|
||||
];
|
||||
/**
|
||||
* Query string settings.
|
||||
*/
|
||||
protected $queryString = [
|
||||
'sort' => ['except' => 'id'],
|
||||
'dir' => ['except' => 'asc'],
|
||||
'page' => ['except' => 1],
|
||||
'trashed' => ['except' => false]
|
||||
];
|
||||
|
||||
/**
|
||||
* Model to get data from.
|
||||
*/
|
||||
public $model;
|
||||
/**
|
||||
* Model to get data from.
|
||||
*/
|
||||
public $model;
|
||||
|
||||
/**
|
||||
* Array of columns to show
|
||||
*/
|
||||
public array $columns;
|
||||
/**
|
||||
* Array of columns to show
|
||||
*/
|
||||
public array $columns;
|
||||
|
||||
/**
|
||||
* What colums are sortable
|
||||
*/
|
||||
public array $sort_columns;
|
||||
/**
|
||||
* What colums are sortable
|
||||
*/
|
||||
public array $sort_columns;
|
||||
|
||||
/**
|
||||
* Default sorting column
|
||||
*/
|
||||
public string $default_sort;
|
||||
/**
|
||||
* Default sorting column
|
||||
*/
|
||||
public string $default_sort;
|
||||
|
||||
/**
|
||||
* If only trashed records should be shown.
|
||||
*/
|
||||
public bool $trashed = false;
|
||||
/**
|
||||
* If only trashed records should be shown.
|
||||
*/
|
||||
public bool $trashed = false;
|
||||
|
||||
/**
|
||||
* Route for creating a record (if null, link is omitted)
|
||||
*/
|
||||
public $route_create;
|
||||
/**
|
||||
* Route for creating a record (if null, link is omitted)
|
||||
*/
|
||||
public $route_create;
|
||||
|
||||
/**
|
||||
* Route for editing a record (if null, link is omitted)
|
||||
*/
|
||||
public $route_edit;
|
||||
/**
|
||||
* Route for editing a record (if null, link is omitted)
|
||||
*/
|
||||
public $route_edit;
|
||||
|
||||
/**
|
||||
* True if delete functionality is enabled.
|
||||
*/
|
||||
public $delete_enabled;
|
||||
/**
|
||||
* True if delete functionality is enabled.
|
||||
*/
|
||||
public $delete_enabled;
|
||||
|
||||
/**
|
||||
* True if restore functionality is enabled.
|
||||
*/
|
||||
public $restore_enabled;
|
||||
/**
|
||||
* True if restore functionality is enabled.
|
||||
*/
|
||||
public $restore_enabled;
|
||||
|
||||
/**
|
||||
* How many records should be displayed on one page.
|
||||
*/
|
||||
public int $itemsPerPage = 30;
|
||||
/**
|
||||
* How many records should be displayed on one page.
|
||||
*/
|
||||
public int $itemsPerPage = 30;
|
||||
|
||||
public function mount(string $model, array $columns,
|
||||
array $sort_columns = [], $default_sort = '',
|
||||
$route_create = null, $route_edit = null, $delete_enabled = false, $restore_enabled = false)
|
||||
{
|
||||
$this->model = app()->make($model);
|
||||
$this->default_sort = $default_sort;
|
||||
$this->sort = $this->default_sort;
|
||||
$this->sort_columns = $sort_columns;
|
||||
$this->route_create = $route_create;
|
||||
$this->route_edit = $route_edit;
|
||||
$this->delete_enabled = (bool) $delete_enabled;
|
||||
$this->restore_enabled = (bool) $restore_enabled;
|
||||
public function mount(
|
||||
string $model,
|
||||
array $columns,
|
||||
array $sort_columns = [],
|
||||
$default_sort = '',
|
||||
$route_create = null,
|
||||
$route_edit = null,
|
||||
$delete_enabled = false,
|
||||
$restore_enabled = false
|
||||
) {
|
||||
$this->model = app()->make($model);
|
||||
$this->default_sort = $default_sort;
|
||||
$this->columns = $columns;
|
||||
$this->sort = $this->default_sort;
|
||||
$this->sort_columns = $sort_columns;
|
||||
$this->route_create = $route_create;
|
||||
$this->route_edit = $route_edit;
|
||||
$this->delete_enabled = (bool) $delete_enabled;
|
||||
$this->restore_enabled = (bool) $restore_enabled;
|
||||
|
||||
$this->setTrashed(false);
|
||||
$this->setTrashed(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the model name.
|
||||
*/
|
||||
public function getModelName() : string
|
||||
{
|
||||
return class_basename($this->model);
|
||||
}
|
||||
/**
|
||||
* Get the model name.
|
||||
*/
|
||||
public function getModelName(): string
|
||||
{
|
||||
return class_basename($this->model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set trashed flag.
|
||||
*/
|
||||
public function setTrashed($value)
|
||||
{
|
||||
$this->trashed = (bool) $value;
|
||||
/**
|
||||
* Set trashed flag.
|
||||
*/
|
||||
public function setTrashed($value)
|
||||
{
|
||||
$this->trashed = (bool) $value;
|
||||
|
||||
if ($this->trashed) {
|
||||
// Add deleted_at columns.
|
||||
$this->columns['deleted_at'] = 'Deleted at';
|
||||
$this->sort_columns['deleted_at'] = 'deleted_at';
|
||||
} else {
|
||||
// Unset deleted_at columns.
|
||||
unset($this->columns['deleted_at']);
|
||||
unset($this->sort_columns['deleted_at']);
|
||||
if ($this->trashed) {
|
||||
// Add deleted_at columns.
|
||||
$this->columns['deleted_at'] = 'Deleted at';
|
||||
$this->sort_columns['deleted_at'] = 'deleted_at';
|
||||
} else {
|
||||
// Unset deleted_at columns.
|
||||
unset($this->columns['deleted_at']);
|
||||
unset($this->sort_columns['deleted_at']);
|
||||
|
||||
// if delete_at was the sorting column
|
||||
// revert back to default sorting.
|
||||
if ($this->sort == 'deleted_at') {
|
||||
$this->sort = $this->default_sort;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if delete_at was the sorting column
|
||||
// revert back to default sorting.
|
||||
if ($this->sort == 'deleted_at') {
|
||||
$this->sort = $this->default_sort;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle trashed flag
|
||||
*/
|
||||
public function toggleTrashed()
|
||||
{
|
||||
$this->setTrashed(!$this->trashed);
|
||||
}
|
||||
/**
|
||||
* Toggle trashed flag
|
||||
*/
|
||||
public function toggleTrashed()
|
||||
{
|
||||
$this->setTrashed(!$this->trashed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an record
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$this->delete_enabled) {
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Delete an record
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$this->delete_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$record = $this->model->find($id);
|
||||
$record = $this->model->find($id);
|
||||
|
||||
if (!$record) {
|
||||
$this->danger('Record not found');
|
||||
return;
|
||||
}
|
||||
if (!$record) {
|
||||
$this->danger('Record not found');
|
||||
return;
|
||||
}
|
||||
|
||||
$record->delete();
|
||||
$record->delete();
|
||||
|
||||
$this->info(__($this->getModelName() . " #:id was deleted.", [ 'id' => $record->id ]));
|
||||
}
|
||||
$this->info(__($this->getModelName() . " #:id was deleted.", ['id' => $record->id]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore a delted record
|
||||
*/
|
||||
public function restore($id)
|
||||
{
|
||||
if (!$this->restore_enabled) {
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Restore a delted record
|
||||
*/
|
||||
public function restore($id)
|
||||
{
|
||||
if (!$this->restore_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$record = $this->model->withTrashed()->find($id);
|
||||
$record = $this->model->withTrashed()->find($id);
|
||||
|
||||
if (!$record) {
|
||||
$this->danger('Record not found');
|
||||
return;
|
||||
}
|
||||
if (!$record) {
|
||||
$this->danger('Record not found');
|
||||
return;
|
||||
}
|
||||
|
||||
$record->restore();
|
||||
$record->restore();
|
||||
|
||||
$this->info(__($this->getModelName() . " #:id was restored.", [ 'id' => $record->id ]));
|
||||
}
|
||||
$this->info(__($this->getModelName() . " #:id was restored.", ['id' => $record->id]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the datatable
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$query = $this->model->query();
|
||||
$query = $this->model->query();
|
||||
|
||||
// Only include trashed if asked to.
|
||||
if ($this->trashed) {
|
||||
$query->onlyTrashed();
|
||||
}
|
||||
// Only include trashed if asked to.
|
||||
if ($this->trashed) {
|
||||
$query->onlyTrashed();
|
||||
}
|
||||
|
||||
// Check colums for "dot-notated" strings.
|
||||
// as we want to eager load those relationships
|
||||
foreach ($this->columns as $col => $_) {
|
||||
$p = strrpos($col, '.');
|
||||
if ($p !== false) {
|
||||
$rel = substr($col, 0, $p);
|
||||
$query->with($rel);
|
||||
}
|
||||
}
|
||||
// Check colums for "dot-notated" strings.
|
||||
// as we want to eager load those relationships
|
||||
foreach ($this->columns as $col => $_) {
|
||||
$p = strrpos($col, '.');
|
||||
if ($p !== false) {
|
||||
$rel = substr($col, 0, $p);
|
||||
$query->with($rel);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply sorting.
|
||||
$this->sortApply($query);
|
||||
// Apply sorting.
|
||||
$this->sortApply($query);
|
||||
|
||||
$items = $query->paginate($this->itemsPerPage);
|
||||
$items = $query->paginate($this->itemsPerPage);
|
||||
|
||||
return view('livewire.datatable', ['items' => $items]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class Authenticate extends Middleware
|
|||
*/
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
if (!$request->expectsJson()) {
|
||||
return route('login');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class Card extends Model
|
|||
return "Somebody";
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Who, Where or What this card belongs to.
|
||||
*/
|
||||
public function getSubjectTypeAttribute()
|
||||
|
|
@ -91,7 +91,7 @@ class Card extends Model
|
|||
->inRandomOrder();
|
||||
|
||||
// Run through all settings and apply filter.
|
||||
foreach($settings->all() as $type => $values) {
|
||||
foreach ($settings->all() as $type => $values) {
|
||||
|
||||
$column = $type_map[$type];
|
||||
|
||||
|
|
|
|||
|
|
@ -29,14 +29,14 @@ class Setting extends Model
|
|||
];
|
||||
|
||||
/**
|
||||
* Get the prunable model query.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function prunable()
|
||||
{
|
||||
return static::where('created_at', '<', now()->subDay(1));
|
||||
}
|
||||
* Get the prunable model query.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function prunable()
|
||||
{
|
||||
return static::where('created_at', '<', now()->subDay(1));
|
||||
}
|
||||
|
||||
public function getHashAttribute()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,19 +4,19 @@ namespace App\Models;
|
|||
|
||||
class Wow
|
||||
{
|
||||
/**
|
||||
* Enum for classes.
|
||||
*/
|
||||
static public $classes = [
|
||||
'warrior' => 'Warrior',
|
||||
'rogue' => 'Rogue',
|
||||
'paladin' => 'Paladin',
|
||||
'hunter' => 'Hunter',
|
||||
'mage' => 'Mage',
|
||||
'warlock' => 'Warlock',
|
||||
'shaman' => 'Shaman',
|
||||
'druid' => 'Druid',
|
||||
'priest' => 'Priest',
|
||||
'dk' => 'Death Knight'
|
||||
];
|
||||
/**
|
||||
* Enum for classes.
|
||||
*/
|
||||
static public $classes = [
|
||||
'warrior' => 'Warrior',
|
||||
'rogue' => 'Rogue',
|
||||
'paladin' => 'Paladin',
|
||||
'hunter' => 'Hunter',
|
||||
'mage' => 'Mage',
|
||||
'warlock' => 'Warlock',
|
||||
'shaman' => 'Shaman',
|
||||
'druid' => 'Druid',
|
||||
'priest' => 'Priest',
|
||||
'dk' => 'Death Knight'
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Game\GameBuilder;
|
||||
use App\Game\GameBoardState;
|
||||
use App\Game\GameService;
|
||||
use App\Game\GameSession;
|
||||
|
|
@ -20,7 +19,7 @@ class GameServiceProvider extends ServiceProvider implements DeferrableProvider
|
|||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->bind(GameBoardState::class, function($app) {
|
||||
$this->app->bind(GameBoardState::class, function ($app) {
|
||||
$width = (int) config('app.game.board.width', 4);
|
||||
$height = (int) config('app.game.board.height', 4);
|
||||
return new GameBoardState($width, $height);
|
||||
|
|
@ -50,6 +49,6 @@ class GameServiceProvider extends ServiceProvider implements DeferrableProvider
|
|||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [ 'game', GameService::class, GameBoardState::class ];
|
||||
return ['game', GameService::class, GameBoardState::class];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,7 @@ namespace App\Providers;
|
|||
|
||||
use App\Models\Setting;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ class Set implements \Countable
|
|||
|
||||
public function __construct($items = [])
|
||||
{
|
||||
foreach($items as $k => $v) {
|
||||
foreach ($items as $k => $v) {
|
||||
$this->set($k, $v);
|
||||
}
|
||||
}
|
||||
|
||||
public function set($key, bool $value = true) : self
|
||||
public function set($key, bool $value = true): self
|
||||
{
|
||||
if ($value) {
|
||||
$this->items[$key] = true;
|
||||
|
|
@ -29,40 +29,40 @@ class Set implements \Countable
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function fill($array) : self
|
||||
public function fill($array): self
|
||||
{
|
||||
$this->clear();
|
||||
|
||||
foreach($array as $k => $v) {
|
||||
foreach ($array as $k => $v) {
|
||||
$this->set($k, $v);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function has($key) : bool
|
||||
public function has($key): bool
|
||||
{
|
||||
return isset($this->items[$key]);
|
||||
}
|
||||
|
||||
public function toggle($key) : self
|
||||
public function toggle($key): self
|
||||
{
|
||||
$this->set($key, !$this->has($key));
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function clear() : self
|
||||
public function clear(): self
|
||||
{
|
||||
$this->items = [];
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function all() : Collection
|
||||
public function all(): Collection
|
||||
{
|
||||
return collect($this->items)->keys();
|
||||
}
|
||||
|
||||
public function count() : int
|
||||
public function count(): int
|
||||
{
|
||||
return count($this->items);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class CardText extends Component
|
|||
{
|
||||
protected Card $card;
|
||||
|
||||
protected string $subject;
|
||||
protected string $subject;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
|
|
@ -20,7 +20,7 @@ class CardText extends Component
|
|||
public function __construct(Card $card, $subject = '')
|
||||
{
|
||||
$this->card = $card;
|
||||
$this->subject = strlen($subject) ? $subject : $card->subject;
|
||||
$this->subject = strlen($subject) ? $subject : $card->subject;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -34,9 +34,10 @@ class CardText extends Component
|
|||
|
||||
// Replace non escaped '?' with subject and also Unescape escaped '?'
|
||||
$text = preg_replace(
|
||||
['/(?<!\\\\)\?/u', '/\\\\\\?/u'] ,
|
||||
['/(?<!\\\\)\?/u', '/\\\\\\?/u'],
|
||||
["<strong>$subject</strong>", '?'],
|
||||
$this->card->body);
|
||||
$this->card->body
|
||||
);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue