1. Go to this page and download the library: Download dentro/yalr library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Http\Routes;
use Dentro\Yalr\BaseRoute;
class DefaultRoute extends BaseRoute
{
/**
* Register routes handled by this class.
*
* @return void
*/
public function register(): void
{
// Make an awesome route
}
}
namespace App\Http\Routes;
use Dentro\Yalr\BaseRoute;
class DefaultRoute extends BaseRoute
{
protected string $prefix = 'wonderful';
protected string $name = 'wonderful';
/**
* Register routes handled by this class.
*
* @return void
*/
public function register(): void
{
$this->router->get('/', function () {
return view('welcome');
});
}
}
namespace App\Http\Routes;
use Dentro\Yalr\BaseRoute;
use App\Http\Controllers\HomeController;
class DefaultRoute extends BaseRoute
{
/**
* Register routes handled by this class.
*
* @return void
*/
public function register(): void
{
$this->router->get('/', [
'uses' => $this->uses('index')
]);
}
/**
* Controller used by this route.
*
* @return string
*/
public function controller(): string
{
return HomeController::class;
}
}
namespace App\Http;
use Dentro\Yalr\Contracts\Bindable;
class RouteModelBinding implements Bindable
{
public function __construct(protected Router $router)
{
}
public function bind(): void
{
$this->router->bind('fleet_hash', fn ($value) => Fleet::byHashOrFail($value));
$this->router->bind('office_slug', fn ($value) => Office::query()->where('slug', $value)->firstOrFail());
}
}
namespace App\Http;
use Dentro\Yalr\Contracts\Bindable;
class RouteRateLimiter implements Bindable
{
public function __construct(protected Router $router)
{
}
public function bind(): void
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(360)->by($request->user()?->email.$request->ip());
});
}
}
#[Middleware(['auth:sanctum', 'verified'])]
class DashboardController extends Controller
{
#[Get('dashboard', name: 'dashboard')]
public function index(): Response
{
return Inertia::render('Dashboard');
}
}