- Created a new Blade view for managing brand contracts with forms for adding and editing contracts, including client and category selection. - Implemented success message notifications for contract actions. - Added a new Blade view for invoice settings, allowing customization of invoice number format, header branding, and default values for new invoices. - Introduced a new PDF view for generating rate cards with customizable styles based on user profile settings. - Developed a profile management page for rate cards, enabling users to update their identity, appearance, and visibility settings.
140 lines
4.9 KiB
PHP
140 lines
4.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Enums\ContentStatus;
|
|
use App\Models\Client;
|
|
use App\Models\ClientCategory;
|
|
use App\Models\ContentBrief;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
class ContentBriefController extends Controller
|
|
{
|
|
private function categoryTree(): \Illuminate\Support\Collection
|
|
{
|
|
return ClientCategory::with('children')
|
|
->whereNull('parent_id')
|
|
->orderBy('sort_order')
|
|
->get();
|
|
}
|
|
|
|
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();
|
|
$categoryTree = $this->categoryTree();
|
|
return view('content.create', compact('clients', 'statuses', 'categoryTree'));
|
|
}
|
|
|
|
public function store(Request $request): RedirectResponse
|
|
{
|
|
$validated = $request->validate([
|
|
'title' => 'required|string|max:255',
|
|
'client_id' => 'nullable|exists:clients,id',
|
|
'category_id' => 'nullable|exists:client_categories,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();
|
|
$categoryTree = $this->categoryTree();
|
|
$contentBrief->load('client');
|
|
return view('content.edit', [
|
|
'brief' => $contentBrief,
|
|
'clients' => $clients,
|
|
'statuses' => $statuses,
|
|
'categoryTree' => $categoryTree,
|
|
]);
|
|
}
|
|
|
|
public function update(Request $request, ContentBrief $contentBrief): RedirectResponse
|
|
{
|
|
$validated = $request->validate([
|
|
'title' => 'required|string|max:255',
|
|
'client_id' => 'nullable|exists:clients,id',
|
|
'category_id' => 'nullable|exists:client_categories,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]);
|
|
}
|
|
}
|