feat: Add accent color to invoice settings and update related views; enhance event creation with brand contract option
This commit is contained in:
@@ -5,12 +5,14 @@ declare(strict_types=1);
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Enums\EventStatus;
|
||||
use App\Models\BrandContract;
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientCategory;
|
||||
use App\Models\Event;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class EventController extends Controller
|
||||
@@ -51,24 +53,41 @@ class EventController extends Controller
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'title' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'client_id' => 'nullable|exists:clients,id',
|
||||
'category_id' => 'nullable|exists:client_categories,id',
|
||||
'event_type' => 'required|in:task,meeting,deadline,posting',
|
||||
'start_time' => 'required|date',
|
||||
'end_time' => 'nullable|date|after:start_time',
|
||||
'location' => 'nullable|string|max:255',
|
||||
'is_priority' => 'boolean',
|
||||
'is_all_day' => 'boolean',
|
||||
'color' => 'nullable|string|max:20',
|
||||
'notes' => 'nullable|string',
|
||||
'title' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'client_id' => 'nullable|exists:clients,id',
|
||||
'category_id' => 'nullable|exists:client_categories,id',
|
||||
'event_type' => 'required|in:task,meeting,deadline,posting',
|
||||
'start_time' => 'required|date',
|
||||
'end_time' => 'nullable|date|after:start_time',
|
||||
'location' => 'nullable|string|max:255',
|
||||
'is_priority' => 'boolean',
|
||||
'is_all_day' => 'boolean',
|
||||
'color' => 'nullable|string|max:20',
|
||||
'notes' => 'nullable|string',
|
||||
'create_brand_contract' => 'nullable|boolean',
|
||||
'contract_title' => 'nullable|string|max:255',
|
||||
'contract_start_date' => 'nullable|date',
|
||||
'contract_end_date' => 'nullable|date|after_or_equal:contract_start_date',
|
||||
]);
|
||||
|
||||
$validated['is_priority'] = $request->boolean('is_priority');
|
||||
$validated['is_all_day'] = $request->boolean('is_all_day');
|
||||
|
||||
Event::create($validated);
|
||||
$event = Event::create(Arr::except($validated, [
|
||||
'create_brand_contract', 'contract_title', 'contract_start_date', 'contract_end_date',
|
||||
]));
|
||||
|
||||
if ($request->boolean('create_brand_contract') && $event->client_id) {
|
||||
BrandContract::create([
|
||||
'title' => $request->input('contract_title') ?: $event->title,
|
||||
'client_id' => $event->client_id,
|
||||
'category_id' => $event->category_id,
|
||||
'start_date' => $request->input('contract_start_date') ?? $event->start_time->toDateString(),
|
||||
'end_date' => $request->input('contract_end_date') ?? ($event->end_time?->toDateString() ?? $event->start_time->toDateString()),
|
||||
'is_active' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->route('schedule.index')
|
||||
->with('success', '🐾 Event scheduled!');
|
||||
@@ -86,22 +105,39 @@ class EventController extends Controller
|
||||
public function update(Request $request, Event $event): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'title' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'client_id' => 'nullable|exists:clients,id',
|
||||
'category_id' => 'nullable|exists:client_categories,id',
|
||||
'event_type' => 'required|in:task,meeting,deadline,posting',
|
||||
'start_time' => 'required|date',
|
||||
'end_time' => 'nullable|date',
|
||||
'location' => 'nullable|string|max:255',
|
||||
'is_priority' => 'boolean',
|
||||
'status' => 'required|in:pending,in_progress,completed,cancelled',
|
||||
'color' => 'nullable|string|max:20',
|
||||
'notes' => 'nullable|string',
|
||||
'title' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'client_id' => 'nullable|exists:clients,id',
|
||||
'category_id' => 'nullable|exists:client_categories,id',
|
||||
'event_type' => 'required|in:task,meeting,deadline,posting',
|
||||
'start_time' => 'required|date',
|
||||
'end_time' => 'nullable|date',
|
||||
'location' => 'nullable|string|max:255',
|
||||
'is_priority' => 'boolean',
|
||||
'status' => 'required|in:pending,in_progress,completed,cancelled',
|
||||
'color' => 'nullable|string|max:20',
|
||||
'notes' => 'nullable|string',
|
||||
'create_brand_contract' => 'nullable|boolean',
|
||||
'contract_title' => 'nullable|string|max:255',
|
||||
'contract_start_date' => 'nullable|date',
|
||||
'contract_end_date' => 'nullable|date|after_or_equal:contract_start_date',
|
||||
]);
|
||||
|
||||
$validated['is_priority'] = $request->boolean('is_priority');
|
||||
$event->update($validated);
|
||||
$event->update(Arr::except($validated, [
|
||||
'create_brand_contract', 'contract_title', 'contract_start_date', 'contract_end_date',
|
||||
]));
|
||||
|
||||
if ($request->boolean('create_brand_contract') && $event->client_id) {
|
||||
BrandContract::create([
|
||||
'title' => $request->input('contract_title') ?: $event->title,
|
||||
'client_id' => $event->client_id,
|
||||
'category_id' => $event->category_id,
|
||||
'start_date' => $request->input('contract_start_date') ?? $event->start_time->toDateString(),
|
||||
'end_date' => $request->input('contract_end_date') ?? ($event->end_time?->toDateString() ?? $event->start_time->toDateString()),
|
||||
'is_active' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->route('schedule.index')
|
||||
->with('success', '🐾 Event updated!');
|
||||
|
||||
@@ -26,6 +26,7 @@ class InvoiceSettingsController extends Controller
|
||||
'header_name' => 'nullable|string|max:100',
|
||||
'header_title' => 'nullable|string|max:150',
|
||||
'header_logo' => 'nullable|image|max:2048',
|
||||
'accent_color' => 'nullable|string|max:20',
|
||||
'default_tax_rate' => 'nullable|numeric|min:0|max:100',
|
||||
'default_currency' => 'nullable|string|max:10',
|
||||
'default_service_description'=> 'nullable|string|max:255',
|
||||
|
||||
@@ -16,6 +16,7 @@ class InvoiceSettings extends Model
|
||||
'header_name',
|
||||
'header_title',
|
||||
'header_logo',
|
||||
'accent_color',
|
||||
'default_tax_rate',
|
||||
'default_currency',
|
||||
'default_service_description',
|
||||
@@ -37,6 +38,7 @@ class InvoiceSettings extends Model
|
||||
return static::firstOrCreate([], [
|
||||
'invoice_prefix' => 'INV',
|
||||
'invoice_next_number' => 1,
|
||||
'accent_color' => '#FFB7C5',
|
||||
'default_tax_rate' => 11,
|
||||
'default_currency' => 'IDR',
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user