Show results
This commit is contained in:
parent
10376e3b02
commit
b922033f72
6 changed files with 137 additions and 70 deletions
|
|
@ -2,13 +2,31 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Requests\FindAnagramWordsRequest;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
use Lvl0\AnagramFinder\Core\Matcher;
|
||||||
|
|
||||||
class AnagramController extends Controller
|
class AnagramController extends Controller
|
||||||
{
|
{
|
||||||
public function __invoke(Request $request): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
return view('index');
|
return view('index');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function find(FindAnagramWordsRequest $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$anagram = $request->get('anagram');
|
||||||
|
|
||||||
|
return redirect()->route('results', $anagram);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function results(Request $request)
|
||||||
|
{
|
||||||
|
$anagram = $request->anagram;
|
||||||
|
$matches = Matcher::findWords($anagram);
|
||||||
|
|
||||||
|
return view('index', ['anagram' => $anagram, 'matches' => $matches]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
29
app/Http/Requests/FindAnagramWordsRequest.php
Normal file
29
app/Http/Requests/FindAnagramWordsRequest.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class FindAnagramWordsRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.3",
|
"php": "^8.3",
|
||||||
|
"anagram-finder/core": "^0.1.0",
|
||||||
"laravel/chisel": "^0.1.0",
|
"laravel/chisel": "^0.1.0",
|
||||||
"laravel/fortify": "^1.37.2",
|
"laravel/fortify": "^1.37.2",
|
||||||
"laravel/framework": "^13.17",
|
"laravel/framework": "^13.17",
|
||||||
|
|
@ -110,5 +111,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"prefer-stable": true
|
"prefer-stable": true,
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "vcs",
|
||||||
|
"url": "ssh://git@forge.lvl0.xyz:2222/anagram-finder/core.git"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
36
composer.lock
generated
36
composer.lock
generated
|
|
@ -4,8 +4,42 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "09b46aa9ca1844f1ec49d90281d6a76b",
|
"content-hash": "421410120a87c8f8ec2456627557bc36",
|
||||||
"packages": [
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "anagram-finder/core",
|
||||||
|
"version": "v0.1.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "ssh://git@forge.lvl0.xyz:2222/anagram-finder/core.git",
|
||||||
|
"reference": "4b8ce74729fa9a6d0ca91c5d661256ca256e5291"
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"illuminate/collections": "^13.26"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"friendsofphp/php-cs-fixer": "^3.95",
|
||||||
|
"phpunit/phpunit": "^13"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Lvl0\\AnagramFinder\\Core\\": "src/",
|
||||||
|
"Lvl0\\AnagramFinder\\Core\\Tests\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"license": [
|
||||||
|
"AGPL-3.0-only"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "myrmidex",
|
||||||
|
"email": "myrmidex@myrmidex.net"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "AnagramFinder core",
|
||||||
|
"time": "2026-08-22T17:50:27+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "bacon/bacon-qr-code",
|
"name": "bacon/bacon-qr-code",
|
||||||
"version": "v3.1.1",
|
"version": "v3.1.1",
|
||||||
|
|
|
||||||
|
|
@ -50,71 +50,46 @@ class="inline-block px-5 py-1.5 dark:text-[#EDEDEC] border-[#19140035] hover:bor
|
||||||
<div class="flex items-center justify-center w-full transition-opacity opacity-100 duration-750 lg:grow starting:opacity-0">
|
<div class="flex items-center justify-center w-full transition-opacity opacity-100 duration-750 lg:grow starting:opacity-0">
|
||||||
<main class="flex max-w-[335px] w-full flex-col-reverse lg:max-w-4xl lg:flex-row">
|
<main class="flex max-w-[335px] w-full flex-col-reverse lg:max-w-4xl lg:flex-row">
|
||||||
<div class="text-[13px] leading-[20px] flex-1 p-6 pb-12 lg:p-20 bg-white dark:bg-[#161615] dark:text-[#EDEDEC] shadow-[inset_0px_0px_0px_1px_rgba(26,26,0,0.16)] dark:shadow-[inset_0px_0px_0px_1px_#fffaed2d] rounded-es-lg rounded-ee-lg lg:rounded-ss-lg lg:rounded-ee-none">
|
<div class="text-[13px] leading-[20px] flex-1 p-6 pb-12 lg:p-20 bg-white dark:bg-[#161615] dark:text-[#EDEDEC] shadow-[inset_0px_0px_0px_1px_rgba(26,26,0,0.16)] dark:shadow-[inset_0px_0px_0px_1px_#fffaed2d] rounded-es-lg rounded-ee-lg lg:rounded-ss-lg lg:rounded-ee-none">
|
||||||
<h1 class="mb-1 font-medium">Let's get started</h1>
|
<h1 class="mb-1 font-medium">Anagram Finder</h1>
|
||||||
<p class="mb-2 text-[#706f6c] dark:text-[#A1A09A]">Laravel has an incredibly rich ecosystem. <br>We suggest starting with the following.</p>
|
<p class="mb-4 text-[#706f6c] dark:text-[#A1A09A]">Enter your letters to find every word that fits.</p>
|
||||||
<ul class="flex flex-col mb-4 lg:mb-6">
|
|
||||||
<li class="flex items-center gap-4 py-2 relative before:border-l before:border-[#e3e3e0] dark:before:border-[#3E3E3A] before:top-1/2 before:bottom-0 before:left-[0.4rem] before:absolute">
|
<form method="POST" action="{{ route('find') }}" class="flex flex-col gap-4">
|
||||||
<span class="relative py-1 bg-white dark:bg-[#161615]">
|
@csrf
|
||||||
<span class="flex items-center justify-center rounded-full bg-[#FDFDFC] dark:bg-[#161615] shadow-[0px_0px_1px_0px_rgba(0,0,0,0.03),0px_1px_2px_0px_rgba(0,0,0,0.06)] w-3.5 h-3.5 border dark:border-[#3E3E3A] border-[#e3e3e0]">
|
|
||||||
<span class="rounded-full bg-[#dbdbd7] dark:bg-[#3E3E3A] w-1.5 h-1.5"></span>
|
<div class="flex flex-col gap-1.5">
|
||||||
</span>
|
<label for="anagram" class="font-medium">Letters</label>
|
||||||
</span>
|
<input
|
||||||
<span>
|
id="anagram"
|
||||||
Read the
|
name="anagram"
|
||||||
<a href="https://laravel.com/docs" target="_blank" class="inline-flex items-center space-x-1 font-medium underline underline-offset-4 text-[#f53003] dark:text-[#FF4433] ms-1">
|
type="text"
|
||||||
<span>Documentation</span>
|
value="{{ old('anagram', $anagram ?? '') }}"
|
||||||
<svg
|
placeholder="eamstoxil"
|
||||||
width="10"
|
autocomplete="off"
|
||||||
height="11"
|
autofocus
|
||||||
viewBox="0 0 10 11"
|
required
|
||||||
fill="none"
|
class="w-full px-3 py-2 rounded-sm bg-white dark:bg-[#161615] text-[#1b1b18] dark:text-[#EDEDEC] border border-[#19140035] dark:border-[#3E3E3A] hover:border-[#1915014a] dark:hover:border-[#62605b] focus:outline-none focus:border-[#1b1b18] dark:focus:border-[#EDEDEC]"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
>
|
||||||
class="w-2.5 h-2.5"
|
@error('anagram')
|
||||||
>
|
<p class="text-[#f53003] dark:text-[#FF4433]">{{ $message }}</p>
|
||||||
<path
|
@enderror
|
||||||
d="M7.70833 6.95834V2.79167H3.54167M2.5 8L7.5 3.00001"
|
</div>
|
||||||
stroke="currentColor"
|
|
||||||
stroke-linecap="square"
|
<button
|
||||||
/>
|
type="submit"
|
||||||
</svg>
|
class="inline-block px-5 py-1.5 self-start rounded-sm text-sm leading-normal cursor-pointer bg-[#1b1b18] dark:bg-[#eeeeec] text-white dark:text-[#1C1C1A] border border-black border-transparent hover:bg-black dark:hover:bg-white"
|
||||||
</a>
|
>
|
||||||
</span>
|
Find words
|
||||||
</li>
|
</button>
|
||||||
<li class="flex items-center gap-4 py-2 relative before:border-l before:border-[#e3e3e0] dark:before:border-[#3E3E3A] before:bottom-1/2 before:top-0 before:start-[0.4rem] before:absolute">
|
</form>
|
||||||
<span class="relative py-1 bg-white dark:bg-[#161615]">
|
@isset($matches)
|
||||||
<span class="flex items-center justify-center rounded-full bg-[#FDFDFC] dark:bg-[#161615] shadow-[0px_0px_1px_0px_rgba(0,0,0,0.03),0px_1px_2px_0px_rgba(0,0,0,0.06)] w-3.5 h-3.5 border dark:border-[#3E3E3A] border-[#e3e3e0]">
|
<div>
|
||||||
<span class="rounded-full bg-[#dbdbd7] dark:bg-[#3E3E3A] w-1.5 h-1.5"></span>
|
<ul>
|
||||||
</span>
|
@foreach($matches as $match)
|
||||||
</span>
|
<li>{{ $match }} ({{ strlen($match) }})</li>
|
||||||
<span>
|
@endforeach
|
||||||
Watch video tutorials at
|
</ul>
|
||||||
<a href="https://laracasts.com" target="_blank" class="inline-flex items-center space-x-1 font-medium underline underline-offset-4 text-[#f53003] dark:text-[#FF4433] ms-1">
|
</div>
|
||||||
<span>Laracasts</span>
|
@endisset
|
||||||
<svg
|
|
||||||
width="10"
|
|
||||||
height="11"
|
|
||||||
viewBox="0 0 10 11"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
class="w-2.5 h-2.5"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
d="M7.70833 6.95834V2.79167H3.54167M2.5 8L7.5 3.00001"
|
|
||||||
stroke="currentColor"
|
|
||||||
stroke-linecap="square"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</a>
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<ul class="flex gap-3 text-sm leading-normal">
|
|
||||||
<li>
|
|
||||||
<a href="https://cloud.laravel.com" target="_blank" class="inline-block dark:bg-[#eeeeec] dark:border-[#eeeeec] dark:text-[#1C1C1A] dark:hover:bg-white dark:hover:border-white hover:bg-black hover:border-black px-5 py-1.5 bg-[#1b1b18] rounded-sm border border-black text-white text-sm leading-normal">
|
|
||||||
Deploy now
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,11 @@
|
||||||
use App\Http\Controllers\AnagramController;
|
use App\Http\Controllers\AnagramController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::get('/', AnagramController::class)->name('home');
|
Route::controller(AnagramController::class)->group(function () {
|
||||||
|
Route::get('/', 'index')->name('home');
|
||||||
|
Route::post('/', 'find')->name('find');
|
||||||
|
Route::get('/find/{anagram}', 'results')->name('results');
|
||||||
|
});
|
||||||
|
|
||||||
Route::middleware(['auth', 'verified'])->group(function () {
|
Route::middleware(['auth', 'verified'])->group(function () {
|
||||||
Route::view('dashboard', 'dashboard')->name('dashboard');
|
Route::view('dashboard', 'dashboard')->name('dashboard');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue