Initial Commit
This commit is contained in:
commit
9b22323711
36 changed files with 7164 additions and 0 deletions
15
.editorconfig
Normal file
15
.editorconfig
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_size = 2
|
||||||
14
.env.example
Normal file
14
.env.example
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
APP_NAME=Lumen
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_URL=http://localhost
|
||||||
|
APP_TIMEZONE=UTC
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
LOG_SLACK_WEBHOOK_URL=
|
||||||
|
|
||||||
|
DB_CONNECTION=sqlite
|
||||||
|
|
||||||
|
CACHE_DRIVER=file
|
||||||
|
QUEUE_CONNECTION=sync
|
||||||
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
/vendor
|
||||||
|
/.idea
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
|
.env
|
||||||
|
.phpunit.result.cache
|
||||||
|
/storage/*.sqlite
|
||||||
6
.styleci.yml
Normal file
6
.styleci.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
php:
|
||||||
|
preset: laravel
|
||||||
|
disabled:
|
||||||
|
- unused_use
|
||||||
|
js: true
|
||||||
|
css: true
|
||||||
0
app/Console/Commands/.gitkeep
Normal file
0
app/Console/Commands/.gitkeep
Normal file
36
app/Console/Commands/AddWordCommand.php
Normal file
36
app/Console/Commands/AddWordCommand.php
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\Word;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class AddWordCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'addword {word} {type}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Add a word to the database';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$row = new Word;
|
||||||
|
$row->value = $this->argument('word');
|
||||||
|
$row->type = $this->argument('type');
|
||||||
|
$row->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
29
app/Console/Kernel.php
Normal file
29
app/Console/Kernel.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console;
|
||||||
|
|
||||||
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
|
use Laravel\Lumen\Console\Kernel as ConsoleKernel;
|
||||||
|
|
||||||
|
class Kernel extends ConsoleKernel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The Artisan commands provided by your application.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $commands = [
|
||||||
|
\App\Console\Commands\AddWordCommand::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the application's command schedule.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function schedule(Schedule $schedule)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
59
app/Exceptions/Handler.php
Normal file
59
app/Exceptions/Handler.php
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class Handler extends ExceptionHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A list of the exception types that should not be reported.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $dontReport = [
|
||||||
|
AuthorizationException::class,
|
||||||
|
HttpException::class,
|
||||||
|
ModelNotFoundException::class,
|
||||||
|
ValidationException::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report or log an exception.
|
||||||
|
*
|
||||||
|
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||||
|
*
|
||||||
|
* @param \Throwable $exception
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function report(Throwable $exception)
|
||||||
|
{
|
||||||
|
parent::report($exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render an exception into an HTTP response.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Throwable $exception
|
||||||
|
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
|
||||||
|
*
|
||||||
|
* @throws \Throwable
|
||||||
|
*/
|
||||||
|
public function render($request, Throwable $exception)
|
||||||
|
{
|
||||||
|
if (env('APP_DEBUG') == false && $exception instanceof NotFoundHttpException) {
|
||||||
|
return response(view("errors.404"), 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::render($request, $exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
52
app/Models/Word.php
Normal file
52
app/Models/Word.php
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Word extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Indicates if the model should be timestamped.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the route key for the model.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRouteKeyName()
|
||||||
|
{
|
||||||
|
return 'uuid';
|
||||||
|
}
|
||||||
|
|
||||||
|
static public function boot()
|
||||||
|
{
|
||||||
|
static::saving(function($model) {
|
||||||
|
$model->uuid = substr(base64_encode($model->value), 0, 10);
|
||||||
|
});
|
||||||
|
|
||||||
|
parent::boot();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a random row from the table.
|
||||||
|
*
|
||||||
|
* @var mixed $exclude uuid's of rows that should be excluded.
|
||||||
|
*/
|
||||||
|
static public function getRandom($exclude = [])
|
||||||
|
{
|
||||||
|
$q = self::inRandomOrder();
|
||||||
|
|
||||||
|
if (!is_array($exclude)) {
|
||||||
|
$exclude = [ $exclude ];
|
||||||
|
}
|
||||||
|
if (count($exclude) > 1) {
|
||||||
|
$q->where("uuid", 'NOT IN', $exclude);
|
||||||
|
}
|
||||||
|
return $q->first();
|
||||||
|
}
|
||||||
|
}
|
||||||
29
app/Providers/AppServiceProvider.php
Normal file
29
app/Providers/AppServiceProvider.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Blade;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
22
app/View/Helpers.php
Normal file
22
app/View/Helpers.php
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (!function_exists('urlGenerator')) {
|
||||||
|
/**
|
||||||
|
* @return \Laravel\Lumen\Routing\UrlGenerator
|
||||||
|
*/
|
||||||
|
function urlGenerator() {
|
||||||
|
return new \Laravel\Lumen\Routing\UrlGenerator(app());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('asset')) {
|
||||||
|
/**
|
||||||
|
* @param $path
|
||||||
|
* @param bool $secured
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function asset($path, $secured = false) {
|
||||||
|
return urlGenerator()->asset($path, $secured);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
artisan
Normal file
35
artisan
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Input\ArgvInput;
|
||||||
|
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Create The Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| First we need to get an application instance. This creates an instance
|
||||||
|
| of the application / container and bootstraps the application so it
|
||||||
|
| is ready to receive HTTP / Console requests from the environment.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app = require __DIR__.'/bootstrap/app.php';
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Run The Artisan Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When we run the console application, the current CLI command will be
|
||||||
|
| executed in this console and the response sent back to a terminal
|
||||||
|
| or another output device for the developers. Here goes nothing!
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$kernel = $app->make(
|
||||||
|
'Illuminate\Contracts\Console\Kernel'
|
||||||
|
);
|
||||||
|
|
||||||
|
exit($kernel->handle(new ArgvInput, new ConsoleOutput));
|
||||||
113
bootstrap/app.php
Normal file
113
bootstrap/app.php
Normal file
|
|
@ -0,0 +1,113 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/../vendor/autoload.php';
|
||||||
|
|
||||||
|
(new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables(
|
||||||
|
dirname(__DIR__)
|
||||||
|
))->bootstrap();
|
||||||
|
|
||||||
|
date_default_timezone_set(env('APP_TIMEZONE', 'UTC'));
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Create The Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here we will load the environment and create the application instance
|
||||||
|
| that serves as the central piece of this framework. We'll use this
|
||||||
|
| application as an "IoC" container and router for this framework.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app = new Laravel\Lumen\Application(
|
||||||
|
dirname(__DIR__)
|
||||||
|
);
|
||||||
|
|
||||||
|
$app->withFacades();
|
||||||
|
|
||||||
|
$app->withEloquent();
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Container Bindings
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Now we will register a few bindings in the service container. We will
|
||||||
|
| register the exception handler and the console kernel. You may add
|
||||||
|
| your own bindings here if you like or you can make another file.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app->singleton(
|
||||||
|
Illuminate\Contracts\Debug\ExceptionHandler::class,
|
||||||
|
App\Exceptions\Handler::class
|
||||||
|
);
|
||||||
|
|
||||||
|
$app->singleton(
|
||||||
|
Illuminate\Contracts\Console\Kernel::class,
|
||||||
|
App\Console\Kernel::class
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Config Files
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Now we will register the "app" configuration file. If the file exists in
|
||||||
|
| your configuration directory it will be loaded; otherwise, we'll load
|
||||||
|
| the default version. You may register other files below as needed.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app->configure('app');
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Middleware
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Next, we will register the middleware with the application. These can
|
||||||
|
| be global middleware that run before and after each request into a
|
||||||
|
| route or middleware that'll be assigned to some specific routes.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// $app->middleware([
|
||||||
|
// App\Http\Middleware\ExampleMiddleware::class
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
// $app->routeMiddleware([
|
||||||
|
// 'auth' => App\Http\Middleware\Authenticate::class,
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Service Providers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here we will register all of the application's service providers which
|
||||||
|
| are used to bind services into the container. Service providers are
|
||||||
|
| totally optional, so you are not required to uncomment this line.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app->register(App\Providers\AppServiceProvider::class);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Load The Application Routes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Next we will include the routes file so that they can all be added to
|
||||||
|
| the application. This will provide all of the URLs the application
|
||||||
|
| can respond to, as well as the controllers that may handle them.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app->router->group([
|
||||||
|
'namespace' => 'App\Http\Controllers',
|
||||||
|
], function ($router) {
|
||||||
|
require __DIR__.'/../routes/web.php';
|
||||||
|
});
|
||||||
|
|
||||||
|
return $app;
|
||||||
47
composer.json
Normal file
47
composer.json
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
{
|
||||||
|
"name": "laravel/lumen",
|
||||||
|
"description": "The Laravel Lumen Framework.",
|
||||||
|
"keywords": ["framework", "laravel", "lumen"],
|
||||||
|
"license": "MIT",
|
||||||
|
"type": "project",
|
||||||
|
"require": {
|
||||||
|
"php": "^7.2.5",
|
||||||
|
"ext-sqlite3": "^7.2",
|
||||||
|
"laravel/lumen-framework": "^7.0",
|
||||||
|
"league/flysystem": "^1.1",
|
||||||
|
"symfony/yaml": "^5.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"fzaninotto/faker": "^1.9.1",
|
||||||
|
"mockery/mockery": "^1.3.1",
|
||||||
|
"phpunit/phpunit": "^8.5"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"app/View/Helpers.php"
|
||||||
|
],
|
||||||
|
"classmap": [
|
||||||
|
"database/seeds"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"App\\": "app/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"classmap": [
|
||||||
|
"tests/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"preferred-install": "dist",
|
||||||
|
"sort-packages": true,
|
||||||
|
"optimize-autoloader": true
|
||||||
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true,
|
||||||
|
"scripts": {
|
||||||
|
"post-root-package-install": [
|
||||||
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
6406
composer.lock
generated
Normal file
6406
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
BIN
database/database.sqlite
Normal file
BIN
database/database.sqlite
Normal file
Binary file not shown.
0
database/migrations/.gitkeep
Normal file
0
database/migrations/.gitkeep
Normal file
33
database/migrations/2020_09_12_172753_initial.php
Normal file
33
database/migrations/2020_09_12_172753_initial.php
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class Initial extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('words', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->uuid('uuid')->unique()->index();
|
||||||
|
$table->string('value')->unique();
|
||||||
|
$table->enum('type', ['sex', 'yoga']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
17
database/seeds/DatabaseSeeder.php
Normal file
17
database/seeds/DatabaseSeeder.php
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class DatabaseSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$this->call(WordsTableSexSeeder::class);
|
||||||
|
$this->call(WordsTableYogaSeeder::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
46
database/seeds/WordsTableSexSeeder.php
Normal file
46
database/seeds/WordsTableSexSeeder.php
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Word;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class WordsTableSexSeeder extends Seeder
|
||||||
|
{
|
||||||
|
protected $_list = [
|
||||||
|
"Heta stolen",
|
||||||
|
"Den omvända saxen",
|
||||||
|
"Spindeln",
|
||||||
|
"Skeden",
|
||||||
|
"Saxen",
|
||||||
|
"Vattenfall",
|
||||||
|
"Enkel skottkärra",
|
||||||
|
"Svår skottkärra",
|
||||||
|
"Balettdansösen",
|
||||||
|
"Deep Stick",
|
||||||
|
"Fjärilen",
|
||||||
|
"Maneten",
|
||||||
|
"Body guard",
|
||||||
|
"Leg Glider",
|
||||||
|
"Korset",
|
||||||
|
"Arken",
|
||||||
|
"Borren",
|
||||||
|
"Dansaren",
|
||||||
|
"Trappa till himlen",
|
||||||
|
"Kringlan",
|
||||||
|
"Den Stående Draken"
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
foreach($this->_list as $value) {
|
||||||
|
Word::create([
|
||||||
|
'value' => $value,
|
||||||
|
'type' => 'sex'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
38
database/seeds/WordsTableYogaSeeder.php
Normal file
38
database/seeds/WordsTableYogaSeeder.php
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Word;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class WordsTableYogaSeeder extends Seeder
|
||||||
|
{
|
||||||
|
protected $_list = [
|
||||||
|
"Nedåtgående hund",
|
||||||
|
"Högt utfall",
|
||||||
|
"Lågt utfall",
|
||||||
|
"Glada barnet",
|
||||||
|
"Halvmånen",
|
||||||
|
"Sittande halv ryggradsrotation",
|
||||||
|
"Omvänd bordspositon",
|
||||||
|
"Halv stående framåtfällning",
|
||||||
|
"Kråkan",
|
||||||
|
"Kobran",
|
||||||
|
"Bananen",
|
||||||
|
"Fyrsidig Stavposition",
|
||||||
|
"Kopositionen"
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
foreach($this->_list as $value) {
|
||||||
|
Word::create([
|
||||||
|
'value' => $value,
|
||||||
|
'type' => 'yoga'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
public/.htaccess
Normal file
21
public/.htaccess
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<IfModule mod_rewrite.c>
|
||||||
|
<IfModule mod_negotiation.c>
|
||||||
|
Options -MultiViews -Indexes
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
RewriteEngine On
|
||||||
|
|
||||||
|
# Handle Authorization Header
|
||||||
|
RewriteCond %{HTTP:Authorization} .
|
||||||
|
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||||
|
|
||||||
|
# Redirect Trailing Slashes If Not A Folder...
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_URI} (.+)/$
|
||||||
|
RewriteRule ^ %1 [L,R=301]
|
||||||
|
|
||||||
|
# Handle Front Controller...
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteRule ^ index.php [L]
|
||||||
|
</IfModule>
|
||||||
7
public/assets/bootstrap.min.css
vendored
Normal file
7
public/assets/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/assets/bootstrap.min.css.map
Normal file
1
public/assets/bootstrap.min.css.map
Normal file
File diff suppressed because one or more lines are too long
28
public/index.php
Normal file
28
public/index.php
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Create The Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| First we need to get an application instance. This creates an instance
|
||||||
|
| of the application / container and bootstraps the application so it
|
||||||
|
| is ready to receive HTTP / Console requests from the environment.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app = require __DIR__.'/../bootstrap/app.php';
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Run The Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Once we have the application, we can handle the incoming request
|
||||||
|
| through the kernel, and send the associated response back to
|
||||||
|
| the client's browser allowing them to enjoy the creative
|
||||||
|
| and wonderful application we have prepared for them.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app->run();
|
||||||
0
resources/views/.gitkeep
Normal file
0
resources/views/.gitkeep
Normal file
6
resources/views/errors/404.blade.php
Normal file
6
resources/views/errors/404.blade.php
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
@extends('layouts.default')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<h1>404</h2>
|
||||||
|
<a href="/">Gå tillbaka</a>
|
||||||
|
@endsection
|
||||||
18
resources/views/layouts/default.blade.php
Normal file
18
resources/views/layouts/default.blade.php
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<!-- Required meta tags -->
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
|
||||||
|
<!-- Bootstrap CSS -->
|
||||||
|
<link rel="stylesheet" href="{{ asset('/assets/bootstrap.min.css') }}">
|
||||||
|
|
||||||
|
<title></title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container mt-5 p-5 text-center">
|
||||||
|
@yield('content')
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
15
resources/views/main.blade.php
Normal file
15
resources/views/main.blade.php
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
@extends('layouts.default')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<p>Är ordet:</p>
|
||||||
|
<h1 class="mb-5">{{ $word }}</h1>
|
||||||
|
|
||||||
|
<div class="row align-items-center">
|
||||||
|
<div class="col-3 ml-auto">
|
||||||
|
<a href="{{ route("word", ['uuid' => $uuid, 'guess' => 'sex'] ) }}" class="btn btn-block btn-lg btn-info">Sex-ställning</a>
|
||||||
|
</div>
|
||||||
|
<div class="col-3 mr-auto">
|
||||||
|
<a href="{{ route("word", ['uuid' => $uuid, 'guess' => 'yoga'] ) }}" class="btn btn-block btn-lg btn-info">Yoga-övning</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
10
resources/views/result.blade.php
Normal file
10
resources/views/result.blade.php
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
@extends('layouts.default')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<p class="mb-5">
|
||||||
|
Är ordet <strong>{{ $word }}</strong> en <strong>{{ $guess == 'sex' ? 'sex-ställning' : 'yoga-övning' }}</strong>?
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h2 class="{{ $correct ? 'text-success' : 'text-danger' }}">{{ $correct ? 'Ja!' : 'Nej!' }}</h2>
|
||||||
|
<a href="{{ route("word", ['uuid' => $next ]) }}" class="mt-5 btn btn-lg btn-info">Nästa ord</a>
|
||||||
|
@endsection
|
||||||
43
routes/web.php
Normal file
43
routes/web.php
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
use Illuminate\Container\Container;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
use App\Models\Word;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Routes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here is where you can register all of the routes for an application.
|
||||||
|
| It is a breeze. Simply tell Lumen the URIs it should respond to
|
||||||
|
| and give it the Closure to call when that URI is requested.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$router->get('/', function() {
|
||||||
|
return redirect()->route('word', [ 'uuid' => Word::getRandom() ]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$router->get('/{uuid}[/{guess}]', ['as' => 'word', function($uuid, $guess = false) {
|
||||||
|
|
||||||
|
$word = Word::where('uuid', $uuid)->first();
|
||||||
|
if (!$word) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'word' => $word->value
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($guess !== false) {
|
||||||
|
$params['guess'] = $guess;
|
||||||
|
$params['correct'] = $guess === $word->type;
|
||||||
|
$params['next'] = Word::getRandom($uuid);
|
||||||
|
return view('result', $params);
|
||||||
|
}
|
||||||
|
return view('main', $params);
|
||||||
|
}]);
|
||||||
2
storage/app/.gitignore
vendored
Normal file
2
storage/app/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
||||||
3
storage/framework/cache/.gitignore
vendored
Normal file
3
storage/framework/cache/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
*
|
||||||
|
!data/
|
||||||
|
!.gitignore
|
||||||
2
storage/framework/cache/data/.gitignore
vendored
Normal file
2
storage/framework/cache/data/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
||||||
2
storage/framework/views/.gitignore
vendored
Normal file
2
storage/framework/views/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
||||||
2
storage/logs/.gitignore
vendored
Normal file
2
storage/logs/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
||||||
Reference in a new issue