initial commit
This commit is contained in:
121
app/Http/Controllers/ContentBriefController.php
Normal file
121
app/Http/Controllers/ContentBriefController.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Enums\ContentStatus;
|
||||
use App\Models\Client;
|
||||
use App\Models\ContentBrief;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class ContentBriefController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{
|
||||
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
||||
|
||||
$columns = collect(ContentStatus::cases())->map(fn (ContentStatus $status) => [
|
||||
'status' => $status,
|
||||
'items' => ContentBrief::with('client')
|
||||
->where('status', $status->value)
|
||||
->orderBy('sort_order')
|
||||
->orderBy('target_date')
|
||||
->get(),
|
||||
]);
|
||||
|
||||
return view('content.index', compact('columns', 'clients'));
|
||||
}
|
||||
|
||||
public function create(): View
|
||||
{
|
||||
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
||||
$statuses = ContentStatus::cases();
|
||||
return view('content.create', compact('clients', 'statuses'));
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'title' => 'required|string|max:255',
|
||||
'client_id' => 'nullable|exists:clients,id',
|
||||
'platform' => 'required|in:instagram,tiktok,youtube',
|
||||
'content_type' => 'required|string|max:50',
|
||||
'status' => 'required|in:drafting,filming,editing,review,posted,archived',
|
||||
'hook' => 'nullable|string',
|
||||
'body' => 'nullable|string',
|
||||
'cta' => 'nullable|string',
|
||||
'script' => 'nullable|string',
|
||||
'caption' => 'nullable|string',
|
||||
'hashtags' => 'nullable|string',
|
||||
'target_date' => 'nullable|date',
|
||||
'notes' => 'nullable|string',
|
||||
]);
|
||||
|
||||
ContentBrief::create($validated);
|
||||
|
||||
return redirect()->route('content.index')
|
||||
->with('success', '🎬 Content brief created!');
|
||||
}
|
||||
|
||||
public function show(ContentBrief $contentBrief): View
|
||||
{
|
||||
$contentBrief->load('client');
|
||||
return view('content.show', ['brief' => $contentBrief]);
|
||||
}
|
||||
|
||||
public function edit(ContentBrief $contentBrief): View
|
||||
{
|
||||
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
||||
$statuses = ContentStatus::cases();
|
||||
$contentBrief->load('client');
|
||||
return view('content.edit', ['brief' => $contentBrief, 'clients' => $clients, 'statuses' => $statuses]);
|
||||
}
|
||||
|
||||
public function update(Request $request, ContentBrief $contentBrief): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'title' => 'required|string|max:255',
|
||||
'client_id' => 'nullable|exists:clients,id',
|
||||
'platform' => 'required|in:instagram,tiktok,youtube',
|
||||
'content_type' => 'required|string|max:50',
|
||||
'status' => 'required|in:drafting,filming,editing,review,posted,archived',
|
||||
'hook' => 'nullable|string',
|
||||
'body' => 'nullable|string',
|
||||
'cta' => 'nullable|string',
|
||||
'script' => 'nullable|string',
|
||||
'caption' => 'nullable|string',
|
||||
'hashtags' => 'nullable|string',
|
||||
'target_date' => 'nullable|date',
|
||||
'posted_date' => 'nullable|date',
|
||||
'posted_url' => 'nullable|url',
|
||||
'notes' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$contentBrief->update($validated);
|
||||
|
||||
return redirect()->route('content.show', $contentBrief)
|
||||
->with('success', '🎬 Content brief updated!');
|
||||
}
|
||||
|
||||
public function destroy(ContentBrief $contentBrief): RedirectResponse
|
||||
{
|
||||
$contentBrief->delete();
|
||||
return redirect()->route('content.index')->with('success', 'Content brief removed.');
|
||||
}
|
||||
|
||||
public function updateStatus(Request $request, ContentBrief $contentBrief): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'status' => 'required|in:drafting,filming,editing,review,posted,archived',
|
||||
'sort_order' => 'nullable|integer',
|
||||
]);
|
||||
|
||||
$contentBrief->update($validated);
|
||||
|
||||
return response()->json(['ok' => true]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user