1
0
Fork 0

Formatting fixes and cleanup.

This commit is contained in:
Henrik Hautakoski 2023-01-31 07:34:02 +01:00
parent a1e14a3e60
commit 51fb71e469
41 changed files with 394 additions and 392 deletions

View file

@ -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,

View file

@ -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,

View file

@ -34,4 +34,4 @@ class InstallLogo extends Command
Storage::disk('resources')->copy('logos/' . $filename, 'images/logo.png');
}
}
}

View file

@ -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');
}

View file

@ -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);

View file

@ -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 [];

View file

@ -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();

View file

@ -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;

View file

@ -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(),

View file

@ -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;
}
}

View file

@ -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.

View file

@ -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
];
}

View file

@ -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];
}
/**

View file

@ -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]);
}

View file

@ -14,7 +14,7 @@ class Authenticate extends Middleware
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
if (!$request->expectsJson()) {
return route('login');
}
}

View file

@ -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];

View file

@ -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()
{

View file

@ -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'
];
}

View file

@ -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];
}
}

View file

@ -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

View file

@ -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);
}

View file

@ -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;
}

View file

@ -15,9 +15,9 @@ define('LARAVEL_START', microtime(true));
|
*/
require __DIR__.'/vendor/autoload.php';
require __DIR__ . '/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
$app = require_once __DIR__ . '/bootstrap/app.php';
/*
|--------------------------------------------------------------------------

View file

@ -105,6 +105,6 @@ return [
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'Bingo'), '_').'_cache'),
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'Bingo'), '_') . '_cache'),
];

View file

@ -123,7 +123,7 @@ return [
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'),
],
'default' => [

View file

@ -43,7 +43,7 @@ return [
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'url' => env('APP_URL') . '/storage',
'visibility' => 'public',
],

View file

@ -2,8 +2,8 @@
return [
'select' => [
'icon' => 'heroicon-s-chevron-down',
]
'select' => [
'icon' => 'heroicon-s-chevron-down',
]
];

View file

@ -16,7 +16,7 @@ return [
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'%s%s',
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : ''
env('APP_URL') ? ',' . parse_url(env('APP_URL'), PHP_URL_HOST) : ''
))),
/*

View file

@ -128,7 +128,7 @@ return [
'cookie' => env(
'SESSION_COOKIE',
Str::slug(env('APP_NAME', 'bingo'), '_').'_session'
Str::slug(env('APP_NAME', 'bingo'), '_') . '_session'
),
/*

View file

@ -2,4 +2,4 @@
return [
'proxies' => env('HTTP_TRUSTED_PROXIES', []),
];
];

View file

@ -14,10 +14,10 @@ class TBCRaidSeeder extends Seeder
*/
public function run()
{
$raids = [ 'Karazhan', 'Grul\'s Lair', 'Magtheridon', 'SSC', 'TK' ];
$raids = ['Karazhan', 'Grul\'s Lair', 'Magtheridon', 'SSC', 'TK'];
foreach($raids as $name) {
Raid::insert(['name' => $name ]);
foreach ($raids as $name) {
Raid::insert(['name' => $name]);
}
}
}

View file

@ -14,10 +14,10 @@ class WrathRaidSeeder extends Seeder
*/
public function run()
{
$raids = [ 'Naxramas', 'Obsidian Sanctum', 'Malygos', 'Ulduar', 'Icecrown Citadel' ];
$raids = ['Naxramas', 'Obsidian Sanctum', 'Malygos', 'Ulduar', 'Icecrown Citadel'];
foreach($raids as $name) {
Raid::insert(['name' => $name ]);
foreach ($raids as $name) {
Raid::insert(['name' => $name]);
}
}
}

View file

@ -4,25 +4,25 @@
<form class="space-y-4" wire:submit.prevent="submit">
<div>
<x-ignite-label for="username">{{ __('Username') }}</x-ignite-label>
<x-ignite-input name="username" value="{{ $username }}" disabled />
</div>
<div>
<x-ignite-label for="username">{{ __('Username') }}</x-ignite-label>
<x-ignite-input name="username" value="{{ $username }}" disabled />
</div>
<div>
<x-ignite-label for="password_current">{{ __('Current Password') }}</x-ignite-label>
<x-ignite-password name="password_current" wire:model="password_current" />
</div>
<div>
<x-ignite-label for="password_current">{{ __('Current Password') }}</x-ignite-label>
<x-ignite-password name="password_current" wire:model="password_current" />
</div>
<div>
<x-ignite-label for="password">{{ __('New Password') }}</x-ignite-label>
<x-ignite-password name="password" wire:model="password" />
</div>
<div>
<x-ignite-label for="password">{{ __('New Password') }}</x-ignite-label>
<x-ignite-password name="password" wire:model="password" />
</div>
<div>
<x-ignite-label for="password_confirmation">{{ __('Confirm Password') }}</x-ignite-label>
<x-ignite-password name="password_confirmation" wire:model="password_confirmation" />
</div>
<div>
<x-ignite-label for="password_confirmation">{{ __('Confirm Password') }}</x-ignite-label>
<x-ignite-password name="password_confirmation" wire:model="password_confirmation" />
</div>
<x-button type="info">{{ __('Save') }}</x-button>
<x-button href="{{ route('admin') }}" type="warning">{{ __('Back') }}</x-button>

View file

@ -9,7 +9,7 @@
<ul class="py-4 space-y-2 text-white">
<li><a class="{{ $item_classes }}" href="{{ url('/admin/account') }}"><x-heroicon-o-user class="h-8 mr-2"/> {{ __('Account') }}</a></li>
<li><a class="{{ $item_classes }}" href="{{ url('/admin') }}"><x-heroicon-o-user-group class="h-8 mr-2"/> {{ __('Admins') }}</a></li>
<li><a class="{{ $item_classes }}" href="{{ url('/admin') }}"><x-heroicon-o-user-group class="h-8 mr-2"/> {{ __('Admins') }}</a></li>
</ul>
<ul class="py-4 space-y-2 text-white">

View file

@ -47,7 +47,7 @@ Artisan::command('character:edit {id} {name}', function ($id, $name) {
})->purpose('Edit a character');
Artisan::command('character:list {--trashed}', function ($trashed) {
$cols = ['id', 'name' ];
$cols = ['id', 'name'];
if ($trashed) {
$cols[] = 'deleted_at';
$q = Character::onlyTrashed();
@ -83,7 +83,7 @@ Artisan::command('raid:add {name}', function ($name) {
Artisan::command('raid:edit {id} {name}', function ($id, $name) {
$raid = Raid::find($id);
if (!$raid ) {
if (!$raid) {
$this->warn("Could not find raid.");
return;
}
@ -95,7 +95,7 @@ Artisan::command('raid:edit {id} {name}', function ($id, $name) {
})->purpose('Edit a raid');
Artisan::command('raid:list {--trashed}', function ($trashed) {
$cols = ['id', 'name' ];
$cols = ['id', 'name'];
if ($trashed) {
$cols[] = 'deleted_at';
$q = Raid::onlyTrashed();
@ -120,9 +120,9 @@ Artisan::command('raid:delete {id}', function ($id) {
// Cards
// --------------------------
Artisan::command('card:add {body} {--column=} {--value=}', function ($body, $column=null, $value=null) {
Artisan::command('card:add {body} {--column=} {--value=}', function ($body, $column = null, $value = null) {
$data = [ 'body' => $body ];
$data = ['body' => $body];
if ($value && !in_array($column, ['character_id', 'raid_id', 'class', 'role'])) {
$this->warn(sprintf("Invalid column '%s'", $column));
@ -137,7 +137,7 @@ Artisan::command('card:add {body} {--column=} {--value=}', function ($body, $col
$this->info("Created card");
})->purpose('Create a new card');
Artisan::command('card:edit {id} {--body=} {--column=} {--value=}', function ($id, $body=null, $column=null, $value=null) {
Artisan::command('card:edit {id} {--body=} {--column=} {--value=}', function ($id, $body = null, $column = null, $value = null) {
$card = Card::find($id);
@ -164,7 +164,7 @@ Artisan::command('card:edit {id} {--body=} {--column=} {--value=}', function ($i
})->purpose('Update a card');
Artisan::command('card:list {--trashed}', function ($trashed) {
$cols = [ 'id', 'character_id', 'raid_id', 'role', 'class', 'body' ];
$cols = ['id', 'character_id', 'raid_id', 'role', 'class', 'body'];
$q = Card::query();
if ($trashed) {
$cols[] = 'deleted_at';
@ -197,7 +197,7 @@ Artisan::command('admin:add {username} {password}', function ($username, $passwo
$this->info("Created admin user");
})->purpose('Add a admin user');
Artisan::command('admin:edit {id} {--username=} {--password=}', function ($id, $username=null, $password=null) {
Artisan::command('admin:edit {id} {--username=} {--password=}', function ($id, $username = null, $password = null) {
$admin = Admin::find($id);
if (!$admin) {
@ -228,8 +228,8 @@ Artisan::command('admin:delete {id}', function ($id) {
})->purpose('Delete a admin user');
Artisan::command('admin:list', function () {
$cols = ['id', 'username', 'password', 'created_at', 'updated_at' ];
$cols = ['id', 'username', 'password', 'created_at', 'updated_at'];
$q = Admin::query();
$data = $q->select($cols)->get()->makeVisible('password');
$this->table($cols, $data);
})->purpose('list admin users');
})->purpose('list admin users');

View file

@ -26,41 +26,41 @@ use Illuminate\Support\Facades\Session;
|
*/
Route::get('/', function() {
Route::get('/', function () {
return redirect()->route('setup');
});
Route::get('/setup', Setup::class)->name('setup');
route::get('/setup/{setting}', [ SettingController::class, "hash" ])->name('setup-hash');
route::get('/setup/{setting}', [SettingController::class, "hash"])->name('setup-hash');
Route::get('/game', Game::class)->name('game');
// Admin section
Route::prefix('admin')->group(function() {
Route::prefix('admin')->group(function () {
// Auth
Route::get('/login', [AuthController::class, 'create'])->name('login');
Route::post('/login', [AuthController::class, 'store']);
// Auth
Route::get('/login', [AuthController::class, 'create'])->name('login');
Route::post('/login', [AuthController::class, 'store']);
Route::middleware(['auth'])->group(function() {
Route::middleware(['auth'])->group(function () {
Route::get('/', [AdminController::class, 'index'])->name('admin');
Route::get('/', [AdminController::class, 'index'])->name('admin');
Route::get('/account', AccountForm::class);
Route::get('/cards', [CardController::class, 'index'])->name('admin.card.index');
Route::get('/cards/new', CardController::getForm())->name('admin.card.create');
Route::get('/cards/{card}', CardController::getForm())->name('admin.card.edit');
Route::get('/cards', [CardController::class, 'index'])->name('admin.card.index');
Route::get('/cards/new', CardController::getForm())->name('admin.card.create');
Route::get('/cards/{card}', CardController::getForm())->name('admin.card.edit');
Route::get('/characters', [CharacterController::class, 'index'])->name('admin.character.index');
Route::get('/characters/new', CharacterController::getForm())->name('admin.character.create');
Route::get('/characters/{character}', CharacterController::getForm())->name('admin.character.edit');
Route::get('/characters', [CharacterController::class, 'index'])->name('admin.character.index');
Route::get('/characters/new', CharacterController::getForm())->name('admin.character.create');
Route::get('/characters/{character}', CharacterController::getForm())->name('admin.character.edit');
Route::get('/raids', [RaidController::class, 'index'])->name('admin.raid.index');
Route::get('/raids/new', RaidController::getForm())->name('admin.raid.create');
Route::get('/raids/{raid}', RaidController::getForm())->name('admin.raid.edit');
Route::get('/raids', [RaidController::class, 'index'])->name('admin.raid.index');
Route::get('/raids/new', RaidController::getForm())->name('admin.raid.create');
Route::get('/raids/{raid}', RaidController::getForm())->name('admin.raid.edit');
Route::post('/logout', [AuthController::class, 'destroy'])->name('logout');
});
Route::post('/logout', [AuthController::class, 'destroy'])->name('logout');
});
});

View file

@ -14,8 +14,8 @@ $uri = urldecode(
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
if ($uri !== '/' && file_exists(__DIR__ . '/public' . $uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
require_once __DIR__ . '/public/index.php';

View file

@ -13,7 +13,7 @@ trait CreatesApplication
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app = require __DIR__ . '/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();

View file

@ -19,7 +19,7 @@ class CardTest extends TestCase
protected $characters;
public function setUp() : void
public function setUp(): void
{
parent::setUp();
@ -47,24 +47,24 @@ class CardTest extends TestCase
public function provider(): array
{
return [
[ [ 0 ], 16 ],
[ [ 0, 1 ], 18 ],
[[0], 16],
[[0, 1], 18],
];
}
public function providerClasses(): array
{
return [
[ [ 'priest' ], 16 ],
[ [ 'priest', 'warrior' ], 18 ],
[['priest'], 16],
[['priest', 'warrior'], 18],
];
}
public function providerRoles(): array
{
return [
[ [ 'dps' ], 16 ],
[ [ 'dps', 'tank' ], 18 ],
[['dps'], 16],
[['dps', 'tank'], 18],
];
}
@ -74,7 +74,7 @@ class CardTest extends TestCase
public function test_get_with_character_settings($characters, $count)
{
$settings = new GameSettings();
foreach($characters as $i) {
foreach ($characters as $i) {
$settings->characters->set($this->characters[$i]);
}
@ -82,11 +82,11 @@ class CardTest extends TestCase
$this->assertSame($count, count($cards));
$expected = collect($characters)->map(function($i) {
$expected = collect($characters)->map(function ($i) {
return $this->characters[$i];
})->push(null);
foreach($cards as $card) {
foreach ($cards as $card) {
$this->assertContains($card->character_id, $expected, $cards->pluck('character_id'));
}
}
@ -97,7 +97,7 @@ class CardTest extends TestCase
public function test_get_with_raid_settings($raids, $count)
{
$settings = new GameSettings();
foreach($raids as $i) {
foreach ($raids as $i) {
$settings->raids->set($this->raids[$i]);
}
@ -105,11 +105,11 @@ class CardTest extends TestCase
$this->assertSame($count, count($cards));
$expected = collect($raids)->map(function($item) {
$expected = collect($raids)->map(function ($item) {
return $this->raids[$item];
})->push(null);
foreach($cards as $card) {
foreach ($cards as $card) {
$this->assertContains($card->raid_id, $expected);
}
}
@ -120,7 +120,7 @@ class CardTest extends TestCase
public function test_get_with_class_settings($classes, $count)
{
$settings = new GameSettings();
foreach($classes as $class) {
foreach ($classes as $class) {
$settings->classes->set($class);
}
@ -130,7 +130,7 @@ class CardTest extends TestCase
$expected = collect($classes)->push(null);
foreach($cards as $card) {
foreach ($cards as $card) {
$this->assertContains($card->class, $expected);
}
}
@ -141,7 +141,7 @@ class CardTest extends TestCase
public function test_get_with_role_settings($roles, $count)
{
$settings = new GameSettings();
foreach($roles as $role) {
foreach ($roles as $role) {
$settings->roles->set($role);
}
@ -151,7 +151,7 @@ class CardTest extends TestCase
$expected = collect($roles)->push(null);
foreach($cards as $card) {
foreach ($cards as $card) {
$this->assertContains($card->role, $expected);
}
}

View file

@ -19,9 +19,9 @@ class GameBoardStateTest extends TestCase
// 8, 9, 10, 11
// 12, 13, 14, 15
[ 4, 4, [], [ 1, 5, 8 ], 0 ],
[ 4, 4, [ 4, 5, 6, 7 ], [2, 3], 1 ],
[ 4, 4, [ 8, 9, 10, 11, 2, 6, 14 ], [ 15 ], 2 ],
[4, 4, [], [1, 5, 8], 0],
[4, 4, [4, 5, 6, 7], [2, 3], 1],
[4, 4, [8, 9, 10, 11, 2, 6, 14], [15], 2],
// 5x3 board
// ---------------
@ -29,9 +29,9 @@ class GameBoardStateTest extends TestCase
// 5, 6, 7, 8, 9
// 10, 11, 12, 13, 14
[ 5, 3, [], [ 2, 4, 5, 8, 13 ], 0 ],
[ 5, 3, [ 5, 6, 7, 8, 9 ], [ 0, 3, 4, 10], 1 ],
[ 5, 3, [ 0, 5, 10, 3, 8, 13, 4, 9, 14 ], [ 6, 12 ], 3 ],
[5, 3, [], [2, 4, 5, 8, 13], 0],
[5, 3, [5, 6, 7, 8, 9], [0, 3, 4, 10], 1],
[5, 3, [0, 5, 10, 3, 8, 13, 4, 9, 14], [6, 12], 3],
// 10x10 board
// --------------------------------------
@ -46,9 +46,9 @@ class GameBoardStateTest extends TestCase
// 80, 81, 82, 83, 84, 85, 86, 87, 88, 89
// 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
[ 10, 10, [], [ 59, 31, 52 ], 0 ],
[ 10, 10, [ 3, 13, 23, 33, 43, 53, 63, 73, 83, 93 ], [7, 11, 24, 25, 31, 32, 57, 66, 90, 91 ], 1 ],
[ 10, 10, [ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 4, 14, 34, 44, 54, 64, 74, 84, 94 ], [ 0, 32, 61, 78, 98 ], 2 ]
[10, 10, [], [59, 31, 52], 0],
[10, 10, [3, 13, 23, 33, 43, 53, 63, 73, 83, 93], [7, 11, 24, 25, 31, 32, 57, 66, 90, 91], 1],
[10, 10, [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 4, 14, 34, 44, 54, 64, 74, 84, 94], [0, 32, 61, 78, 98], 2]
];
}
@ -59,15 +59,15 @@ class GameBoardStateTest extends TestCase
{
$board = new GameBoardState($w, $h);
foreach($state_win + $state_press as $pos) {
foreach ($state_win + $state_press as $pos) {
$board->set($pos);
}
foreach($state_win as $pos) {
foreach ($state_win as $pos) {
$this->assertTrue($board->isWin($pos));
}
foreach($state_press as $pos) {
foreach ($state_press as $pos) {
$this->assertFalse($board->isWin($pos));
}
}
@ -79,11 +79,11 @@ class GameBoardStateTest extends TestCase
{
$board = new GameBoardState($w, $h);
foreach($state_win + $state_press as $pos) {
foreach ($state_win + $state_press as $pos) {
$board->set($pos);
}
foreach($state_win + $state_press as $pos) {
foreach ($state_win + $state_press as $pos) {
$this->assertTrue($board->isPressed($pos));
}
}
@ -95,7 +95,7 @@ class GameBoardStateTest extends TestCase
{
$board = new GameBoardState($w, $h);
foreach($state_win + $state_press as $pos) {
foreach ($state_win + $state_press as $pos) {
$board->set($pos);
}

View file

@ -32,7 +32,7 @@ class SetTest extends TestCase
{
$set = new Set(['one' => true, 'two' => true, 'three' => true]);
$set->fill(["five" => true, "six" => true, "seven" => false ]);
$set->fill(["five" => true, "six" => true, "seven" => false]);
$this->assertSame(['five', 'six'], $set->all()->toArray());
}