Add contract management and invoice settings pages
- 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.
This commit is contained in:
@@ -5,8 +5,11 @@ declare(strict_types=1);
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\RateCard;
|
||||
use App\Models\RateCardProfile;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class RateCardController extends Controller
|
||||
@@ -14,7 +17,8 @@ class RateCardController extends Controller
|
||||
public function index(): View
|
||||
{
|
||||
$rateCards = RateCard::orderBy('sort_order')->orderBy('platform')->get();
|
||||
return view('rate-cards.index', compact('rateCards'));
|
||||
$profile = RateCardProfile::getSingleton();
|
||||
return view('rate-cards.index', compact('rateCards', 'profile'));
|
||||
}
|
||||
|
||||
public function create(): View
|
||||
@@ -25,15 +29,15 @@ class RateCardController extends Controller
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'service_name' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'platform' => 'required|in:instagram,tiktok,youtube,general',
|
||||
'content_type' => 'nullable|string|max:50',
|
||||
'price' => 'required|numeric|min:0',
|
||||
'currency' => 'required|string|max:10',
|
||||
'price_unit' => 'required|in:per_content,per_month,per_campaign',
|
||||
'service_name' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'platform' => 'required|in:instagram,tiktok,youtube,general',
|
||||
'content_type' => 'nullable|string|max:50',
|
||||
'price' => 'required|numeric|min:0',
|
||||
'currency' => 'required|string|max:10',
|
||||
'price_unit' => 'required|in:per_content,per_month,per_campaign',
|
||||
'is_negotiable' => 'boolean',
|
||||
'sort_order' => 'nullable|integer',
|
||||
'sort_order' => 'nullable|integer',
|
||||
]);
|
||||
|
||||
$validated['is_negotiable'] = $request->boolean('is_negotiable');
|
||||
@@ -53,16 +57,16 @@ class RateCardController extends Controller
|
||||
public function update(Request $request, RateCard $rateCard): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'service_name' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'platform' => 'required|in:instagram,tiktok,youtube,general',
|
||||
'content_type' => 'nullable|string|max:50',
|
||||
'price' => 'required|numeric|min:0',
|
||||
'currency' => 'required|string|max:10',
|
||||
'price_unit' => 'required|in:per_content,per_month,per_campaign',
|
||||
'service_name' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'platform' => 'required|in:instagram,tiktok,youtube,general',
|
||||
'content_type' => 'nullable|string|max:50',
|
||||
'price' => 'required|numeric|min:0',
|
||||
'currency' => 'required|string|max:10',
|
||||
'price_unit' => 'required|in:per_content,per_month,per_campaign',
|
||||
'is_negotiable' => 'boolean',
|
||||
'is_active' => 'boolean',
|
||||
'sort_order' => 'nullable|integer',
|
||||
'is_active' => 'boolean',
|
||||
'sort_order' => 'nullable|integer',
|
||||
]);
|
||||
|
||||
$validated['is_negotiable'] = $request->boolean('is_negotiable');
|
||||
@@ -80,14 +84,91 @@ class RateCardController extends Controller
|
||||
return redirect()->route('rate-cards.index')->with('success', 'Entry removed.');
|
||||
}
|
||||
|
||||
// ── Public Page ──────────────────────────────────────────────
|
||||
|
||||
public function public(): View
|
||||
{
|
||||
$profile = RateCardProfile::getSingleton();
|
||||
$rateCards = RateCard::where('is_active', true)
|
||||
->orderBy('sort_order')
|
||||
->orderBy('platform')
|
||||
->get()
|
||||
->groupBy('platform');
|
||||
|
||||
return view('rate-cards.public', compact('rateCards'));
|
||||
return view('rate-cards.public', compact('rateCards', 'profile'));
|
||||
}
|
||||
|
||||
// ── Profile Settings ─────────────────────────────────────────
|
||||
|
||||
public function profilePage(): View
|
||||
{
|
||||
$profile = RateCardProfile::getSingleton();
|
||||
return view('rate-cards.profile', compact('profile'));
|
||||
}
|
||||
|
||||
public function profileUpdate(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'owner_name' => 'required|string|max:100',
|
||||
'tagline' => 'nullable|string|max:200',
|
||||
'whatsapp' => 'nullable|string|max:30',
|
||||
'ig_handle' => 'nullable|string|max:60',
|
||||
'tiktok_handle' => 'nullable|string|max:60',
|
||||
'youtube_handle'=> 'nullable|string|max:60',
|
||||
'email' => 'nullable|email|max:150',
|
||||
'bg_color' => 'nullable|string|max:20',
|
||||
'accent_color' => 'nullable|string|max:20',
|
||||
'text_color' => 'nullable|string|max:20',
|
||||
'custom_footer' => 'nullable|string|max:500',
|
||||
'show_prices' => 'boolean',
|
||||
'logo' => 'nullable|image|max:2048',
|
||||
]);
|
||||
|
||||
$profile = RateCardProfile::getSingleton();
|
||||
|
||||
if ($request->hasFile('logo')) {
|
||||
$path = $request->file('logo')->store('profile', 'private');
|
||||
$validated['logo_path'] = $path;
|
||||
}
|
||||
|
||||
$validated['show_prices'] = $request->boolean('show_prices');
|
||||
unset($validated['logo']);
|
||||
|
||||
$profile->update($validated);
|
||||
|
||||
return back()->with('success', '🎨 Profile updated!');
|
||||
}
|
||||
|
||||
public function serveProfileLogo(): Response
|
||||
{
|
||||
$profile = RateCardProfile::getSingleton();
|
||||
|
||||
if (! $profile->logo_path || ! \Storage::disk('private')->exists($profile->logo_path)) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$contents = \Storage::disk('private')->get($profile->logo_path);
|
||||
$mime = \Storage::disk('private')->mimeType($profile->logo_path);
|
||||
|
||||
return response($contents, 200)->header('Content-Type', $mime);
|
||||
}
|
||||
|
||||
// ── PDF Download ─────────────────────────────────────────────
|
||||
|
||||
public function pdf(): \Illuminate\Http\Response
|
||||
{
|
||||
$profile = RateCardProfile::getSingleton();
|
||||
$rateCards = RateCard::where('is_active', true)
|
||||
->orderBy('sort_order')
|
||||
->orderBy('platform')
|
||||
->get()
|
||||
->groupBy('platform');
|
||||
|
||||
$pdf = Pdf::loadView('rate-cards.pdf', compact('rateCards', 'profile'))
|
||||
->setPaper('a4', 'portrait');
|
||||
|
||||
$filename = 'rate-card-' . now()->format('Y-m-d') . '.pdf';
|
||||
|
||||
return $pdf->download($filename);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user