Initial Laravel 12 starter kit

This commit is contained in:
zino
2025-11-16 00:01:06 +01:00
parent 98c77c7df6
commit 7fa25fc80c
63 changed files with 15204 additions and 1 deletions

View File

@@ -0,0 +1,8 @@
<?php
namespace App\Http\Controllers;
abstract class Controller
{
//
}

49
app/Models/User.php Normal file
View File

@@ -0,0 +1,49 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasApiTokens, HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}

View File

@@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\Vite;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider {
/**
* Register any application services.
*/
public function register(): void {
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void {
// Prevents lazy loading
// Prevents silently discarding attributes.
// Prevents accessing missing attributes.
Model::shouldBeStrict();
// Automatically eager-load needed relations.
Model::automaticallyEagerLoadRelationships();
// Force HTTPS for all generated URLs.
URL::forceHttps(
$this->app->environment(['production']),
);
// Prohibits: db:wipe, migrate:fresh, migrate:refresh, and migrate:reset
DB::prohibitDestructiveCommands($this->app->environment(['production']));
// Prefetch all assets at once.
Vite::prefetch();
// Disable resourc wrapping
JsonResource::withoutWrapping();
// Globally rate limit api requests
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(500)
->by($request->user()->id ?? $request->ip())
->response(function () {
return response()->json([
'message' => 'Too many attempts. Try again later.',
], 429);
});
});
}
}