Create news story form

This commit is contained in:
Matt Young 2025-12-19 09:27:13 -06:00
parent a34940d22c
commit 18a48f5463
9 changed files with 153 additions and 1 deletions

View File

@ -0,0 +1,67 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\NewsStory;
use Illuminate\Http\Request;
class NewsStoryController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
$stories = NewsStory::orderBy('id', 'desc')->paginate(15);
return view('admin.news.index', compact('stories'));
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('admin.news.create');
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*/
public function show(string $id)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(string $id)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(string $id)
{
//
}
}

View File

@ -36,6 +36,10 @@ class Admin extends Component
'name' => 'Audition Etudes',
'link' => route('admin.etudes.index'),
],
[
'name' => 'News Stories',
'link' => route('admin.news.index'),
]
];
}

View File

@ -1,6 +1,7 @@
@import 'tailwindcss';
@layer base {
dl dt {
@apply font-semibold;
}

View File

@ -0,0 +1,48 @@
<x-layout.admin>
<x-card class="max-w-3xl mx-auto">
<x-slot:header class="bg-brand-600!">Create News Story</x-slot:header>
<x-slot:body class="bg-white border border-brand-600">
<x-form method="POST" :action="route('admin.news.store')">
<div>
<x-form.input name="headline" label="Headline"/>
</div>
<div class="mt-3">
<x-form.textarea name="body" label="Body"/>
</div>
<div class="mt-3">
<x-form.radio-group name="active">
<x-slot:label>Status</x-slot:label>
<x-form.radio-group-item id="active" value="true" checked>Active</x-form.radio-group-item>
<x-form.radio-group-item id="draft" value="false">Draft</x-form.radio-group-item>
</x-form.radio-group>
</div>
<div x-data="{ showStartDate: false }" class="mt-3">
<x-form.checkbox name="scheduleStart" x-model="showStartDate" value="true"
label="Schedule Publication"/>
<x-form.input
type="date"
name="start_publication_date"
label=""
:value="now()->toDateString()"
x-show="showStartDate"
x-cloak
/>
</div>
<div x-data="{ showEndDate: false }" class="mt-3">
<x-form.checkbox name="scheduleEnd" x-model="showEndDate" value="true" label="Schedule Removal"/>
<x-form.input
type="date"
name="stop_publication_date"
label=""
x-show="showEndDate"
x-cloak
/>
</div>
<div class="mt-3 text-right">
<x-form.button type="submit">Save Story</x-form.button>
</div>
</x-form>
</x-slot:body>
</x-card>
</x-layout.admin>

View File

@ -0,0 +1,10 @@
<x-layout.admin>
<x-card class="max-w-3xl mx-auto">
<x-slot:header class="bg-brand-600!">News Stories</x-slot:header>
<x-slot:body class="bg-white border border-brand-600">
<div class="text-right">
<x-form.button type="link" :href="route('admin.news.create')">New Story</x-form.button>
</div>
</x-slot:body>
</x-card>
</x-layout.admin>

View File

@ -6,7 +6,7 @@
<div class="group grid size-4 grid-cols-1">
<input id="{{ $id ?? $name }}" type="checkbox" name="{{ $name }}"
{{ $checked ? 'checked' : '' }}
class="col-start-1 row-start-1 appearance-none rounded-sm border border-gray-300 bg-white checked:border-brand-600 checked:bg-brand-600 indeterminate:border-brand-600 indeterminate:bg-brand-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-600 disabled:border-gray-300 disabled:bg-gray-100 disabled:checked:bg-gray-100 dark:border-white/10 dark:bg-white/5 dark:checked:border-brand-500 dark:checked:bg-brand-500 dark:indeterminate:border-brand-500 dark:indeterminate:bg-brand-500 dark:focus-visible:outline-brand-500 dark:disabled:border-white/5 dark:disabled:bg-white/10 dark:disabled:checked:bg-white/10 forced-colors:appearance-auto"/>
{{ $attributes->merge(['class' => 'col-start-1 row-start-1 appearance-none rounded-sm border border-gray-300 bg-white checked:border-brand-600 checked:bg-brand-600 indeterminate:border-brand-600 indeterminate:bg-brand-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-600 disabled:border-gray-300 disabled:bg-gray-100 disabled:checked:bg-gray-100 dark:border-white/10 dark:bg-white/5 dark:checked:border-brand-500 dark:checked:bg-brand-500 dark:indeterminate:border-brand-500 dark:indeterminate:bg-brand-500 dark:focus-visible:outline-brand-500 dark:disabled:border-white/5 dark:disabled:bg-white/10 dark:disabled:checked:bg-white/10 forced-colors:appearance-auto']) }}/>
<svg viewBox="0 0 14 14" fill="none"
class="pointer-events-none col-start-1 row-start-1 size-3.5 self-center justify-self-center stroke-white group-has-disabled:stroke-gray-950/25 dark:group-has-disabled:stroke-white/25">
<path d="M3 8L6 11L11 3.5" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"

View File

@ -0,0 +1,8 @@
@aware(['name'])
@props(['value', 'id'])
<div class="flex items-center">
<input type="radio" name="{{ $name }}" id="{{ $id }}"
value="{{ $value }}" {{ $attributes }}
class="relative size-4 appearance-none rounded-full border border-gray-300 bg-white before:absolute before:inset-1 before:rounded-full before:bg-white not-checked:before:hidden checked:border-indigo-600 checked:bg-indigo-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 disabled:border-gray-300 disabled:bg-gray-100 disabled:before:bg-gray-400 dark:border-white/10 dark:bg-white/5 dark:checked:border-indigo-500 dark:checked:bg-indigo-500 dark:focus-visible:outline-indigo-500 dark:disabled:border-white/5 dark:disabled:bg-white/10 dark:disabled:before:bg-white/20 forced-colors:appearance-auto forced-colors:before:hidden"/>
<label for="{{ $id }}" class="ml-3 block text-sm/6 font-medium text-gray-900 dark:text-white">{{ $slot }}</label>
</div>

View File

@ -0,0 +1,12 @@
@props(['label' => null, 'sublabel' => null, 'name'])
<fieldset>
@if($label)
<legend class="text-sm/6 font-semibold text-gray-900 dark:text-white">{{ $label }}</legend>
@endif
@if($sublabel)
<p class="mt-1 text-sm/6 text-gray-600 dark:text-gray-400">{{ $sublabel }}</p>
@endif
<div class="mt-3 space-y-2">
{{ $slot }}
</div>
</fieldset>

View File

@ -2,6 +2,7 @@
use App\Http\Controllers\Admin\AuditionEtudeController;
use App\Http\Controllers\Admin\DashboardController;
use App\Http\Controllers\Admin\NewsStoryController;
use App\Http\Controllers\Admin\SiteDataController;
use App\Http\Controllers\Admin\UsersController;
use App\Http\Controllers\AuditionInformationPageController;
@ -25,4 +26,5 @@ Route::middleware(['auth'])->prefix('admin')->name('admin.')->group(function ()
Route::get('/', [UsersController::class, 'index'])->name('index');
});
Route::resource('/etudes', AuditionEtudeController::class)->names('etudes');
Route::resource('/news', NewsStoryController::class)->names('news');
});