feat(event): add slug field to events and update related resources and routes

This commit is contained in:
2026-09-22 10:32:25 -03:00
parent 03bb7709c4
commit 506f8a5176
8 changed files with 54 additions and 5 deletions

View File

@@ -13,7 +13,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
#[Fillable(['tenant_code', 'event_category_id', 'title', 'subtitle', 'description', 'location', 'exact_location', 'date_text', 'published_at', 'attachment_id'])]
#[Fillable(['tenant_code', 'slug', 'event_category_id', 'title', 'subtitle', 'description', 'location', 'exact_location', 'date_text', 'published_at', 'attachment_id'])]
class Event extends Model
{
use HasFactory;

View File

@@ -17,6 +17,7 @@ class EventResource extends JsonResource
return [
'id' => $this->id,
'slug' => $this->slug,
'title' => $this->title,
'subtitle' => $this->subtitle,
'description' => $this->description,

View File

@@ -14,6 +14,7 @@ class PublicEventResource extends JsonResource
{
return [
'id' => $this->id,
'slug' => $this->slug,
'event_category_id' => $this->event_category_id,
'title' => $this->title,
'subtitle' => $this->subtitle,

View File

@@ -6,9 +6,9 @@ use Illuminate\Support\Facades\Route;
require __DIR__.'/adminapp.php';
Route::prefix('tenants/{tenant:codigo}')->group(function (): void {
Route::prefix('tenants/{tenant:codigo}')->scopeBindings()->group(function (): void {
Route::get('events', [PublicEventController::class, 'index']);
Route::get('events/{event}', [PublicEventController::class, 'show']);
Route::get('events/{event:slug}', [PublicEventController::class, 'show']);
});
Route::middleware('auth:sanctum')->post(