Initial Commit
This commit is contained in:
commit
ddf09fe00c
113 changed files with 187148 additions and 0 deletions
183
routes/console.php
Normal file
183
routes/console.php
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Card;
|
||||
use App\Models\Raid;
|
||||
use App\Models\Character;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Console Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is where you may define all of your Closure based console
|
||||
| commands. Each Closure is bound to a command instance allowing a
|
||||
| simple approach to interacting with each command's IO methods.
|
||||
|
|
||||
*/
|
||||
|
||||
// Characters
|
||||
// --------------------------
|
||||
|
||||
Artisan::command('character:add {name}', function ($name) {
|
||||
|
||||
Character::create([
|
||||
'name' => Str::ucfirst($name),
|
||||
]);
|
||||
|
||||
$this->info("Created character");
|
||||
})->purpose('Add a character');
|
||||
|
||||
Artisan::command('character:edit {id} {name}', function ($id, $name) {
|
||||
|
||||
$character = Character::find($id);
|
||||
if (!$character) {
|
||||
$this->warn("Could not find character.");
|
||||
return;
|
||||
}
|
||||
|
||||
$character->name = Str::ucfirst($name);
|
||||
$character->save();
|
||||
|
||||
$this->info("Updated character");
|
||||
})->purpose('Edit a character');
|
||||
|
||||
Artisan::command('character:list {--trashed}', function ($trashed) {
|
||||
$cols = ['id', 'name' ];
|
||||
if ($trashed) {
|
||||
$cols[] = 'deleted_at';
|
||||
$q = Character::onlyTrashed();
|
||||
} else {
|
||||
$q = Character::query();
|
||||
}
|
||||
$this->table($cols, $q->select($cols)->get());
|
||||
})->purpose('list characters');
|
||||
|
||||
Artisan::command('character:delete {id}', function ($id) {
|
||||
$char = Character::find($id);
|
||||
|
||||
if ($char) {
|
||||
$char->delete();
|
||||
$this->info(sprintf("Character #%s deleted", $id));
|
||||
} else {
|
||||
$this->warn(sprintf("Could not find character with id %s", $id));
|
||||
}
|
||||
})->purpose('Delete a character');
|
||||
|
||||
// Raids
|
||||
// --------------------------
|
||||
|
||||
Artisan::command('raid:add {name}', function ($name) {
|
||||
|
||||
Raid::create([
|
||||
'name' => $name,
|
||||
]);
|
||||
|
||||
$this->info("Created raid");
|
||||
})->purpose('Add a raid');
|
||||
|
||||
Artisan::command('raid:edit {id} {name}', function ($id, $name) {
|
||||
|
||||
$raid = Raid::find($id);
|
||||
if (!$raid ) {
|
||||
$this->warn("Could not find raid.");
|
||||
return;
|
||||
}
|
||||
|
||||
$raid->name = $name;
|
||||
$raid->save();
|
||||
|
||||
$this->info("Updated raid");
|
||||
})->purpose('Edit a raid');
|
||||
|
||||
Artisan::command('raid:list {--trashed}', function ($trashed) {
|
||||
$cols = ['id', 'name' ];
|
||||
if ($trashed) {
|
||||
$cols[] = 'deleted_at';
|
||||
$q = Raid::onlyTrashed();
|
||||
} else {
|
||||
$q = Raid::query();
|
||||
}
|
||||
$this->table($cols, $q->select($cols)->get());
|
||||
})->purpose('list raids');
|
||||
|
||||
Artisan::command('raid:delete {id}', function ($id) {
|
||||
$raid = Raid::find($id);
|
||||
|
||||
if ($raid) {
|
||||
$raid->delete();
|
||||
$this->info(sprintf("Raid #%s deleted", $id));
|
||||
} else {
|
||||
$this->warn(sprintf("Could not find raid with id %s", $id));
|
||||
}
|
||||
})->purpose('Delete a raid');
|
||||
|
||||
|
||||
// Cards
|
||||
// --------------------------
|
||||
|
||||
Artisan::command('card:add {body} {--column=} {--value=}', function ($body, $column=null, $value=null) {
|
||||
|
||||
$data = [ 'body' => $body ];
|
||||
|
||||
if ($value && !in_array($column, ['character_id', 'raid_id', 'class', 'role'])) {
|
||||
$this->warn(sprintf("Invalid column '%s'", $column));
|
||||
return;
|
||||
}
|
||||
|
||||
if ($value && $column) {
|
||||
$data[$column] = $value;
|
||||
}
|
||||
|
||||
Card::create($data);
|
||||
$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) {
|
||||
|
||||
$card = Card::find($id);
|
||||
|
||||
if (!$card) {
|
||||
$this->warn("Could not find card.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ($body) {
|
||||
$card->body = $body;
|
||||
}
|
||||
|
||||
if ($value && in_array($column, ['character_id', 'raid_id', 'class', 'role'])) {
|
||||
$card->character_id = null;
|
||||
$card->raid_id = null;
|
||||
$card->class = null;
|
||||
$card->role = null;
|
||||
$card->{$column} = $value;
|
||||
}
|
||||
|
||||
$card->save();
|
||||
|
||||
$this->info("Updated card");
|
||||
})->purpose('Update a card');
|
||||
|
||||
Artisan::command('card:list {--trashed}', function ($trashed) {
|
||||
$cols = ['id', 'character_id', 'raid_id', 'role', 'class', 'body' ];
|
||||
$q = Card::query();
|
||||
if ($trashed) {
|
||||
$cols[] = 'deleted_at';
|
||||
$q->onlyTrashed();
|
||||
}
|
||||
$data = $q->select($cols)->get()->makeHidden('subject');
|
||||
$this->table($cols, $data);
|
||||
})->purpose('list cards');
|
||||
|
||||
Artisan::command('card:delete {id}', function ($id) {
|
||||
$record = Card::find($id);
|
||||
if ($record) {
|
||||
$record->delete();
|
||||
$this->info(sprintf("Card #%s deleted", $id));
|
||||
} else {
|
||||
$this->warn(sprintf("Could not find card with id %s", $id));
|
||||
}
|
||||
})->purpose('Delete a card');
|
||||
30
routes/web.php
Normal file
30
routes/web.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
use App\Http\Livewire\Game;
|
||||
use App\Http\Livewire\Setup;
|
||||
use App\Http\Controllers\SettingController;
|
||||
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register web routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| contains the "web" middleware group. Now create something great!
|
||||
|
|
||||
*/
|
||||
|
||||
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('/game', Game::class)->name('game');
|
||||
Reference in a new issue