Compare commits
8 Commits
e09c8a5fa9
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0b294fa1c | ||
|
|
3f18dbaadf | ||
|
|
1b90f730a6 | ||
|
|
5748b163b6 | ||
|
|
86176c99c7 | ||
|
|
22f03ccca7 | ||
|
|
d3c35ad730 | ||
|
|
1126877ef5 |
@@ -12,7 +12,9 @@
|
|||||||
"Bash(PHP_BIN=\"/c/laragon/bin/php/php-8.3.16-Win32-vs16-x64/php.exe\" cd \"E:/_PERSONAL-PROJECT_/PHP/KOL-Manager\" __NEW_LINE_7c463fa4c32b98a2__ \"$PHP_BIN\" artisan route:list)",
|
"Bash(PHP_BIN=\"/c/laragon/bin/php/php-8.3.16-Win32-vs16-x64/php.exe\" cd \"E:/_PERSONAL-PROJECT_/PHP/KOL-Manager\" __NEW_LINE_7c463fa4c32b98a2__ \"$PHP_BIN\" artisan route:list)",
|
||||||
"Bash(NODE_BIN=\"/c/laragon/bin/nodejs/node-v22\" cd \"E:/_PERSONAL-PROJECT_/PHP/KOL-Manager\" \"$NODE_BIN/node.exe\" \"$NODE_BIN/node_modules/npm/bin/npm-cli.js\" run build)",
|
"Bash(NODE_BIN=\"/c/laragon/bin/nodejs/node-v22\" cd \"E:/_PERSONAL-PROJECT_/PHP/KOL-Manager\" \"$NODE_BIN/node.exe\" \"$NODE_BIN/node_modules/npm/bin/npm-cli.js\" run build)",
|
||||||
"Bash(/c/laragon/bin/nodejs/node-v22/node node_modules/npm/bin/npm-cli.js run build)",
|
"Bash(/c/laragon/bin/nodejs/node-v22/node node_modules/npm/bin/npm-cli.js run build)",
|
||||||
"Bash(/c/laragon/bin/nodejs/node-v22/node /c/laragon/bin/nodejs/node-v22/node_modules/npm/bin/npm-cli.js run build)"
|
"Bash(/c/laragon/bin/nodejs/node-v22/node /c/laragon/bin/nodejs/node-v22/node_modules/npm/bin/npm-cli.js run build)",
|
||||||
|
"Bash(php artisan:*)",
|
||||||
|
"Bash(php -r \":*)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
53
.dockerignore
Normal file
53
.dockerignore
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# ── Git ──────────────────────────────────────
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.gitattributes
|
||||||
|
|
||||||
|
# ── Env files (use .env.docker instead) ─────
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
.env.*.local
|
||||||
|
|
||||||
|
# ── Node / build artifacts ───────────────────
|
||||||
|
node_modules
|
||||||
|
npm-debug.log*
|
||||||
|
|
||||||
|
# ── Laravel local storage (mounted as volume)
|
||||||
|
storage/logs/*
|
||||||
|
storage/framework/cache/*
|
||||||
|
storage/framework/sessions/*
|
||||||
|
storage/framework/views/*
|
||||||
|
storage/app/private/*
|
||||||
|
|
||||||
|
# ── Laravel bootstrap cache ──────────────────
|
||||||
|
bootstrap/cache/*.php
|
||||||
|
|
||||||
|
# ── SQLite database (mounted as volume) ──────
|
||||||
|
database/database.sqlite
|
||||||
|
|
||||||
|
# ── Compiled assets (rebuilt in Dockerfile) ──
|
||||||
|
public/build
|
||||||
|
public/hot
|
||||||
|
|
||||||
|
# ── Local storage symlink (recreated by entrypoint.sh) ──
|
||||||
|
public/storage
|
||||||
|
|
||||||
|
# ── Tests / dev tooling ──────────────────────
|
||||||
|
tests
|
||||||
|
phpunit.xml
|
||||||
|
.editorconfig
|
||||||
|
.php-cs-fixer*
|
||||||
|
|
||||||
|
# ── IDE / OS ─────────────────────────────────
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
*.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# ── Docker config itself ─────────────────────
|
||||||
|
Dockerfile
|
||||||
|
docker-compose*.yml
|
||||||
|
|
||||||
|
# ── Claude / project meta ────────────────────
|
||||||
|
.claude
|
||||||
|
README.md
|
||||||
@@ -4,6 +4,9 @@ APP_KEY=
|
|||||||
APP_DEBUG=true
|
APP_DEBUG=true
|
||||||
APP_URL=http://localhost
|
APP_URL=http://localhost
|
||||||
|
|
||||||
|
# ── App Gate Password ─────────────────────────────────────────────────────────
|
||||||
|
APP_PASSWORD=
|
||||||
|
|
||||||
APP_LOCALE=en
|
APP_LOCALE=en
|
||||||
APP_FALLBACK_LOCALE=en
|
APP_FALLBACK_LOCALE=en
|
||||||
APP_FAKER_LOCALE=en_US
|
APP_FAKER_LOCALE=en_US
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,6 +3,7 @@
|
|||||||
.env
|
.env
|
||||||
.env.backup
|
.env.backup
|
||||||
.env.production
|
.env.production
|
||||||
|
.env.docker
|
||||||
.phpactor.json
|
.phpactor.json
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
/.fleet
|
/.fleet
|
||||||
|
|||||||
120
Dockerfile
Normal file
120
Dockerfile
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# Stage 1 – Build frontend assets (Node)
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
FROM node:22-alpine AS node-builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN npm ci --ignore-scripts
|
||||||
|
|
||||||
|
COPY vite.config.js ./
|
||||||
|
COPY resources/ resources/
|
||||||
|
COPY public/ public/
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# Stage 2 – PHP runtime
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
FROM php:8.3-fpm-alpine AS runtime
|
||||||
|
|
||||||
|
# ── System packages ──────────────────────────
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
nginx \
|
||||||
|
supervisor \
|
||||||
|
sqlite \
|
||||||
|
sqlite-dev \
|
||||||
|
curl \
|
||||||
|
git \
|
||||||
|
unzip \
|
||||||
|
libpng-dev \
|
||||||
|
libjpeg-turbo-dev \
|
||||||
|
freetype-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
libzip-dev \
|
||||||
|
icu-dev \
|
||||||
|
oniguruma-dev
|
||||||
|
|
||||||
|
# ── PHP extensions ───────────────────────────
|
||||||
|
# GD (needed by dompdf for image rendering)
|
||||||
|
RUN docker-php-ext-configure gd \
|
||||||
|
--with-freetype \
|
||||||
|
--with-jpeg \
|
||||||
|
&& docker-php-ext-install -j"$(nproc)" \
|
||||||
|
pdo \
|
||||||
|
pdo_sqlite \
|
||||||
|
mbstring \
|
||||||
|
fileinfo \
|
||||||
|
xml \
|
||||||
|
dom \
|
||||||
|
bcmath \
|
||||||
|
zip \
|
||||||
|
intl \
|
||||||
|
gd \
|
||||||
|
opcache \
|
||||||
|
pcntl
|
||||||
|
|
||||||
|
# ── Composer ─────────────────────────────────
|
||||||
|
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
# ── App directory ────────────────────────────
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
# Install PHP dependencies first (better layer caching)
|
||||||
|
COPY composer.json composer.lock ./
|
||||||
|
RUN composer install \
|
||||||
|
--no-dev \
|
||||||
|
--no-interaction \
|
||||||
|
--no-scripts \
|
||||||
|
--optimize-autoloader \
|
||||||
|
--prefer-dist
|
||||||
|
|
||||||
|
# Copy full application
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Inject compiled frontend assets from Stage 1
|
||||||
|
COPY --from=node-builder /app/public/build public/build/
|
||||||
|
|
||||||
|
# ── Docker helper files ───────────────────────
|
||||||
|
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
||||||
|
COPY docker/supervisord.conf /etc/supervisord.conf
|
||||||
|
COPY docker/entrypoint.sh /entrypoint.sh
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
# ── File system ──────────────────────────────
|
||||||
|
RUN mkdir -p \
|
||||||
|
storage/app/public \
|
||||||
|
storage/app/private/talent-assets \
|
||||||
|
storage/logs \
|
||||||
|
storage/framework/cache \
|
||||||
|
storage/framework/sessions \
|
||||||
|
storage/framework/views \
|
||||||
|
bootstrap/cache \
|
||||||
|
database \
|
||||||
|
&& chown -R www-data:www-data \
|
||||||
|
storage \
|
||||||
|
bootstrap/cache \
|
||||||
|
database \
|
||||||
|
&& chmod -R 775 \
|
||||||
|
storage \
|
||||||
|
bootstrap/cache \
|
||||||
|
database
|
||||||
|
|
||||||
|
# ── PHP-FPM: run as www-data ─────────────────
|
||||||
|
RUN sed -i 's/user = www-data/user = www-data/' /usr/local/etc/php-fpm.d/www.conf 2>/dev/null || true \
|
||||||
|
&& sed -i 's/group = www-data/group = www-data/' /usr/local/etc/php-fpm.d/www.conf 2>/dev/null || true
|
||||||
|
|
||||||
|
# ── OPcache tuning ───────────────────────────
|
||||||
|
RUN { \
|
||||||
|
echo "opcache.enable=1"; \
|
||||||
|
echo "opcache.memory_consumption=128"; \
|
||||||
|
echo "opcache.interned_strings_buffer=8"; \
|
||||||
|
echo "opcache.max_accelerated_files=10000"; \
|
||||||
|
echo "opcache.validate_timestamps=0"; \
|
||||||
|
echo "opcache.fast_shutdown=1"; \
|
||||||
|
} > /usr/local/etc/php/conf.d/opcache.ini
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
6
How-To.txt
Normal file
6
How-To.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
git clone this repository
|
||||||
|
composer install
|
||||||
|
#php artisan key:generate
|
||||||
|
touch database/database.sqlite && php artisan migrate
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
126
app/Http/Controllers/BrandContractController.php
Normal file
126
app/Http/Controllers/BrandContractController.php
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\BrandContract;
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\ClientCategory;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class BrandContractController extends Controller
|
||||||
|
{
|
||||||
|
private function categoryTree(): \Illuminate\Support\Collection
|
||||||
|
{
|
||||||
|
return ClientCategory::with('children')
|
||||||
|
->whereNull('parent_id')
|
||||||
|
->orderBy('sort_order')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(): View
|
||||||
|
{
|
||||||
|
$contracts = BrandContract::with(['client', 'category'])
|
||||||
|
->orderByDesc('end_date')
|
||||||
|
->get();
|
||||||
|
$clients = Client::orderBy('name')->get();
|
||||||
|
$categoryTree = $this->categoryTree();
|
||||||
|
|
||||||
|
return view('contracts.index', compact('contracts', 'clients', 'categoryTree'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'title' => 'required|string|max:255',
|
||||||
|
'client_id' => 'nullable|exists:clients,id',
|
||||||
|
'category_id' => 'required|exists:client_categories,id',
|
||||||
|
'start_date' => 'required|date',
|
||||||
|
'end_date' => 'required|date|after_or_equal:start_date',
|
||||||
|
'notes' => 'nullable|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$validated['is_active'] = true;
|
||||||
|
BrandContract::create($validated);
|
||||||
|
|
||||||
|
return back()->with('success', '📝 Contract added!');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, BrandContract $contract): RedirectResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'title' => 'required|string|max:255',
|
||||||
|
'client_id' => 'nullable|exists:clients,id',
|
||||||
|
'category_id' => 'required|exists:client_categories,id',
|
||||||
|
'start_date' => 'required|date',
|
||||||
|
'end_date' => 'required|date|after_or_equal:start_date',
|
||||||
|
'notes' => 'nullable|string',
|
||||||
|
'is_active' => 'boolean',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$validated['is_active'] = $request->boolean('is_active', $contract->is_active);
|
||||||
|
$contract->update($validated);
|
||||||
|
|
||||||
|
return back()->with('success', '📝 Contract updated!');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(BrandContract $contract): RedirectResponse
|
||||||
|
{
|
||||||
|
$contract->delete();
|
||||||
|
return back()->with('success', '📝 Contract removed.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toggle(BrandContract $contract): RedirectResponse
|
||||||
|
{
|
||||||
|
$contract->update(['is_active' => ! $contract->is_active]);
|
||||||
|
return back()->with('success', $contract->is_active ? '✅ Contract activated.' : '⏸️ Contract paused.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AJAX: check if a category has an active exclusive contract.
|
||||||
|
* Returns null if clear, or contract details if blocked.
|
||||||
|
*/
|
||||||
|
public function check(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$categoryId = $request->integer('category_id');
|
||||||
|
$clientId = $request->integer('client_id');
|
||||||
|
|
||||||
|
if (! $categoryId) {
|
||||||
|
return response()->json(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collect the category and its parent chain (so blocking a parent also blocks children)
|
||||||
|
$category = ClientCategory::find($categoryId);
|
||||||
|
$checkIds = [$categoryId];
|
||||||
|
if ($category?->parent_id) {
|
||||||
|
$checkIds[] = $category->parent_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$contract = BrandContract::with(['client', 'category'])
|
||||||
|
->active()
|
||||||
|
->whereIn('category_id', $checkIds)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (! $contract) {
|
||||||
|
return response()->json(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow if it's the contracted brand itself
|
||||||
|
if ($clientId && $contract->client_id && $contract->client_id === $clientId) {
|
||||||
|
return response()->json(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'id' => $contract->id,
|
||||||
|
'title' => $contract->title,
|
||||||
|
'client_name' => $contract->client?->name ?? 'Unknown',
|
||||||
|
'category' => $contract->category?->name ?? 'Unknown',
|
||||||
|
'end_date' => $contract->end_date->format('d M Y'),
|
||||||
|
'days_left' => $contract->days_remaining,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
79
app/Http/Controllers/ClientCategoryController.php
Normal file
79
app/Http/Controllers/ClientCategoryController.php
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\ClientCategory;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ClientCategoryController extends Controller
|
||||||
|
{
|
||||||
|
public function index(): \Illuminate\View\View
|
||||||
|
{
|
||||||
|
$categories = ClientCategory::with('children', 'parent')
|
||||||
|
->withCount('clients')
|
||||||
|
->orderBy('sort_order')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$parents = ClientCategory::whereNull('parent_id')
|
||||||
|
->orderBy('sort_order')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return view('categories.index', compact('categories', 'parents'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'name' => 'required|string|max:100',
|
||||||
|
'parent_id' => 'nullable|exists:client_categories,id',
|
||||||
|
'icon' => 'nullable|string|max:10',
|
||||||
|
'color' => 'nullable|string|max:20',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Auto slug
|
||||||
|
$validated['slug'] = \Illuminate\Support\Str::slug($validated['name']);
|
||||||
|
|
||||||
|
// If slug conflicts, suffix with random
|
||||||
|
if (ClientCategory::where('slug', $validated['slug'])->exists()) {
|
||||||
|
$validated['slug'] .= '-' . substr(uniqid(), -4);
|
||||||
|
}
|
||||||
|
|
||||||
|
ClientCategory::create($validated);
|
||||||
|
|
||||||
|
return back()->with('success', '🏷️ Category added!');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, ClientCategory $category): RedirectResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'name' => 'required|string|max:100',
|
||||||
|
'parent_id' => 'nullable|exists:client_categories,id',
|
||||||
|
'icon' => 'nullable|string|max:10',
|
||||||
|
'color' => 'nullable|string|max:20',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Prevent a category from being its own parent
|
||||||
|
if (isset($validated['parent_id']) && $validated['parent_id'] == $category->id) {
|
||||||
|
$validated['parent_id'] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$category->update($validated);
|
||||||
|
|
||||||
|
return back()->with('success', '🏷️ Category updated!');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(ClientCategory $category): RedirectResponse
|
||||||
|
{
|
||||||
|
// Reassign children to the parent
|
||||||
|
$category->children()->update(['parent_id' => $category->parent_id]);
|
||||||
|
// Detach clients
|
||||||
|
$category->clients()->update(['category_id' => null]);
|
||||||
|
|
||||||
|
$category->delete();
|
||||||
|
|
||||||
|
return back()->with('success', '🏷️ Category removed.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,25 +6,63 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
use App\Enums\ClientStatus;
|
use App\Enums\ClientStatus;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
|
use App\Models\ClientCategory;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
class ClientController extends Controller
|
class ClientController extends Controller
|
||||||
{
|
{
|
||||||
public function index(): View
|
private function categoryTree(): \Illuminate\Support\Collection
|
||||||
{
|
{
|
||||||
$clients = Client::withCount(['invoices', 'events', 'contentBriefs'])
|
return ClientCategory::with('children')
|
||||||
->latest()
|
->whereNull('parent_id')
|
||||||
->paginate(12);
|
->orderBy('sort_order')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
return view('clients.index', compact('clients'));
|
private function flatCategories(): \Illuminate\Support\Collection
|
||||||
|
{
|
||||||
|
$flat = collect();
|
||||||
|
foreach ($this->categoryTree() as $parent) {
|
||||||
|
$flat->push($parent);
|
||||||
|
foreach ($parent->children as $child) {
|
||||||
|
$flat->push($child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $flat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request): View
|
||||||
|
{
|
||||||
|
$query = Client::with('category')
|
||||||
|
->withCount(['invoices', 'events', 'contentBriefs'])
|
||||||
|
->latest();
|
||||||
|
|
||||||
|
if ($request->filled('category')) {
|
||||||
|
$query->where('category_id', $request->category);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->filled('status')) {
|
||||||
|
$query->where('status', $request->status);
|
||||||
|
}
|
||||||
|
|
||||||
|
$clients = $query->paginate(12)->withQueryString();
|
||||||
|
$categories = $this->categoryTree();
|
||||||
|
$statuses = ClientStatus::cases();
|
||||||
|
|
||||||
|
return view('clients.index', compact('clients', 'categories', 'statuses'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create(): View
|
public function create(): View
|
||||||
{
|
{
|
||||||
$statuses = ClientStatus::cases();
|
$statuses = ClientStatus::cases();
|
||||||
return view('clients.create', compact('statuses'));
|
$categories = $this->flatCategories();
|
||||||
|
$categoryTree = $this->categoryTree();
|
||||||
|
|
||||||
|
return view('clients.create', compact('statuses', 'categories', 'categoryTree'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request): RedirectResponse
|
public function store(Request $request): RedirectResponse
|
||||||
@@ -44,6 +82,7 @@ class ClientController extends Controller
|
|||||||
'postal_code' => 'nullable|string|max:20',
|
'postal_code' => 'nullable|string|max:20',
|
||||||
'country' => 'nullable|string|max:100',
|
'country' => 'nullable|string|max:100',
|
||||||
'status' => 'required|in:active,inactive,prospect',
|
'status' => 'required|in:active,inactive,prospect',
|
||||||
|
'category_id' => 'nullable|exists:client_categories,id',
|
||||||
'notes' => 'nullable|string',
|
'notes' => 'nullable|string',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -55,10 +94,13 @@ class ClientController extends Controller
|
|||||||
|
|
||||||
public function show(Client $client): View
|
public function show(Client $client): View
|
||||||
{
|
{
|
||||||
$client->load(['events' => fn ($q) => $q->latest()->limit(5)]);
|
$client->load([
|
||||||
$client->load(['invoices' => fn ($q) => $q->latest()->limit(5)]);
|
'category',
|
||||||
$client->load(['contentBriefs' => fn ($q) => $q->latest()->limit(5)]);
|
'events' => fn ($q) => $q->latest()->limit(5),
|
||||||
$client->load(['mediaFiles' => fn ($q) => $q->latest()->limit(10)]);
|
'invoices' => fn ($q) => $q->latest()->limit(5),
|
||||||
|
'contentBriefs'=> fn ($q) => $q->latest()->limit(5),
|
||||||
|
'mediaFiles' => fn ($q) => $q->latest()->limit(10),
|
||||||
|
]);
|
||||||
|
|
||||||
return view('clients.show', compact('client'));
|
return view('clients.show', compact('client'));
|
||||||
}
|
}
|
||||||
@@ -66,7 +108,10 @@ class ClientController extends Controller
|
|||||||
public function edit(Client $client): View
|
public function edit(Client $client): View
|
||||||
{
|
{
|
||||||
$statuses = ClientStatus::cases();
|
$statuses = ClientStatus::cases();
|
||||||
return view('clients.edit', compact('client', 'statuses'));
|
$categories = $this->flatCategories();
|
||||||
|
$categoryTree = $this->categoryTree();
|
||||||
|
|
||||||
|
return view('clients.edit', compact('client', 'statuses', 'categories', 'categoryTree'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Request $request, Client $client): RedirectResponse
|
public function update(Request $request, Client $client): RedirectResponse
|
||||||
@@ -86,6 +131,7 @@ class ClientController extends Controller
|
|||||||
'postal_code' => 'nullable|string|max:20',
|
'postal_code' => 'nullable|string|max:20',
|
||||||
'country' => 'nullable|string|max:100',
|
'country' => 'nullable|string|max:100',
|
||||||
'status' => 'required|in:active,inactive,prospect',
|
'status' => 'required|in:active,inactive,prospect',
|
||||||
|
'category_id' => 'nullable|exists:client_categories,id',
|
||||||
'notes' => 'nullable|string',
|
'notes' => 'nullable|string',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -102,4 +148,42 @@ class ClientController extends Controller
|
|||||||
return redirect()->route('clients.index')
|
return redirect()->route('clients.index')
|
||||||
->with('success', '🐱 Client removed.');
|
->with('success', '🐱 Client removed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function quickStore(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'email' => 'nullable|email|unique:clients,email',
|
||||||
|
'phone' => 'nullable|string|max:50',
|
||||||
|
'company' => 'nullable|string|max:255',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$client = Client::create(array_merge($validated, ['status' => 'active']));
|
||||||
|
|
||||||
|
return response()->json(['id' => $client->id, 'name' => $client->name]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function uploadAvatar(Request $request, Client $client): JsonResponse
|
||||||
|
{
|
||||||
|
$request->validate(['avatar' => 'required|image|max:2048']);
|
||||||
|
|
||||||
|
if ($client->avatar) {
|
||||||
|
Storage::disk('public')->delete($client->avatar);
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $request->file('avatar')->store('client-avatars', 'public');
|
||||||
|
$client->update(['avatar' => $path]);
|
||||||
|
|
||||||
|
return response()->json(['url' => asset('storage/' . $path)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteAvatar(Client $client): JsonResponse
|
||||||
|
{
|
||||||
|
if ($client->avatar) {
|
||||||
|
Storage::disk('public')->delete($client->avatar);
|
||||||
|
$client->update(['avatar' => null]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['ok' => true]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
use App\Enums\ContentStatus;
|
use App\Enums\ContentStatus;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
|
use App\Models\ClientCategory;
|
||||||
use App\Models\ContentBrief;
|
use App\Models\ContentBrief;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
@@ -14,6 +15,14 @@ use Illuminate\View\View;
|
|||||||
|
|
||||||
class ContentBriefController extends Controller
|
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
|
public function index(): View
|
||||||
{
|
{
|
||||||
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
||||||
@@ -34,7 +43,8 @@ class ContentBriefController extends Controller
|
|||||||
{
|
{
|
||||||
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
||||||
$statuses = ContentStatus::cases();
|
$statuses = ContentStatus::cases();
|
||||||
return view('content.create', compact('clients', 'statuses'));
|
$categoryTree = $this->categoryTree();
|
||||||
|
return view('content.create', compact('clients', 'statuses', 'categoryTree'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request): RedirectResponse
|
public function store(Request $request): RedirectResponse
|
||||||
@@ -42,6 +52,7 @@ class ContentBriefController extends Controller
|
|||||||
$validated = $request->validate([
|
$validated = $request->validate([
|
||||||
'title' => 'required|string|max:255',
|
'title' => 'required|string|max:255',
|
||||||
'client_id' => 'nullable|exists:clients,id',
|
'client_id' => 'nullable|exists:clients,id',
|
||||||
|
'category_id' => 'nullable|exists:client_categories,id',
|
||||||
'platform' => 'required|in:instagram,tiktok,youtube',
|
'platform' => 'required|in:instagram,tiktok,youtube',
|
||||||
'content_type' => 'required|string|max:50',
|
'content_type' => 'required|string|max:50',
|
||||||
'status' => 'required|in:drafting,filming,editing,review,posted,archived',
|
'status' => 'required|in:drafting,filming,editing,review,posted,archived',
|
||||||
@@ -71,8 +82,14 @@ class ContentBriefController extends Controller
|
|||||||
{
|
{
|
||||||
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
||||||
$statuses = ContentStatus::cases();
|
$statuses = ContentStatus::cases();
|
||||||
|
$categoryTree = $this->categoryTree();
|
||||||
$contentBrief->load('client');
|
$contentBrief->load('client');
|
||||||
return view('content.edit', ['brief' => $contentBrief, 'clients' => $clients, 'statuses' => $statuses]);
|
return view('content.edit', [
|
||||||
|
'brief' => $contentBrief,
|
||||||
|
'clients' => $clients,
|
||||||
|
'statuses' => $statuses,
|
||||||
|
'categoryTree' => $categoryTree,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Request $request, ContentBrief $contentBrief): RedirectResponse
|
public function update(Request $request, ContentBrief $contentBrief): RedirectResponse
|
||||||
@@ -80,6 +97,7 @@ class ContentBriefController extends Controller
|
|||||||
$validated = $request->validate([
|
$validated = $request->validate([
|
||||||
'title' => 'required|string|max:255',
|
'title' => 'required|string|max:255',
|
||||||
'client_id' => 'nullable|exists:clients,id',
|
'client_id' => 'nullable|exists:clients,id',
|
||||||
|
'category_id' => 'nullable|exists:client_categories,id',
|
||||||
'platform' => 'required|in:instagram,tiktok,youtube',
|
'platform' => 'required|in:instagram,tiktok,youtube',
|
||||||
'content_type' => 'required|string|max:50',
|
'content_type' => 'required|string|max:50',
|
||||||
'status' => 'required|in:drafting,filming,editing,review,posted,archived',
|
'status' => 'required|in:drafting,filming,editing,review,posted,archived',
|
||||||
|
|||||||
@@ -4,20 +4,42 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Enums\ContentStatus;
|
||||||
use App\Enums\EventStatus;
|
use App\Enums\EventStatus;
|
||||||
|
use App\Models\BrandContract;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
|
use App\Models\ClientCategory;
|
||||||
|
use App\Models\ContentBrief;
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
class EventController extends Controller
|
class EventController extends Controller
|
||||||
{
|
{
|
||||||
|
private function categoryTree(): \Illuminate\Support\Collection
|
||||||
|
{
|
||||||
|
return ClientCategory::with('children')
|
||||||
|
->whereNull('parent_id')
|
||||||
|
->orderBy('sort_order')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
||||||
|
$categoryTree = $this->categoryTree();
|
||||||
|
|
||||||
|
return view('schedule.create', compact('clients', 'categoryTree'));
|
||||||
|
}
|
||||||
|
|
||||||
public function index(): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
$events = Event::with('client')->orderBy('start_time')->get();
|
$events = Event::with('client')->orderBy('start_time')->get();
|
||||||
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
||||||
|
$categoryTree = $this->categoryTree();
|
||||||
|
|
||||||
// Format for FullCalendar
|
// Format for FullCalendar
|
||||||
$calendarEvents = $events->map(fn (Event $e) => [
|
$calendarEvents = $events->map(fn (Event $e) => [
|
||||||
@@ -35,7 +57,7 @@ class EventController extends Controller
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return view('schedule.index', compact('events', 'clients', 'calendarEvents'));
|
return view('schedule.index', compact('events', 'clients', 'calendarEvents', 'categoryTree'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request): RedirectResponse
|
public function store(Request $request): RedirectResponse
|
||||||
@@ -44,6 +66,7 @@ class EventController extends Controller
|
|||||||
'title' => 'required|string|max:255',
|
'title' => 'required|string|max:255',
|
||||||
'description' => 'nullable|string',
|
'description' => 'nullable|string',
|
||||||
'client_id' => 'nullable|exists:clients,id',
|
'client_id' => 'nullable|exists:clients,id',
|
||||||
|
'category_id' => 'nullable|exists:client_categories,id',
|
||||||
'event_type' => 'required|in:task,meeting,deadline,posting',
|
'event_type' => 'required|in:task,meeting,deadline,posting',
|
||||||
'start_time' => 'required|date',
|
'start_time' => 'required|date',
|
||||||
'end_time' => 'nullable|date|after:start_time',
|
'end_time' => 'nullable|date|after:start_time',
|
||||||
@@ -52,23 +75,67 @@ class EventController extends Controller
|
|||||||
'is_all_day' => 'boolean',
|
'is_all_day' => 'boolean',
|
||||||
'color' => 'nullable|string|max:20',
|
'color' => 'nullable|string|max:20',
|
||||||
'notes' => 'nullable|string',
|
'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',
|
||||||
|
'add_to_content_board' => 'nullable|boolean',
|
||||||
|
'content_platform' => 'nullable|string|max:50',
|
||||||
|
'content_type' => 'nullable|string|max:50',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$validated['is_priority'] = $request->boolean('is_priority');
|
$validated['is_priority'] = $request->boolean('is_priority');
|
||||||
$validated['is_all_day'] = $request->boolean('is_all_day');
|
$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',
|
||||||
|
'add_to_content_board', 'content_platform', 'content_type',
|
||||||
|
]));
|
||||||
|
|
||||||
|
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,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->boolean('add_to_content_board')) {
|
||||||
|
ContentBrief::create([
|
||||||
|
'title' => $event->title,
|
||||||
|
'client_id' => $event->client_id,
|
||||||
|
'category_id' => $event->category_id,
|
||||||
|
'platform' => $request->input('content_platform', 'instagram'),
|
||||||
|
'content_type' => $request->input('content_type', 'post'),
|
||||||
|
'status' => ContentStatus::Drafting,
|
||||||
|
'target_date' => $event->start_time->toDateString(),
|
||||||
|
'notes' => $event->notes,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
return redirect()->route('schedule.index')
|
return redirect()->route('schedule.index')
|
||||||
->with('success', '🐾 Event scheduled!');
|
->with('success', '🐾 Event scheduled!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function edit(Event $event): View
|
||||||
|
{
|
||||||
|
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
||||||
|
$statuses = EventStatus::cases();
|
||||||
|
$categoryTree = $this->categoryTree();
|
||||||
|
|
||||||
|
return view('schedule.edit', compact('event', 'clients', 'statuses', 'categoryTree'));
|
||||||
|
}
|
||||||
|
|
||||||
public function update(Request $request, Event $event): RedirectResponse
|
public function update(Request $request, Event $event): RedirectResponse
|
||||||
{
|
{
|
||||||
$validated = $request->validate([
|
$validated = $request->validate([
|
||||||
'title' => 'required|string|max:255',
|
'title' => 'required|string|max:255',
|
||||||
'description' => 'nullable|string',
|
'description' => 'nullable|string',
|
||||||
'client_id' => 'nullable|exists:clients,id',
|
'client_id' => 'nullable|exists:clients,id',
|
||||||
|
'category_id' => 'nullable|exists:client_categories,id',
|
||||||
'event_type' => 'required|in:task,meeting,deadline,posting',
|
'event_type' => 'required|in:task,meeting,deadline,posting',
|
||||||
'start_time' => 'required|date',
|
'start_time' => 'required|date',
|
||||||
'end_time' => 'nullable|date',
|
'end_time' => 'nullable|date',
|
||||||
@@ -77,10 +144,27 @@ class EventController extends Controller
|
|||||||
'status' => 'required|in:pending,in_progress,completed,cancelled',
|
'status' => 'required|in:pending,in_progress,completed,cancelled',
|
||||||
'color' => 'nullable|string|max:20',
|
'color' => 'nullable|string|max:20',
|
||||||
'notes' => 'nullable|string',
|
'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_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')
|
return redirect()->route('schedule.index')
|
||||||
->with('success', '🐾 Event updated!');
|
->with('success', '🐾 Event updated!');
|
||||||
|
|||||||
44
app/Http/Controllers/GateController.php
Normal file
44
app/Http/Controllers/GateController.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class GateController extends Controller
|
||||||
|
{
|
||||||
|
public function login(): View
|
||||||
|
{
|
||||||
|
return view('gate.login');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function attempt(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'password' => 'required|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$expected = config('app.password');
|
||||||
|
|
||||||
|
if (! $expected || $request->input('password') !== $expected) {
|
||||||
|
return back()->withErrors(['password' => 'Wrong password. Please try again.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store flag in session; expires with session lifetime (24 h in .env)
|
||||||
|
$request->session()->put('gate_authenticated', true);
|
||||||
|
$request->session()->regenerate();
|
||||||
|
|
||||||
|
return redirect()->intended(route('dashboard'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logout(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->session()->forget('gate_authenticated');
|
||||||
|
$request->session()->regenerate();
|
||||||
|
|
||||||
|
return redirect()->route('gate.login');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ namespace App\Http\Controllers;
|
|||||||
use App\Enums\InvoiceStatus;
|
use App\Enums\InvoiceStatus;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
use App\Models\InvoiceSettings;
|
||||||
use App\Services\InvoiceService;
|
use App\Services\InvoiceService;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -29,7 +30,8 @@ class InvoiceController extends Controller
|
|||||||
{
|
{
|
||||||
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
||||||
$statuses = InvoiceStatus::cases();
|
$statuses = InvoiceStatus::cases();
|
||||||
return view('invoices.create', compact('clients', 'statuses'));
|
$invoiceSettings = InvoiceSettings::instance();
|
||||||
|
return view('invoices.create', compact('clients', 'statuses', 'invoiceSettings'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request): RedirectResponse
|
public function store(Request $request): RedirectResponse
|
||||||
@@ -46,10 +48,12 @@ class InvoiceController extends Controller
|
|||||||
'bank_name' => 'nullable|string|max:100',
|
'bank_name' => 'nullable|string|max:100',
|
||||||
'bank_account' => 'nullable|string|max:50',
|
'bank_account' => 'nullable|string|max:50',
|
||||||
'bank_holder' => 'nullable|string|max:100',
|
'bank_holder' => 'nullable|string|max:100',
|
||||||
|
'branch_name' => 'nullable|string|max:100',
|
||||||
'items' => 'required|array|min:1',
|
'items' => 'required|array|min:1',
|
||||||
'items.*.description' => 'required|string',
|
'items.*.description' => 'required|string',
|
||||||
'items.*.quantity' => 'required|integer|min:1',
|
'items.*.quantity' => 'required|integer|min:1',
|
||||||
'items.*.unit_price' => 'required|numeric|min:0',
|
'items.*.unit_price' => 'required|numeric|min:0',
|
||||||
|
'items.*.is_taxable' => 'nullable|boolean',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$items = $validated['items'];
|
$items = $validated['items'];
|
||||||
@@ -65,15 +69,17 @@ class InvoiceController extends Controller
|
|||||||
public function show(Invoice $invoice): View
|
public function show(Invoice $invoice): View
|
||||||
{
|
{
|
||||||
$invoice->load('client', 'items');
|
$invoice->load('client', 'items');
|
||||||
return view('invoices.show', compact('invoice'));
|
$invoiceSettings = InvoiceSettings::instance();
|
||||||
|
return view('invoices.show', compact('invoice', 'invoiceSettings'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit(Invoice $invoice): View
|
public function edit(Invoice $invoice): View
|
||||||
{
|
{
|
||||||
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
$clients = Client::where('status', 'active')->orderBy('name')->get();
|
||||||
$statuses = InvoiceStatus::cases();
|
$statuses = InvoiceStatus::cases();
|
||||||
|
$invoiceSettings = InvoiceSettings::instance();
|
||||||
$invoice->load('client', 'items');
|
$invoice->load('client', 'items');
|
||||||
return view('invoices.edit', compact('invoice', 'clients', 'statuses'));
|
return view('invoices.edit', compact('invoice', 'clients', 'statuses', 'invoiceSettings'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Request $request, Invoice $invoice): RedirectResponse
|
public function update(Request $request, Invoice $invoice): RedirectResponse
|
||||||
@@ -91,10 +97,12 @@ class InvoiceController extends Controller
|
|||||||
'bank_name' => 'nullable|string|max:100',
|
'bank_name' => 'nullable|string|max:100',
|
||||||
'bank_account' => 'nullable|string|max:50',
|
'bank_account' => 'nullable|string|max:50',
|
||||||
'bank_holder' => 'nullable|string|max:100',
|
'bank_holder' => 'nullable|string|max:100',
|
||||||
|
'branch_name' => 'nullable|string|max:100',
|
||||||
'items' => 'required|array|min:1',
|
'items' => 'required|array|min:1',
|
||||||
'items.*.description' => 'required|string',
|
'items.*.description' => 'required|string',
|
||||||
'items.*.quantity' => 'required|integer|min:1',
|
'items.*.quantity' => 'required|integer|min:1',
|
||||||
'items.*.unit_price' => 'required|numeric|min:0',
|
'items.*.unit_price' => 'required|numeric|min:0',
|
||||||
|
'items.*.is_taxable' => 'nullable|boolean',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$items = $validated['items'];
|
$items = $validated['items'];
|
||||||
|
|||||||
88
app/Http/Controllers/InvoiceSettingsController.php
Normal file
88
app/Http/Controllers/InvoiceSettingsController.php
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\InvoiceSettings;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class InvoiceSettingsController extends Controller
|
||||||
|
{
|
||||||
|
public function edit(): View
|
||||||
|
{
|
||||||
|
$settings = InvoiceSettings::instance();
|
||||||
|
return view('invoices.settings', compact('settings'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'invoice_prefix' => 'required|string|max:20',
|
||||||
|
'invoice_next_number' => 'required|integer|min:1',
|
||||||
|
'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',
|
||||||
|
'default_bank_name' => 'nullable|string|max:100',
|
||||||
|
'default_branch_name' => 'nullable|string|max:100',
|
||||||
|
'default_bank_account' => 'nullable|string|max:50',
|
||||||
|
'default_bank_holder' => 'nullable|string|max:100',
|
||||||
|
'default_notes' => 'nullable|string|max:1000',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$settings = InvoiceSettings::instance();
|
||||||
|
|
||||||
|
if ($request->hasFile('header_logo')) {
|
||||||
|
// Delete old logo if exists
|
||||||
|
if ($settings->header_logo) {
|
||||||
|
Storage::disk('public')->delete($settings->header_logo);
|
||||||
|
}
|
||||||
|
$path = $request->file('header_logo')->store('invoice-logos', 'public');
|
||||||
|
$validated['header_logo'] = $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
$settings->update($validated);
|
||||||
|
|
||||||
|
return redirect()->route('invoice-settings.edit')
|
||||||
|
->with('success', '🧾 Invoice settings saved!');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function uploadLogo(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$request->validate(['header_logo' => 'required|image|max:2048']);
|
||||||
|
|
||||||
|
$settings = InvoiceSettings::instance();
|
||||||
|
|
||||||
|
if ($settings->header_logo) {
|
||||||
|
Storage::disk('public')->delete($settings->header_logo);
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $request->file('header_logo')->store('invoice-logos', 'public');
|
||||||
|
$settings->update(['header_logo' => $path]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'url' => asset('storage/' . $path),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteLogo(): RedirectResponse
|
||||||
|
{
|
||||||
|
$settings = InvoiceSettings::instance();
|
||||||
|
|
||||||
|
if ($settings->header_logo) {
|
||||||
|
Storage::disk('public')->delete($settings->header_logo);
|
||||||
|
$settings->update(['header_logo' => null]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('invoice-settings.edit')
|
||||||
|
->with('success', '🗑️ Logo removed.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -41,7 +41,7 @@ class MediaFileController extends Controller
|
|||||||
return view('files.index', compact('files', 'folders', 'folder', 'clients'));
|
return view('files.index', compact('files', 'folders', 'folder', 'clients'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request): RedirectResponse
|
public function store(Request $request): RedirectResponse|\Illuminate\Http\JsonResponse
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'file' => 'required|file|max:51200', // 50 MB
|
'file' => 'required|file|max:51200', // 50 MB
|
||||||
@@ -55,6 +55,10 @@ class MediaFileController extends Controller
|
|||||||
$request->input('client_id')
|
$request->input('client_id')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($request->expectsJson() || $request->ajax()) {
|
||||||
|
return response()->json(['success' => true, 'message' => 'File uploaded successfully!']);
|
||||||
|
}
|
||||||
|
|
||||||
return back()->with('success', '📁 File uploaded successfully!');
|
return back()->with('success', '📁 File uploaded successfully!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
64
app/Http/Controllers/NoteController.php
Normal file
64
app/Http/Controllers/NoteController.php
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Note;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class NoteController extends Controller
|
||||||
|
{
|
||||||
|
public function index(): View
|
||||||
|
{
|
||||||
|
$notes = Note::orderByDesc('is_pinned')
|
||||||
|
->orderByDesc('updated_at')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return view('notes.index', compact('notes'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'title' => 'required|string|max:255',
|
||||||
|
'content' => 'nullable|array',
|
||||||
|
'color' => 'nullable|string|max:20',
|
||||||
|
'is_pinned' => 'boolean',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$note = Note::create($data);
|
||||||
|
|
||||||
|
return response()->json($note, 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, Note $note): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'title' => 'required|string|max:255',
|
||||||
|
'content' => 'nullable|array',
|
||||||
|
'color' => 'nullable|string|max:20',
|
||||||
|
'is_pinned' => 'boolean',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$note->update($data);
|
||||||
|
|
||||||
|
return response()->json($note);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Note $note): JsonResponse
|
||||||
|
{
|
||||||
|
$note->delete();
|
||||||
|
|
||||||
|
return response()->json(['ok' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function togglePin(Note $note): JsonResponse
|
||||||
|
{
|
||||||
|
$note->update(['is_pinned' => ! $note->is_pinned]);
|
||||||
|
|
||||||
|
return response()->json($note);
|
||||||
|
}
|
||||||
|
}
|
||||||
97
app/Http/Controllers/NotificationSettingController.php
Normal file
97
app/Http/Controllers/NotificationSettingController.php
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\NotificationSetting;
|
||||||
|
use App\Services\NotificationDispatcher;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class NotificationSettingController extends Controller
|
||||||
|
{
|
||||||
|
public function index(): View
|
||||||
|
{
|
||||||
|
$settings = NotificationSetting::orderBy('channel')->orderBy('name')->get();
|
||||||
|
|
||||||
|
return view('settings.notifications', compact('settings'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'name' => 'required|string|max:100',
|
||||||
|
'channel' => 'required|in:email,telegram,whatsapp',
|
||||||
|
'triggers' => 'nullable|array',
|
||||||
|
'triggers.*' => 'in:upcoming_event,invoice_due,content_due',
|
||||||
|
'notify_before_hours' => 'nullable|integer|min:1|max:720',
|
||||||
|
// Email
|
||||||
|
'config.to_email' => 'required_if:channel,email|nullable|email',
|
||||||
|
// Telegram
|
||||||
|
'config.bot_token' => 'required_if:channel,telegram|nullable|string',
|
||||||
|
'config.chat_id' => 'nullable|string',
|
||||||
|
// WhatsApp (WAHA)
|
||||||
|
'config.waha_endpoint' => 'required_if:channel,whatsapp|nullable|url',
|
||||||
|
'config.waha_session' => 'nullable|string',
|
||||||
|
'config.api_key' => 'nullable|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
NotificationSetting::create([
|
||||||
|
'name' => $validated['name'],
|
||||||
|
'channel' => $validated['channel'],
|
||||||
|
'config' => $request->input('config', []), // pass raw config — not stripped by validation
|
||||||
|
'triggers' => $validated['triggers'] ?? [],
|
||||||
|
'notify_before_hours' => $validated['notify_before_hours'] ?? 24,
|
||||||
|
'is_enabled' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->with('success', '🔔 Notification channel added!');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, NotificationSetting $setting): RedirectResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'name' => 'required|string|max:100',
|
||||||
|
'triggers' => 'nullable|array',
|
||||||
|
'triggers.*' => 'in:upcoming_event,invoice_due,content_due',
|
||||||
|
'notify_before_hours' => 'nullable|integer|min:1|max:720',
|
||||||
|
'config' => 'nullable|array',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$setting->update([
|
||||||
|
'name' => $validated['name'],
|
||||||
|
'triggers' => $validated['triggers'] ?? [],
|
||||||
|
'notify_before_hours' => $validated['notify_before_hours'] ?? $setting->notify_before_hours,
|
||||||
|
'config' => $request->input('config', $setting->config), // use raw input so no keys are stripped
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->with('success', '🔔 Notification updated!');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(NotificationSetting $setting): RedirectResponse
|
||||||
|
{
|
||||||
|
$setting->delete();
|
||||||
|
|
||||||
|
return back()->with('success', '🔔 Channel removed.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toggle(NotificationSetting $setting): RedirectResponse
|
||||||
|
{
|
||||||
|
$setting->update(['is_enabled' => ! $setting->is_enabled]);
|
||||||
|
|
||||||
|
return back()->with('success', $setting->is_enabled ? '🔔 Enabled!' : '🔕 Disabled.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test(NotificationSetting $setting): RedirectResponse
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
app(NotificationDispatcher::class)->sendTest($setting);
|
||||||
|
return back()->with('success', '✅ Test notification sent!');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return back()->with('error', '❌ Failed: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,8 +5,11 @@ declare(strict_types=1);
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\RateCard;
|
use App\Models\RateCard;
|
||||||
|
use App\Models\RateCardProfile;
|
||||||
|
use Barryvdh\DomPDF\Facade\Pdf;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
class RateCardController extends Controller
|
class RateCardController extends Controller
|
||||||
@@ -14,7 +17,8 @@ class RateCardController extends Controller
|
|||||||
public function index(): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
$rateCards = RateCard::orderBy('sort_order')->orderBy('platform')->get();
|
$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
|
public function create(): View
|
||||||
@@ -80,14 +84,91 @@ class RateCardController extends Controller
|
|||||||
return redirect()->route('rate-cards.index')->with('success', 'Entry removed.');
|
return redirect()->route('rate-cards.index')->with('success', 'Entry removed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Public Page ──────────────────────────────────────────────
|
||||||
|
|
||||||
public function public(): View
|
public function public(): View
|
||||||
{
|
{
|
||||||
|
$profile = RateCardProfile::getSingleton();
|
||||||
$rateCards = RateCard::where('is_active', true)
|
$rateCards = RateCard::where('is_active', true)
|
||||||
->orderBy('sort_order')
|
->orderBy('sort_order')
|
||||||
->orderBy('platform')
|
->orderBy('platform')
|
||||||
->get()
|
->get()
|
||||||
->groupBy('platform');
|
->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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
143
app/Http/Controllers/SearchController.php
Normal file
143
app/Http/Controllers/SearchController.php
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\ContentBrief;
|
||||||
|
use App\Models\Event;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\RateCard;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class SearchController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request): View
|
||||||
|
{
|
||||||
|
$q = trim($request->get('q', ''));
|
||||||
|
$results = $q ? $this->search($q) : [];
|
||||||
|
|
||||||
|
return view('search.index', compact('q', 'results'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Quick AJAX endpoint — returns grouped results for the dropdown */
|
||||||
|
public function quick(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$q = trim($request->get('q', ''));
|
||||||
|
|
||||||
|
if (strlen($q) < 2) {
|
||||||
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($this->search($q, limit: 5));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function search(string $q, int $limit = 20): array
|
||||||
|
{
|
||||||
|
$groups = [];
|
||||||
|
$like = "%{$q}%";
|
||||||
|
|
||||||
|
// ── Clients ──────────────────────────────────────────────
|
||||||
|
$clients = Client::where('name', 'LIKE', $like)
|
||||||
|
->orWhere('email', 'LIKE', $like)
|
||||||
|
->orWhere('company', 'LIKE', $like)
|
||||||
|
->orWhere('ig_handle', 'LIKE', $like)
|
||||||
|
->orWhere('tiktok_handle', 'LIKE', $like)
|
||||||
|
->limit($limit)->get();
|
||||||
|
|
||||||
|
if ($clients->isNotEmpty()) {
|
||||||
|
$groups[] = [
|
||||||
|
'type' => 'clients',
|
||||||
|
'label' => '👥 Clients',
|
||||||
|
'items' => $clients->map(fn ($c) => [
|
||||||
|
'icon' => '👥',
|
||||||
|
'title' => $c->name,
|
||||||
|
'subtitle' => collect([$c->company, $c->email])->filter()->implode(' · '),
|
||||||
|
'url' => route('clients.show', $c),
|
||||||
|
])->values()->all(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Events ───────────────────────────────────────────────
|
||||||
|
$events = Event::with('client')
|
||||||
|
->where('title', 'LIKE', $like)
|
||||||
|
->orWhere('description', 'LIKE', $like)
|
||||||
|
->orWhere('location', 'LIKE', $like)
|
||||||
|
->limit($limit)->get();
|
||||||
|
|
||||||
|
if ($events->isNotEmpty()) {
|
||||||
|
$groups[] = [
|
||||||
|
'type' => 'events',
|
||||||
|
'label' => '📅 Events',
|
||||||
|
'items' => $events->map(fn ($e) => [
|
||||||
|
'icon' => '📅',
|
||||||
|
'title' => $e->title,
|
||||||
|
'subtitle' => $e->start_time->format('d M Y') . ($e->client ? ' · ' . $e->client->name : ''),
|
||||||
|
'url' => route('schedule.index'),
|
||||||
|
])->values()->all(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Invoices ─────────────────────────────────────────────
|
||||||
|
$invoices = Invoice::with('client')
|
||||||
|
->where('invoice_number', 'LIKE', $like)
|
||||||
|
->orWhere('title', 'LIKE', $like)
|
||||||
|
->limit($limit)->get();
|
||||||
|
|
||||||
|
if ($invoices->isNotEmpty()) {
|
||||||
|
$groups[] = [
|
||||||
|
'type' => 'invoices',
|
||||||
|
'label' => '🧾 Invoices',
|
||||||
|
'items' => $invoices->map(fn ($i) => [
|
||||||
|
'icon' => '🧾',
|
||||||
|
'title' => $i->invoice_number . ($i->title ? ' — ' . $i->title : ''),
|
||||||
|
'subtitle' => ($i->client?->name ?? '') . ' · ' . ($i->formatted_total ?? ''),
|
||||||
|
'url' => route('invoices.show', $i),
|
||||||
|
])->values()->all(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Content Briefs ───────────────────────────────────────
|
||||||
|
$content = ContentBrief::with('client')
|
||||||
|
->where('title', 'LIKE', $like)
|
||||||
|
->orWhere('description', 'LIKE', $like)
|
||||||
|
->orWhere('platform', 'LIKE', $like)
|
||||||
|
->limit($limit)->get();
|
||||||
|
|
||||||
|
if ($content->isNotEmpty()) {
|
||||||
|
$groups[] = [
|
||||||
|
'type' => 'content',
|
||||||
|
'label' => '🎬 Content',
|
||||||
|
'items' => $content->map(fn ($c) => [
|
||||||
|
'icon' => $c->platform_icon ?? '🎬',
|
||||||
|
'title' => $c->title,
|
||||||
|
'subtitle' => ucfirst($c->platform) . ($c->client ? ' · ' . $c->client->name : ''),
|
||||||
|
'url' => route('content.show', $c),
|
||||||
|
])->values()->all(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Rate Cards ───────────────────────────────────────────
|
||||||
|
$rateCards = RateCard::where('service_name', 'LIKE', $like)
|
||||||
|
->orWhere('description', 'LIKE', $like)
|
||||||
|
->limit($limit)->get();
|
||||||
|
|
||||||
|
if ($rateCards->isNotEmpty()) {
|
||||||
|
$groups[] = [
|
||||||
|
'type' => 'rate-cards',
|
||||||
|
'label' => '💰 Rate Cards',
|
||||||
|
'items' => $rateCards->map(fn ($r) => [
|
||||||
|
'icon' => '💰',
|
||||||
|
'title' => $r->service_name,
|
||||||
|
'subtitle' => $r->description ?? '',
|
||||||
|
'url' => route('rate-cards.edit', $r),
|
||||||
|
])->values()->all(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $groups;
|
||||||
|
}
|
||||||
|
}
|
||||||
26
app/Http/Middleware/GateAuth.php
Normal file
26
app/Http/Middleware/GateAuth.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class GateAuth
|
||||||
|
{
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
// Allow the login routes through without auth check
|
||||||
|
if ($request->routeIs('gate.login', 'gate.attempt', 'gate.logout')) {
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $request->session()->get('gate_authenticated')) {
|
||||||
|
return redirect()->route('gate.login');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
75
app/Models/BrandContract.php
Normal file
75
app/Models/BrandContract.php
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class BrandContract extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'title', 'client_id', 'category_id',
|
||||||
|
'start_date', 'end_date', 'notes', 'is_active',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'start_date' => 'date',
|
||||||
|
'end_date' => 'date',
|
||||||
|
'is_active' => 'boolean',
|
||||||
|
];
|
||||||
|
|
||||||
|
// ── Relationships ────────────────────────────────────────────
|
||||||
|
|
||||||
|
public function client(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Client::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function category(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(ClientCategory::class, 'category_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Scopes ───────────────────────────────────────────────────
|
||||||
|
|
||||||
|
public function scopeActive($query)
|
||||||
|
{
|
||||||
|
return $query->where('is_active', true)
|
||||||
|
->where('start_date', '<=', today())
|
||||||
|
->where('end_date', '>=', today());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Helpers ──────────────────────────────────────────────────
|
||||||
|
|
||||||
|
public function isCurrentlyActive(): bool
|
||||||
|
{
|
||||||
|
return $this->is_active
|
||||||
|
&& $this->start_date->lte(today())
|
||||||
|
&& $this->end_date->gte(today());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDaysRemainingAttribute(): int
|
||||||
|
{
|
||||||
|
return (int) max(0, today()->diffInDays($this->end_date, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStatusLabelAttribute(): string
|
||||||
|
{
|
||||||
|
if (! $this->is_active) return 'Inactive';
|
||||||
|
if ($this->start_date->gt(today())) return 'Upcoming';
|
||||||
|
if ($this->end_date->lt(today())) return 'Expired';
|
||||||
|
return 'Active';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStatusColorAttribute(): string
|
||||||
|
{
|
||||||
|
return match ($this->statusLabel) {
|
||||||
|
'Active' => 'badge-success',
|
||||||
|
'Upcoming' => 'badge-info',
|
||||||
|
'Expired' => 'badge-neutral',
|
||||||
|
default => 'badge-ghost',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ namespace App\Models;
|
|||||||
use App\Enums\ClientStatus;
|
use App\Enums\ClientStatus;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
@@ -18,13 +19,20 @@ class Client extends Model
|
|||||||
'name', 'email', 'phone', 'company',
|
'name', 'email', 'phone', 'company',
|
||||||
'ig_handle', 'tiktok_handle', 'youtube_handle',
|
'ig_handle', 'tiktok_handle', 'youtube_handle',
|
||||||
'address_line1', 'address_line2', 'city', 'state', 'postal_code', 'country',
|
'address_line1', 'address_line2', 'city', 'state', 'postal_code', 'country',
|
||||||
'status', 'notes', 'avatar',
|
'status', 'category_id', 'notes', 'avatar',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'status' => ClientStatus::class,
|
'status' => ClientStatus::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// ── Relationships ────────────────────────────────────────────
|
||||||
|
|
||||||
|
public function category(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(ClientCategory::class, 'category_id');
|
||||||
|
}
|
||||||
|
|
||||||
public function events(): HasMany
|
public function events(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(Event::class);
|
return $this->hasMany(Event::class);
|
||||||
@@ -45,6 +53,8 @@ class Client extends Model
|
|||||||
return $this->hasMany(MediaFile::class);
|
return $this->hasMany(MediaFile::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Accessors ────────────────────────────────────────────────
|
||||||
|
|
||||||
public function getFullAddressAttribute(): string
|
public function getFullAddressAttribute(): string
|
||||||
{
|
{
|
||||||
return collect([
|
return collect([
|
||||||
|
|||||||
74
app/Models/ClientCategory.php
Normal file
74
app/Models/ClientCategory.php
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class ClientCategory extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'name', 'slug', 'parent_id', 'icon', 'color',
|
||||||
|
'description', 'is_system', 'sort_order',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'is_system' => 'boolean',
|
||||||
|
'sort_order' => 'integer',
|
||||||
|
];
|
||||||
|
|
||||||
|
// ── Relationships ────────────────────────────────────────────
|
||||||
|
|
||||||
|
public function parent(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(ClientCategory::class, 'parent_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function children(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(ClientCategory::class, 'parent_id')->orderBy('sort_order');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clients(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Client::class, 'category_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Scopes ───────────────────────────────────────────────────
|
||||||
|
|
||||||
|
public function scopeRoots($query)
|
||||||
|
{
|
||||||
|
return $query->whereNull('parent_id')->orderBy('sort_order');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeTopLevel($query)
|
||||||
|
{
|
||||||
|
return $query->whereNull('parent_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Accessors ────────────────────────────────────────────────
|
||||||
|
|
||||||
|
public function getFullNameAttribute(): string
|
||||||
|
{
|
||||||
|
return $this->parent
|
||||||
|
? $this->parent->name . ' › ' . $this->name
|
||||||
|
: $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Events ───────────────────────────────────────────────────
|
||||||
|
|
||||||
|
protected static function boot(): void
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
static::creating(function (ClientCategory $cat): void {
|
||||||
|
if (empty($cat->slug)) {
|
||||||
|
$cat->slug = Str::slug($cat->name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ class ContentBrief extends Model
|
|||||||
use HasFactory, SoftDeletes;
|
use HasFactory, SoftDeletes;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'client_id', 'title', 'platform', 'content_type', 'status',
|
'client_id', 'category_id', 'title', 'platform', 'content_type', 'status',
|
||||||
'hook', 'body', 'cta', 'script', 'caption', 'hashtags',
|
'hook', 'body', 'cta', 'script', 'caption', 'hashtags',
|
||||||
'target_date', 'posted_date', 'posted_url', 'sort_order', 'notes',
|
'target_date', 'posted_date', 'posted_url', 'sort_order', 'notes',
|
||||||
];
|
];
|
||||||
@@ -31,6 +31,11 @@ class ContentBrief extends Model
|
|||||||
return $this->belongsTo(Client::class);
|
return $this->belongsTo(Client::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function category(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(ClientCategory::class, 'category_id');
|
||||||
|
}
|
||||||
|
|
||||||
public function getPlatformIconAttribute(): string
|
public function getPlatformIconAttribute(): string
|
||||||
{
|
{
|
||||||
return match($this->platform) {
|
return match($this->platform) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Event extends Model
|
|||||||
use HasFactory, SoftDeletes;
|
use HasFactory, SoftDeletes;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'client_id', 'title', 'description', 'event_type',
|
'client_id', 'category_id', 'title', 'description', 'event_type',
|
||||||
'start_time', 'end_time', 'location', 'is_priority',
|
'start_time', 'end_time', 'location', 'is_priority',
|
||||||
'is_all_day', 'status', 'color', 'notes',
|
'is_all_day', 'status', 'color', 'notes',
|
||||||
];
|
];
|
||||||
@@ -33,6 +33,11 @@ class Event extends Model
|
|||||||
return $this->belongsTo(Client::class);
|
return $this->belongsTo(Client::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function category(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(ClientCategory::class, 'category_id');
|
||||||
|
}
|
||||||
|
|
||||||
public function scopeUpcoming($query, int $hours = 24)
|
public function scopeUpcoming($query, int $hours = 24)
|
||||||
{
|
{
|
||||||
return $query->where('start_time', '>=', now())
|
return $query->where('start_time', '>=', now())
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace App\Models;
|
|||||||
|
|
||||||
use App\Enums\InvoiceStatus;
|
use App\Enums\InvoiceStatus;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
// InvoiceSettings used for number generation
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
@@ -19,7 +20,7 @@ class Invoice extends Model
|
|||||||
'client_id', 'invoice_number', 'title', 'description',
|
'client_id', 'invoice_number', 'title', 'description',
|
||||||
'subtotal', 'tax_rate', 'tax_amount', 'total', 'currency',
|
'subtotal', 'tax_rate', 'tax_amount', 'total', 'currency',
|
||||||
'status', 'issue_date', 'due_date', 'paid_date', 'notes',
|
'status', 'issue_date', 'due_date', 'paid_date', 'notes',
|
||||||
'bank_name', 'bank_account', 'bank_holder',
|
'bank_name', 'bank_account', 'bank_holder', 'branch_name',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
@@ -45,9 +46,15 @@ class Invoice extends Model
|
|||||||
|
|
||||||
public function recalculate(): void
|
public function recalculate(): void
|
||||||
{
|
{
|
||||||
|
// Total of all items (what the creator receives)
|
||||||
$this->subtotal = $this->items->sum('total');
|
$this->subtotal = $this->items->sum('total');
|
||||||
$this->tax_amount = round($this->subtotal * ($this->tax_rate / 100), 2);
|
|
||||||
$this->total = $this->subtotal + $this->tax_amount;
|
// Tax is calculated only on taxable items, but paid by the client on top
|
||||||
|
$taxableSubtotal = $this->items->where('is_taxable', true)->sum('total');
|
||||||
|
$this->tax_amount = round((float) $taxableSubtotal * ($this->tax_rate / 100), 2);
|
||||||
|
|
||||||
|
// Grand total = subtotal (creator's fee, pre-tax — tax is borne by client separately)
|
||||||
|
$this->total = $this->subtotal;
|
||||||
$this->save();
|
$this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,8 +65,6 @@ class Invoice extends Model
|
|||||||
|
|
||||||
public static function generateNumber(): string
|
public static function generateNumber(): string
|
||||||
{
|
{
|
||||||
$prefix = 'INV-' . now()->format('Ym');
|
return InvoiceSettings::generateNumber();
|
||||||
$last = static::where('invoice_number', 'like', $prefix . '%')->count();
|
|
||||||
return $prefix . '-' . str_pad((string) ($last + 1), 3, '0', STR_PAD_LEFT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||||||
|
|
||||||
class InvoiceItem extends Model
|
class InvoiceItem extends Model
|
||||||
{
|
{
|
||||||
protected $fillable = ['invoice_id', 'description', 'quantity', 'unit_price', 'total'];
|
protected $fillable = ['invoice_id', 'description', 'quantity', 'unit_price', 'total', 'is_taxable'];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'unit_price' => 'decimal:2',
|
'unit_price' => 'decimal:2',
|
||||||
'total' => 'decimal:2',
|
'total' => 'decimal:2',
|
||||||
|
'is_taxable' => 'boolean',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function invoice(): BelongsTo
|
public function invoice(): BelongsTo
|
||||||
|
|||||||
56
app/Models/InvoiceSettings.php
Normal file
56
app/Models/InvoiceSettings.php
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class InvoiceSettings extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'invoice_settings';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'invoice_prefix',
|
||||||
|
'invoice_next_number',
|
||||||
|
'header_name',
|
||||||
|
'header_title',
|
||||||
|
'header_logo',
|
||||||
|
'accent_color',
|
||||||
|
'default_tax_rate',
|
||||||
|
'default_currency',
|
||||||
|
'default_service_description',
|
||||||
|
'default_bank_name',
|
||||||
|
'default_branch_name',
|
||||||
|
'default_bank_account',
|
||||||
|
'default_bank_holder',
|
||||||
|
'default_notes',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'invoice_next_number' => 'integer',
|
||||||
|
'default_tax_rate' => 'decimal:2',
|
||||||
|
];
|
||||||
|
|
||||||
|
/** Always return the single settings row, creating it if absent. */
|
||||||
|
public static function instance(): self
|
||||||
|
{
|
||||||
|
return static::firstOrCreate([], [
|
||||||
|
'invoice_prefix' => 'INV',
|
||||||
|
'invoice_next_number' => 1,
|
||||||
|
'accent_color' => '#FFB7C5',
|
||||||
|
'default_tax_rate' => 11,
|
||||||
|
'default_currency' => 'IDR',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Generate the next invoice number and increment the counter. */
|
||||||
|
public static function generateNumber(): string
|
||||||
|
{
|
||||||
|
$settings = static::instance();
|
||||||
|
$prefix = rtrim($settings->invoice_prefix, '-');
|
||||||
|
$number = str_pad((string) $settings->invoice_next_number, 3, '0', STR_PAD_LEFT);
|
||||||
|
$settings->increment('invoice_next_number');
|
||||||
|
return $prefix . '-' . $number;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -41,6 +41,11 @@ class MediaFile extends Model
|
|||||||
return str_starts_with($this->mime_type, 'image/');
|
return str_starts_with($this->mime_type, 'image/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getIsVideoAttribute(): bool
|
||||||
|
{
|
||||||
|
return str_starts_with($this->mime_type, 'video/');
|
||||||
|
}
|
||||||
|
|
||||||
public function getIconAttribute(): string
|
public function getIconAttribute(): string
|
||||||
{
|
{
|
||||||
if ($this->is_image) return '🖼️';
|
if ($this->is_image) return '🖼️';
|
||||||
|
|||||||
22
app/Models/Note.php
Normal file
22
app/Models/Note.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Note extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'title',
|
||||||
|
'content',
|
||||||
|
'color',
|
||||||
|
'is_pinned',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'content' => 'array',
|
||||||
|
'is_pinned' => 'boolean',
|
||||||
|
];
|
||||||
|
}
|
||||||
53
app/Models/NotificationSetting.php
Normal file
53
app/Models/NotificationSetting.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class NotificationSetting extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'name', 'channel', 'config', 'triggers',
|
||||||
|
'is_enabled', 'notify_before_hours',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'config' => 'array',
|
||||||
|
'triggers' => 'array',
|
||||||
|
'is_enabled' => 'boolean',
|
||||||
|
'notify_before_hours' => 'integer',
|
||||||
|
];
|
||||||
|
|
||||||
|
// ── Channel icons/labels ─────────────────────────────────────
|
||||||
|
|
||||||
|
public static array $channelMeta = [
|
||||||
|
'email' => ['icon' => '✉️', 'label' => 'Email', 'color' => '#AEC6CF'],
|
||||||
|
'telegram' => ['icon' => '✈️', 'label' => 'Telegram', 'color' => '#E8D5F5'],
|
||||||
|
'whatsapp' => ['icon' => '💬', 'label' => 'WhatsApp', 'color' => '#B5EAD7'],
|
||||||
|
];
|
||||||
|
|
||||||
|
public function getChannelIconAttribute(): string
|
||||||
|
{
|
||||||
|
return static::$channelMeta[$this->channel]['icon'] ?? '🔔';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getChannelLabelAttribute(): string
|
||||||
|
{
|
||||||
|
return static::$channelMeta[$this->channel]['label'] ?? ucfirst($this->channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Trigger helpers ──────────────────────────────────────────
|
||||||
|
|
||||||
|
public static array $triggerMeta = [
|
||||||
|
'upcoming_event' => ['icon' => '📅', 'label' => 'Upcoming Events'],
|
||||||
|
'invoice_due' => ['icon' => '🧾', 'label' => 'Invoice Due Date'],
|
||||||
|
'content_due' => ['icon' => '🎬', 'label' => 'Content Target Date'],
|
||||||
|
];
|
||||||
|
|
||||||
|
public function hasTrigger(string $trigger): bool
|
||||||
|
{
|
||||||
|
return in_array($trigger, $this->triggers ?? []);
|
||||||
|
}
|
||||||
|
}
|
||||||
47
app/Models/RateCardProfile.php
Normal file
47
app/Models/RateCardProfile.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class RateCardProfile extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'owner_name', 'tagline', 'whatsapp',
|
||||||
|
'ig_handle', 'tiktok_handle', 'youtube_handle', 'email',
|
||||||
|
'logo_path', 'bg_color', 'accent_color', 'text_color',
|
||||||
|
'custom_footer', 'show_prices', 'access_token',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'show_prices' => 'boolean',
|
||||||
|
];
|
||||||
|
|
||||||
|
/** Get the singleton profile, creating defaults if needed */
|
||||||
|
public static function getSingleton(): self
|
||||||
|
{
|
||||||
|
return static::firstOrCreate([], [
|
||||||
|
'owner_name' => config('app.name', 'KOL Manager'),
|
||||||
|
'bg_color' => '#FFF8F0',
|
||||||
|
'accent_color' => '#FFB7C5',
|
||||||
|
'text_color' => '#374151',
|
||||||
|
'show_prices' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWhatsappUrlAttribute(): ?string
|
||||||
|
{
|
||||||
|
if (! $this->whatsapp) return null;
|
||||||
|
$number = preg_replace('/[^0-9]/', '', $this->whatsapp);
|
||||||
|
return "https://wa.me/{$number}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLogoUrlAttribute(): ?string
|
||||||
|
{
|
||||||
|
return $this->logo_path
|
||||||
|
? route('files.serve-profile-logo')
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,10 +4,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Models\BrandContract;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
|
use App\Models\ClientCategory;
|
||||||
use App\Models\ContentBrief;
|
use App\Models\ContentBrief;
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
use App\Models\MediaFile;
|
||||||
use App\Models\SocialStat;
|
use App\Models\SocialStat;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
@@ -22,6 +25,11 @@ final class DashboardService
|
|||||||
'pending_invoices' => Invoice::where('status', 'sent')->count(),
|
'pending_invoices' => Invoice::where('status', 'sent')->count(),
|
||||||
'total_revenue' => Invoice::where('status', 'paid')->sum('total'),
|
'total_revenue' => Invoice::where('status', 'paid')->sum('total'),
|
||||||
'content_in_progress' => ContentBrief::whereNotIn('status', ['posted', 'archived'])->count(),
|
'content_in_progress' => ContentBrief::whereNotIn('status', ['posted', 'archived'])->count(),
|
||||||
|
'total_categories' => ClientCategory::whereNull('parent_id')->count(),
|
||||||
|
'total_subcategories' => ClientCategory::whereNotNull('parent_id')->count(),
|
||||||
|
'total_files' => MediaFile::count(),
|
||||||
|
'active_contracts' => BrandContract::where('is_active', true)->where('end_date', '>=', today())->count(),
|
||||||
|
'total_contracts' => BrandContract::count(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace App\Services;
|
|||||||
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\InvoiceItem;
|
use App\Models\InvoiceItem;
|
||||||
|
use App\Models\InvoiceSettings;
|
||||||
use Barryvdh\DomPDF\Facade\Pdf;
|
use Barryvdh\DomPDF\Facade\Pdf;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ final class InvoiceService
|
|||||||
|
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
$item['total'] = $item['quantity'] * $item['unit_price'];
|
$item['total'] = $item['quantity'] * $item['unit_price'];
|
||||||
|
$item['is_taxable'] = isset($item['is_taxable']) && $item['is_taxable'] ? true : false;
|
||||||
$invoice->items()->create($item);
|
$invoice->items()->create($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,6 +40,7 @@ final class InvoiceService
|
|||||||
|
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
$item['total'] = $item['quantity'] * $item['unit_price'];
|
$item['total'] = $item['quantity'] * $item['unit_price'];
|
||||||
|
$item['is_taxable'] = isset($item['is_taxable']) && $item['is_taxable'] ? true : false;
|
||||||
$invoice->items()->create($item);
|
$invoice->items()->create($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,8 +52,9 @@ final class InvoiceService
|
|||||||
public function generatePdf(Invoice $invoice): Response
|
public function generatePdf(Invoice $invoice): Response
|
||||||
{
|
{
|
||||||
$invoice->load('client', 'items');
|
$invoice->load('client', 'items');
|
||||||
|
$invoiceSettings = InvoiceSettings::instance();
|
||||||
|
|
||||||
$pdf = Pdf::loadView('invoices.pdf', compact('invoice'));
|
$pdf = Pdf::loadView('invoices.pdf', compact('invoice', 'invoiceSettings'));
|
||||||
$pdf->setPaper('A4', 'portrait');
|
$pdf->setPaper('A4', 'portrait');
|
||||||
|
|
||||||
return $pdf->download("invoice-{$invoice->invoice_number}.pdf");
|
return $pdf->download("invoice-{$invoice->invoice_number}.pdf");
|
||||||
|
|||||||
113
app/Services/NotificationDispatcher.php
Normal file
113
app/Services/NotificationDispatcher.php
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Models\ContentBrief;
|
||||||
|
use App\Models\Event;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\NotificationSetting;
|
||||||
|
use App\Services\Notifications\EmailNotifier;
|
||||||
|
use App\Services\Notifications\TelegramNotifier;
|
||||||
|
use App\Services\Notifications\WahaNotifier;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class NotificationDispatcher
|
||||||
|
{
|
||||||
|
/** Dispatch all due notifications for enabled channels */
|
||||||
|
public function dispatchAll(): void
|
||||||
|
{
|
||||||
|
$settings = NotificationSetting::where('is_enabled', true)->get();
|
||||||
|
|
||||||
|
foreach ($settings as $setting) {
|
||||||
|
try {
|
||||||
|
$this->dispatchForSetting($setting);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error("Notification dispatch failed for [{$setting->name}]: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dispatchForSetting(NotificationSetting $setting): void
|
||||||
|
{
|
||||||
|
$triggers = $setting->triggers ?? [];
|
||||||
|
$hours = $setting->notify_before_hours;
|
||||||
|
|
||||||
|
$messages = collect();
|
||||||
|
|
||||||
|
if (in_array('upcoming_event', $triggers)) {
|
||||||
|
$events = Event::with('client')
|
||||||
|
->where('start_time', '>=', now())
|
||||||
|
->where('start_time', '<=', now()->addHours($hours))
|
||||||
|
->whereNotIn('status', ['completed', 'cancelled'])
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($events as $event) {
|
||||||
|
$messages->push(
|
||||||
|
"📅 *Upcoming Event*\n"
|
||||||
|
. "*{$event->title}*\n"
|
||||||
|
. "⏰ " . $event->start_time->format('d M Y, H:i') . "\n"
|
||||||
|
. ($event->client ? "👤 {$event->client->name}\n" : '')
|
||||||
|
. ($event->location ? "📍 {$event->location}" : '')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array('invoice_due', $triggers)) {
|
||||||
|
$invoices = Invoice::with('client')
|
||||||
|
->whereBetween('due_date', [now(), now()->addHours($hours)])
|
||||||
|
->whereNotIn('status', ['paid', 'cancelled'])
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($invoices as $inv) {
|
||||||
|
$messages->push(
|
||||||
|
"🧾 *Invoice Due Soon*\n"
|
||||||
|
. "*{$inv->invoice_number}*"
|
||||||
|
. ($inv->title ? " — {$inv->title}" : '') . "\n"
|
||||||
|
. "📅 Due: " . $inv->due_date->format('d M Y') . "\n"
|
||||||
|
. ($inv->client ? "👤 {$inv->client->name}\n" : '')
|
||||||
|
. ($inv->formatted_total ?? '')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array('content_due', $triggers)) {
|
||||||
|
$content = ContentBrief::with('client')
|
||||||
|
->whereBetween('target_date', [now(), now()->addHours($hours)])
|
||||||
|
->whereNotIn('status', ['posted', 'archived'])
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($content as $c) {
|
||||||
|
$messages->push(
|
||||||
|
"🎬 *Content Target*\n"
|
||||||
|
. "*{$c->title}*\n"
|
||||||
|
. "📅 " . $c->target_date->format('d M Y') . "\n"
|
||||||
|
. ucfirst($c->platform)
|
||||||
|
. ($c->client ? " · {$c->client->name}" : '')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($messages->isEmpty()) return;
|
||||||
|
|
||||||
|
$notifier = $this->resolveNotifier($setting);
|
||||||
|
$notifier->sendBatch($setting, $messages->all());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Send a simple test message */
|
||||||
|
public function sendTest(NotificationSetting $setting): void
|
||||||
|
{
|
||||||
|
$this->resolveNotifier($setting)->sendTest($setting);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function resolveNotifier(NotificationSetting $setting): EmailNotifier|TelegramNotifier|WahaNotifier
|
||||||
|
{
|
||||||
|
return match ($setting->channel) {
|
||||||
|
'email' => new EmailNotifier,
|
||||||
|
'telegram' => new TelegramNotifier,
|
||||||
|
'whatsapp' => new WahaNotifier,
|
||||||
|
default => throw new \InvalidArgumentException("Unknown channel: {$setting->channel}"),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
43
app/Services/Notifications/EmailNotifier.php
Normal file
43
app/Services/Notifications/EmailNotifier.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Services\Notifications;
|
||||||
|
|
||||||
|
use App\Models\NotificationSetting;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
||||||
|
class EmailNotifier
|
||||||
|
{
|
||||||
|
public function sendBatch(NotificationSetting $setting, array $messages): void
|
||||||
|
{
|
||||||
|
$toEmail = $setting->config['to_email'] ?? null;
|
||||||
|
|
||||||
|
if (! $toEmail) {
|
||||||
|
throw new \RuntimeException('Email to_email address is required.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$combined = implode("\n\n---\n\n", $messages);
|
||||||
|
|
||||||
|
Mail::raw($combined, function ($mail) use ($toEmail, $setting): void {
|
||||||
|
$mail->to($toEmail)
|
||||||
|
->subject("🐱 KOL Manager — {$setting->name} Notifications");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendTest(NotificationSetting $setting): void
|
||||||
|
{
|
||||||
|
$toEmail = $setting->config['to_email'] ?? null;
|
||||||
|
|
||||||
|
if (! $toEmail) {
|
||||||
|
throw new \RuntimeException('Email to_email address is required.');
|
||||||
|
}
|
||||||
|
|
||||||
|
Mail::raw(
|
||||||
|
"🐱 KOL Manager — Test Notification\n\nYour Email channel is configured correctly! 🎉",
|
||||||
|
function ($mail) use ($toEmail): void {
|
||||||
|
$mail->to($toEmail)->subject('🐱 KOL Manager — Test Notification');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
50
app/Services/Notifications/TelegramNotifier.php
Normal file
50
app/Services/Notifications/TelegramNotifier.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Services\Notifications;
|
||||||
|
|
||||||
|
use App\Models\NotificationSetting;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
|
class TelegramNotifier
|
||||||
|
{
|
||||||
|
public function sendBatch(NotificationSetting $setting, array $messages): void
|
||||||
|
{
|
||||||
|
foreach ($messages as $message) {
|
||||||
|
$this->send($setting, $message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendTest(NotificationSetting $setting): void
|
||||||
|
{
|
||||||
|
$this->send(
|
||||||
|
$setting,
|
||||||
|
"🐱 *KOL Manager — Test Notification*\n\nYour Telegram channel is configured correctly! 🎉"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function send(NotificationSetting $setting, string $text): void
|
||||||
|
{
|
||||||
|
$config = $setting->config ?? [];
|
||||||
|
$botToken = $config['bot_token'] ?? null;
|
||||||
|
$chatId = $config['chat_id'] ?? null;
|
||||||
|
|
||||||
|
if (! $botToken || ! $chatId) {
|
||||||
|
throw new \RuntimeException('Telegram bot_token and chat_id are required.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::timeout(10)->post(
|
||||||
|
"https://api.telegram.org/bot{$botToken}/sendMessage",
|
||||||
|
[
|
||||||
|
'chat_id' => $chatId,
|
||||||
|
'text' => $text,
|
||||||
|
'parse_mode' => 'Markdown',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (! $response->successful()) {
|
||||||
|
throw new \RuntimeException('Telegram API error: ' . $response->body());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
62
app/Services/Notifications/WahaNotifier.php
Normal file
62
app/Services/Notifications/WahaNotifier.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Services\Notifications;
|
||||||
|
|
||||||
|
use App\Models\NotificationSetting;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WAHA (WhatsApp HTTP API) — self-hosted WhatsApp bridge.
|
||||||
|
* Docs: https://waha.devlike.pro/docs/how-to/send-messages/
|
||||||
|
*/
|
||||||
|
class WahaNotifier
|
||||||
|
{
|
||||||
|
public function sendBatch(NotificationSetting $setting, array $messages): void
|
||||||
|
{
|
||||||
|
foreach ($messages as $message) {
|
||||||
|
$this->send($setting, $message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendTest(NotificationSetting $setting): void
|
||||||
|
{
|
||||||
|
$this->send(
|
||||||
|
$setting,
|
||||||
|
"🐱 *KOL Manager — Test Notification*\n\nYour WhatsApp channel is configured correctly! 🎉"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function send(NotificationSetting $setting, string $text): void
|
||||||
|
{
|
||||||
|
$config = $setting->config ?? [];
|
||||||
|
$endpoint = $config['waha_endpoint'] ?? null;
|
||||||
|
$session = $config['waha_session'] ?? 'default';
|
||||||
|
$chatId = $config['chat_id'] ?? null;
|
||||||
|
$apiKey = $config['api_key'] ?? null;
|
||||||
|
|
||||||
|
if (! $endpoint || ! $chatId) {
|
||||||
|
throw new \RuntimeException('WAHA waha_endpoint and chat_id are required.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$http = Http::timeout(15)->acceptJson()->contentType('application/json');
|
||||||
|
|
||||||
|
if ($apiKey) {
|
||||||
|
$http = $http->withHeaders(['X-Api-Key' => $apiKey]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $http->post($endpoint, [
|
||||||
|
'chatId' => $chatId,
|
||||||
|
'text' => $text,
|
||||||
|
'session' => $session,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (! $response->successful()) {
|
||||||
|
$keyHint = $apiKey ? '(api_key set, length=' . strlen($apiKey) . ')' : '(no api_key)';
|
||||||
|
throw new \RuntimeException(
|
||||||
|
"WAHA API error {$response->status()} {$keyHint} → " . $response->body()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Http\Middleware\GateAuth;
|
||||||
use Illuminate\Foundation\Application;
|
use Illuminate\Foundation\Application;
|
||||||
use Illuminate\Foundation\Configuration\Exceptions;
|
use Illuminate\Foundation\Configuration\Exceptions;
|
||||||
use Illuminate\Foundation\Configuration\Middleware;
|
use Illuminate\Foundation\Configuration\Middleware;
|
||||||
@@ -11,7 +12,9 @@ return Application::configure(basePath: dirname(__DIR__))
|
|||||||
health: '/up',
|
health: '/up',
|
||||||
)
|
)
|
||||||
->withMiddleware(function (Middleware $middleware): void {
|
->withMiddleware(function (Middleware $middleware): void {
|
||||||
//
|
$middleware->web(append: [
|
||||||
|
GateAuth::class,
|
||||||
|
]);
|
||||||
})
|
})
|
||||||
->withExceptions(function (Exceptions $exceptions): void {
|
->withExceptions(function (Exceptions $exceptions): void {
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ return [
|
|||||||
|
|
||||||
'name' => env('APP_NAME', 'Laravel'),
|
'name' => env('APP_NAME', 'Laravel'),
|
||||||
|
|
||||||
|
'password' => env('APP_PASSWORD'),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Application Environment
|
| Application Environment
|
||||||
|
|||||||
@@ -38,6 +38,13 @@ return [
|
|||||||
'report' => false,
|
'report' => false,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'private' => [
|
||||||
|
'driver' => 'local',
|
||||||
|
'root' => storage_path('app/private'),
|
||||||
|
'serve' => false,
|
||||||
|
'throw' => false,
|
||||||
|
],
|
||||||
|
|
||||||
'public' => [
|
'public' => [
|
||||||
'driver' => 'local',
|
'driver' => 'local',
|
||||||
'root' => storage_path('app/public'),
|
'root' => storage_path('app/public'),
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('client_categories', function (Blueprint $table): void {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('slug')->unique();
|
||||||
|
$table->unsignedBigInteger('parent_id')->nullable();
|
||||||
|
$table->string('icon')->default('🏷️');
|
||||||
|
$table->string('color')->default('#FFB7C5');
|
||||||
|
$table->string('description')->nullable();
|
||||||
|
$table->boolean('is_system')->default(false);
|
||||||
|
$table->unsignedInteger('sort_order')->default(0);
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->foreign('parent_id')
|
||||||
|
->references('id')
|
||||||
|
->on('client_categories')
|
||||||
|
->onDelete('set null');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add category_id to clients table
|
||||||
|
Schema::table('clients', function (Blueprint $table): void {
|
||||||
|
$table->unsignedBigInteger('category_id')->nullable()->after('status');
|
||||||
|
$table->foreign('category_id')
|
||||||
|
->references('id')
|
||||||
|
->on('client_categories')
|
||||||
|
->onDelete('set null');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('clients', function (Blueprint $table): void {
|
||||||
|
$table->dropForeign(['category_id']);
|
||||||
|
$table->dropColumn('category_id');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::dropIfExists('client_categories');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('notification_settings', function (Blueprint $table): void {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name'); // e.g. "My Telegram Bot"
|
||||||
|
$table->string('channel'); // email | telegram | whatsapp
|
||||||
|
$table->json('config'); // channel-specific credentials
|
||||||
|
$table->json('triggers')->nullable(); // array: upcoming_event, invoice_due, content_due
|
||||||
|
$table->boolean('is_enabled')->default(true);
|
||||||
|
$table->integer('notify_before_hours')->default(24); // hours before event to notify
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('notification_settings');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('events', function (Blueprint $table): void {
|
||||||
|
$table->unsignedBigInteger('category_id')->nullable()->after('client_id');
|
||||||
|
$table->foreign('category_id')
|
||||||
|
->references('id')->on('client_categories')->onDelete('set null');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('content_briefs', function (Blueprint $table): void {
|
||||||
|
$table->unsignedBigInteger('category_id')->nullable()->after('client_id');
|
||||||
|
$table->foreign('category_id')
|
||||||
|
->references('id')->on('client_categories')->onDelete('set null');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('events', function (Blueprint $table): void {
|
||||||
|
$table->dropForeign(['category_id']);
|
||||||
|
$table->dropColumn('category_id');
|
||||||
|
});
|
||||||
|
Schema::table('content_briefs', function (Blueprint $table): void {
|
||||||
|
$table->dropForeign(['category_id']);
|
||||||
|
$table->dropColumn('category_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('brand_contracts', function (Blueprint $table): void {
|
||||||
|
$table->id();
|
||||||
|
$table->string('title');
|
||||||
|
$table->unsignedBigInteger('client_id')->nullable(); // the contracted brand
|
||||||
|
$table->unsignedBigInteger('category_id')->nullable(); // the exclusive category
|
||||||
|
$table->date('start_date');
|
||||||
|
$table->date('end_date');
|
||||||
|
$table->text('notes')->nullable();
|
||||||
|
$table->boolean('is_active')->default(true);
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->foreign('client_id')->references('id')->on('clients')->onDelete('set null');
|
||||||
|
$table->foreign('category_id')->references('id')->on('client_categories')->onDelete('set null');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('brand_contracts');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('rate_card_profiles', function (Blueprint $table): void {
|
||||||
|
$table->id();
|
||||||
|
$table->string('owner_name')->default('KOL Manager');
|
||||||
|
$table->string('tagline')->nullable();
|
||||||
|
$table->string('whatsapp')->nullable();
|
||||||
|
$table->string('ig_handle')->nullable();
|
||||||
|
$table->string('tiktok_handle')->nullable();
|
||||||
|
$table->string('youtube_handle')->nullable();
|
||||||
|
$table->string('email')->nullable();
|
||||||
|
$table->string('logo_path')->nullable(); // uploaded image
|
||||||
|
$table->string('bg_color')->default('#FFF8F0');
|
||||||
|
$table->string('accent_color')->default('#FFB7C5');
|
||||||
|
$table->string('text_color')->default('#374151');
|
||||||
|
$table->text('custom_footer')->nullable();
|
||||||
|
$table->boolean('show_prices')->default(true);
|
||||||
|
$table->string('access_token')->nullable(); // optional: require ?token=xxx
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('rate_card_profiles');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
// Add branch_name to invoices
|
||||||
|
Schema::table('invoices', function (Blueprint $table): void {
|
||||||
|
$table->string('branch_name')->nullable()->after('bank_holder');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add is_taxable to invoice_items
|
||||||
|
Schema::table('invoice_items', function (Blueprint $table): void {
|
||||||
|
$table->boolean('is_taxable')->default(true)->after('total');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Invoice settings singleton table
|
||||||
|
Schema::create('invoice_settings', function (Blueprint $table): void {
|
||||||
|
$table->id();
|
||||||
|
$table->string('invoice_prefix')->default('INV');
|
||||||
|
$table->unsignedInteger('invoice_next_number')->default(1);
|
||||||
|
$table->string('header_name')->nullable(); // talent name
|
||||||
|
$table->string('header_title')->nullable(); // subtitle / tagline
|
||||||
|
$table->string('header_logo')->nullable(); // stored path
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('invoice_settings');
|
||||||
|
Schema::table('invoice_items', function (Blueprint $table): void {
|
||||||
|
$table->dropColumn('is_taxable');
|
||||||
|
});
|
||||||
|
Schema::table('invoices', function (Blueprint $table): void {
|
||||||
|
$table->dropColumn('branch_name');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('invoice_settings', function (Blueprint $table): void {
|
||||||
|
$table->decimal('default_tax_rate', 5, 2)->default(11)->after('header_logo');
|
||||||
|
$table->string('default_currency')->default('IDR')->after('default_tax_rate');
|
||||||
|
$table->string('default_service_description')->nullable()->after('default_currency');
|
||||||
|
$table->string('default_bank_name')->nullable()->after('default_service_description');
|
||||||
|
$table->string('default_branch_name')->nullable()->after('default_bank_name');
|
||||||
|
$table->string('default_bank_account')->nullable()->after('default_branch_name');
|
||||||
|
$table->string('default_bank_holder')->nullable()->after('default_bank_account');
|
||||||
|
$table->text('default_notes')->nullable()->after('default_bank_holder');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('invoice_settings', function (Blueprint $table): void {
|
||||||
|
$table->dropColumn([
|
||||||
|
'default_tax_rate', 'default_currency',
|
||||||
|
'default_service_description',
|
||||||
|
'default_bank_name', 'default_branch_name',
|
||||||
|
'default_bank_account', 'default_bank_holder', 'default_notes',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('invoice_settings', function (Blueprint $table) {
|
||||||
|
$table->string('accent_color', 20)->default('#FFB7C5')->after('header_logo');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('invoice_settings', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('accent_color');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
25
database/migrations/2026_04_02_000000_create_notes_table.php
Normal file
25
database/migrations/2026_04_02_000000_create_notes_table.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('notes', function (Blueprint $table): void {
|
||||||
|
$table->id();
|
||||||
|
$table->string('title')->default('Untitled Note');
|
||||||
|
$table->json('content')->nullable(); // array of block objects
|
||||||
|
$table->string('color', 20)->default('#FFFFFF');
|
||||||
|
$table->boolean('is_pinned')->default(false);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('notes');
|
||||||
|
}
|
||||||
|
};
|
||||||
89
database/seeders/ClientCategorySeeder.php
Normal file
89
database/seeders/ClientCategorySeeder.php
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\ClientCategory;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class ClientCategorySeeder extends Seeder
|
||||||
|
{
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$categories = [
|
||||||
|
['name' => 'Food & Beverages', 'icon' => '🍔', 'color' => '#FFD5B8', 'children' => [
|
||||||
|
['name' => 'Food', 'icon' => '🍱', 'color' => '#FFD5B8'],
|
||||||
|
['name' => 'Beverages', 'icon' => '🥤', 'color' => '#FFD5B8'],
|
||||||
|
['name' => 'Restaurant & Café', 'icon' => '☕', 'color' => '#FFD5B8'],
|
||||||
|
['name' => 'Snacks & Treats', 'icon' => '🍪', 'color' => '#FFD5B8'],
|
||||||
|
]],
|
||||||
|
['name' => 'Fashion', 'icon' => '👗', 'color' => '#FFB7C5', 'children' => [
|
||||||
|
['name' => 'Clothing', 'icon' => '👕', 'color' => '#FFB7C5'],
|
||||||
|
['name' => 'Accessories', 'icon' => '💍', 'color' => '#FFB7C5'],
|
||||||
|
['name' => 'Shoes & Footwear', 'icon' => '👠', 'color' => '#FFB7C5'],
|
||||||
|
['name' => 'Bags & Luggage', 'icon' => '👜', 'color' => '#FFB7C5'],
|
||||||
|
]],
|
||||||
|
['name' => 'Beauty & Skincare', 'icon' => '💄', 'color' => '#E8D5F5', 'children' => [
|
||||||
|
['name' => 'Skincare', 'icon' => '🧴', 'color' => '#E8D5F5'],
|
||||||
|
['name' => 'Makeup', 'icon' => '💋', 'color' => '#E8D5F5'],
|
||||||
|
['name' => 'Hair Care', 'icon' => '💇', 'color' => '#E8D5F5'],
|
||||||
|
['name' => 'Fragrance', 'icon' => '🌸', 'color' => '#E8D5F5'],
|
||||||
|
]],
|
||||||
|
['name' => 'Technology', 'icon' => '💻', 'color' => '#AEC6CF', 'children' => [
|
||||||
|
['name' => 'Consumer Electronics', 'icon' => '📱', 'color' => '#AEC6CF'],
|
||||||
|
['name' => 'Apps & Software', 'icon' => '🖥️', 'color' => '#AEC6CF'],
|
||||||
|
['name' => 'Gaming', 'icon' => '🎮', 'color' => '#AEC6CF'],
|
||||||
|
['name' => 'Smart Home', 'icon' => '🏠', 'color' => '#AEC6CF'],
|
||||||
|
]],
|
||||||
|
['name' => 'Health & Wellness', 'icon' => '💪', 'color' => '#B5EAD7', 'children' => [
|
||||||
|
['name' => 'Fitness', 'icon' => '🏋️', 'color' => '#B5EAD7'],
|
||||||
|
['name' => 'Supplements', 'icon' => '💊', 'color' => '#B5EAD7'],
|
||||||
|
['name' => 'Mental Health', 'icon' => '🧘', 'color' => '#B5EAD7'],
|
||||||
|
]],
|
||||||
|
['name' => 'Lifestyle', 'icon' => '🌿', 'color' => '#FDFD96', 'children' => [
|
||||||
|
['name' => 'Travel', 'icon' => '✈️', 'color' => '#FDFD96'],
|
||||||
|
['name' => 'Home & Living', 'icon' => '🛋️', 'color' => '#FDFD96'],
|
||||||
|
['name' => 'Pets', 'icon' => '🐾', 'color' => '#FDFD96'],
|
||||||
|
['name' => 'Parenting', 'icon' => '👶', 'color' => '#FDFD96'],
|
||||||
|
]],
|
||||||
|
['name' => 'Entertainment', 'icon' => '🎬', 'color' => '#AEC6CF', 'children' => [
|
||||||
|
['name' => 'Movies & TV', 'icon' => '🎥', 'color' => '#AEC6CF'],
|
||||||
|
['name' => 'Music', 'icon' => '🎵', 'color' => '#AEC6CF'],
|
||||||
|
['name' => 'Sports', 'icon' => '⚽', 'color' => '#AEC6CF'],
|
||||||
|
['name' => 'Gaming & Esports', 'icon' => '🕹️', 'color' => '#AEC6CF'],
|
||||||
|
]],
|
||||||
|
['name' => 'Finance', 'icon' => '💰', 'color' => '#FDFD96', 'children' => [
|
||||||
|
['name' => 'Banking', 'icon' => '🏦', 'color' => '#FDFD96'],
|
||||||
|
['name' => 'Insurance', 'icon' => '🛡️', 'color' => '#FDFD96'],
|
||||||
|
['name' => 'Investment', 'icon' => '📈', 'color' => '#FDFD96'],
|
||||||
|
]],
|
||||||
|
['name' => 'Education', 'icon' => '📚', 'color' => '#B5EAD7', 'children' => [
|
||||||
|
['name' => 'Online Courses', 'icon' => '🎓', 'color' => '#B5EAD7'],
|
||||||
|
['name' => 'Kids Education', 'icon' => '🧒', 'color' => '#B5EAD7'],
|
||||||
|
]],
|
||||||
|
['name' => 'Other', 'icon' => '🏷️', 'color' => '#E5E7EB', 'children' => []],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($categories as $i => $data) {
|
||||||
|
$parent = ClientCategory::create([
|
||||||
|
'name' => $data['name'],
|
||||||
|
'icon' => $data['icon'],
|
||||||
|
'color' => $data['color'],
|
||||||
|
'is_system' => true,
|
||||||
|
'sort_order' => $i,
|
||||||
|
]);
|
||||||
|
|
||||||
|
foreach ($data['children'] as $j => $child) {
|
||||||
|
ClientCategory::create([
|
||||||
|
'name' => $child['name'],
|
||||||
|
'icon' => $child['icon'],
|
||||||
|
'color' => $child['color'],
|
||||||
|
'parent_id' => $parent->id,
|
||||||
|
'is_system' => true,
|
||||||
|
'sort_order' => $j,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,5 +21,9 @@ class DatabaseSeeder extends Seeder
|
|||||||
'name' => 'Test User',
|
'name' => 'Test User',
|
||||||
'email' => 'test@example.com',
|
'email' => 'test@example.com',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$this->call([
|
||||||
|
ClientCategorySeeder::class,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
38
docker-compose.yml
Normal file
38
docker-compose.yml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
image: kol-manager:latest
|
||||||
|
container_name: kol-manager
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- "${APP_PORT:-8080}:80"
|
||||||
|
|
||||||
|
# Mount .env.docker as the runtime .env
|
||||||
|
env_file:
|
||||||
|
- .env.docker
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
# Persist the SQLite database across container rebuilds
|
||||||
|
- kol_database:/var/www/html/database
|
||||||
|
|
||||||
|
# Persist uploaded files (talent assets, etc.)
|
||||||
|
- kol_storage:/var/www/html/storage
|
||||||
|
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost/up"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 30s
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
# Named volume for SQLite database
|
||||||
|
kol_database:
|
||||||
|
driver: local
|
||||||
|
|
||||||
|
# Named volume for all file uploads / logs / cache
|
||||||
|
kol_storage:
|
||||||
|
driver: local
|
||||||
67
docker/entrypoint.sh
Normal file
67
docker/entrypoint.sh
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
APP_DIR=/var/www/html
|
||||||
|
|
||||||
|
echo "──────────────────────────────────────────"
|
||||||
|
echo " KOL Manager – Container Start"
|
||||||
|
echo "──────────────────────────────────────────"
|
||||||
|
|
||||||
|
cd "$APP_DIR"
|
||||||
|
|
||||||
|
# ── 1. Bootstrap .env ───────────────────────
|
||||||
|
if [ ! -f .env ]; then
|
||||||
|
if [ -f .env.docker ]; then
|
||||||
|
cp .env.docker .env
|
||||||
|
echo "[env] Copied .env.docker → .env"
|
||||||
|
else
|
||||||
|
echo "[env] WARNING: No .env or .env.docker found!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── 2. Generate APP_KEY if empty ────────────
|
||||||
|
if grep -qE '^APP_KEY=$' .env 2>/dev/null; then
|
||||||
|
echo "[key] Generating application key…"
|
||||||
|
php artisan key:generate --force --quiet
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── 3. Ensure SQLite database file exists ───
|
||||||
|
if [ ! -f database/database.sqlite ]; then
|
||||||
|
echo "[db] Creating SQLite database file…"
|
||||||
|
touch database/database.sqlite
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── 4. Fix ownership / permissions ──────────
|
||||||
|
chown -R www-data:www-data \
|
||||||
|
storage \
|
||||||
|
bootstrap/cache \
|
||||||
|
database
|
||||||
|
chmod -R 775 \
|
||||||
|
storage \
|
||||||
|
bootstrap/cache \
|
||||||
|
database
|
||||||
|
|
||||||
|
# ── 5. Discover packages (composer --no-scripts skips this) ──
|
||||||
|
echo "[packages] Discovering service providers…"
|
||||||
|
php artisan package:discover --ansi 2>/dev/null || true
|
||||||
|
|
||||||
|
# ── 6. Run migrations ─────────────────────────
|
||||||
|
echo "[migrate] Running database migrations…"
|
||||||
|
php artisan migrate --force --no-interaction
|
||||||
|
|
||||||
|
# ── 7. Create public storage symlink ──────────
|
||||||
|
echo "[storage] Creating public storage symlink…"
|
||||||
|
php artisan storage:link --quiet 2>/dev/null || true
|
||||||
|
|
||||||
|
# ── 8. Cache config / routes / views ─────────
|
||||||
|
echo "[optimize] Caching configuration…"
|
||||||
|
php artisan config:cache --quiet
|
||||||
|
php artisan route:cache --quiet
|
||||||
|
php artisan view:cache --quiet
|
||||||
|
|
||||||
|
echo "──────────────────────────────────────────"
|
||||||
|
echo " All checks passed. Starting services…"
|
||||||
|
echo "──────────────────────────────────────────"
|
||||||
|
|
||||||
|
# ── 9. Hand off to Supervisor ────────────────
|
||||||
|
exec supervisord -c /etc/supervisord.conf
|
||||||
74
docker/nginx.conf
Normal file
74
docker/nginx.conf
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
user www-data;
|
||||||
|
worker_processes auto;
|
||||||
|
pid /run/nginx.pid;
|
||||||
|
error_log /dev/stderr warn;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
multi_accept on;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
# Logging to stdout/stderr so Docker captures it
|
||||||
|
access_log /dev/stdout;
|
||||||
|
error_log /dev/stderr warn;
|
||||||
|
|
||||||
|
sendfile on;
|
||||||
|
tcp_nopush on;
|
||||||
|
tcp_nodelay on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
gzip on;
|
||||||
|
gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
|
||||||
|
|
||||||
|
# Upload size limit (matches file uploads in the app)
|
||||||
|
client_max_body_size 64M;
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
root /var/www/html/public;
|
||||||
|
index index.php;
|
||||||
|
|
||||||
|
charset utf-8;
|
||||||
|
|
||||||
|
# Laravel health-check endpoint
|
||||||
|
location = /up {
|
||||||
|
try_files $uri /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main catch-all → Laravel router
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
# PHP-FPM handler
|
||||||
|
location ~ \.php$ {
|
||||||
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
|
|
||||||
|
# Increase timeouts for long-running requests (PDF export, uploads)
|
||||||
|
fastcgi_read_timeout 300;
|
||||||
|
fastcgi_connect_timeout 60;
|
||||||
|
fastcgi_send_timeout 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Deny access to hidden files (.env, .git, etc.)
|
||||||
|
location ~ /\.(?!well-known).* {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Cache static assets
|
||||||
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|otf)$ {
|
||||||
|
expires 1y;
|
||||||
|
add_header Cache-Control "public, immutable";
|
||||||
|
try_files $uri =404;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
52
docker/supervisord.conf
Normal file
52
docker/supervisord.conf
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
[supervisord]
|
||||||
|
nodaemon=true
|
||||||
|
user=root
|
||||||
|
logfile=/dev/null
|
||||||
|
logfile_maxbytes=0
|
||||||
|
pidfile=/run/supervisord.pid
|
||||||
|
|
||||||
|
[unix_http_server]
|
||||||
|
file=/run/supervisor.sock
|
||||||
|
|
||||||
|
[supervisorctl]
|
||||||
|
serverurl=unix:///run/supervisor.sock
|
||||||
|
|
||||||
|
[rpcinterface:supervisor]
|
||||||
|
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||||
|
|
||||||
|
; ── PHP-FPM ───────────────────────────────────────────────────────────────────
|
||||||
|
[program:php-fpm]
|
||||||
|
command=php-fpm --nodaemonize
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
priority=5
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stderr_logfile_maxbytes=0
|
||||||
|
|
||||||
|
; ── Nginx ─────────────────────────────────────────────────────────────────────
|
||||||
|
[program:nginx]
|
||||||
|
command=nginx -g "daemon off;"
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
priority=10
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stderr_logfile_maxbytes=0
|
||||||
|
|
||||||
|
; ── Laravel Queue Worker ──────────────────────────────────────────────────────
|
||||||
|
[program:queue]
|
||||||
|
command=php /var/www/html/artisan queue:work --sleep=3 --tries=3 --max-time=3600 --queue=default
|
||||||
|
directory=/var/www/html
|
||||||
|
user=www-data
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
priority=20
|
||||||
|
numprocs=1
|
||||||
|
startsecs=5
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stderr_logfile_maxbytes=0
|
||||||
26
public/manifest.json
Normal file
26
public/manifest.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"name": "KOL Manager",
|
||||||
|
"short_name": "KOL",
|
||||||
|
"description": "Your Purr-fect Influencer Management Assistant",
|
||||||
|
"start_url": "/",
|
||||||
|
"display": "standalone",
|
||||||
|
"orientation": "portrait-primary",
|
||||||
|
"background_color": "#FFF8F0",
|
||||||
|
"theme_color": "#FFB7C5",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "/icons/icon-192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "any maskable"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/icons/icon-512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "any maskable"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"categories": ["business", "productivity"],
|
||||||
|
"screenshots": []
|
||||||
|
}
|
||||||
61
public/sw.js
Normal file
61
public/sw.js
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
// KOL Manager Service Worker
|
||||||
|
// Provides basic offline support and caches static assets
|
||||||
|
|
||||||
|
const CACHE_NAME = 'kol-manager-v1';
|
||||||
|
const STATIC_ASSETS = [
|
||||||
|
'/',
|
||||||
|
'/manifest.json',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Install — pre-cache shell
|
||||||
|
self.addEventListener('install', event => {
|
||||||
|
event.waitUntil(
|
||||||
|
caches.open(CACHE_NAME).then(cache => cache.addAll(STATIC_ASSETS))
|
||||||
|
);
|
||||||
|
self.skipWaiting();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Activate — clean up old caches
|
||||||
|
self.addEventListener('activate', event => {
|
||||||
|
event.waitUntil(
|
||||||
|
caches.keys().then(keys =>
|
||||||
|
Promise.all(keys.filter(k => k !== CACHE_NAME).map(k => caches.delete(k)))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
self.clients.claim();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fetch — network-first for HTML/API, cache-first for static assets
|
||||||
|
self.addEventListener('fetch', event => {
|
||||||
|
const { request } = event;
|
||||||
|
const url = new URL(request.url);
|
||||||
|
|
||||||
|
// Skip non-GET and cross-origin requests
|
||||||
|
if (request.method !== 'GET' || url.origin !== location.origin) return;
|
||||||
|
|
||||||
|
// Cache-first for Vite build assets (hashed filenames)
|
||||||
|
if (url.pathname.startsWith('/build/')) {
|
||||||
|
event.respondWith(
|
||||||
|
caches.match(request).then(cached => cached || fetch(request).then(response => {
|
||||||
|
const clone = response.clone();
|
||||||
|
caches.open(CACHE_NAME).then(cache => cache.put(request, clone));
|
||||||
|
return response;
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Network-first for everything else (app routes)
|
||||||
|
event.respondWith(
|
||||||
|
fetch(request)
|
||||||
|
.then(response => {
|
||||||
|
// Cache successful HTML responses
|
||||||
|
if (response.ok && request.headers.get('Accept')?.includes('text/html')) {
|
||||||
|
const clone = response.clone();
|
||||||
|
caches.open(CACHE_NAME).then(cache => cache.put(request, clone));
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
})
|
||||||
|
.catch(() => caches.match(request))
|
||||||
|
);
|
||||||
|
});
|
||||||
@@ -115,6 +115,40 @@ aside {
|
|||||||
}
|
}
|
||||||
.paw-bounce { animation: paw-bounce 0.4s ease-in-out; }
|
.paw-bounce { animation: paw-bounce 0.4s ease-in-out; }
|
||||||
|
|
||||||
|
/* ── Label Soft ───────────────────────────────────────────── */
|
||||||
|
.label-soft {
|
||||||
|
@apply block text-xs font-semibold text-gray-600 mb-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Select Soft ──────────────────────────────────────────── */
|
||||||
|
.select-soft {
|
||||||
|
@apply rounded-2xl border border-pink-200 px-4 py-2
|
||||||
|
focus:border-pink-400 focus:outline-none focus:ring-2 focus:ring-pink-200
|
||||||
|
w-full bg-white text-sm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Btn Pink (alias for btn-sakura) ─────────────────────── */
|
||||||
|
.btn-pink {
|
||||||
|
@apply rounded-full text-white font-semibold shadow-sm
|
||||||
|
transition-all duration-150 inline-block cursor-pointer text-center;
|
||||||
|
background-color: #FFB7C5;
|
||||||
|
border: none;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.btn-pink:hover { background-color: #FF8FAD; }
|
||||||
|
.btn-pink:active { transform: scale(0.96); }
|
||||||
|
|
||||||
|
/* ── Badge Soft ───────────────────────────────────────────── */
|
||||||
|
.badge-soft { @apply badge badge-ghost; }
|
||||||
|
|
||||||
|
/* ── Cat Card Header ──────────────────────────────────────── */
|
||||||
|
.cat-card-header {
|
||||||
|
@apply flex items-center gap-3 px-4 py-3 border-b border-pink-50;
|
||||||
|
}
|
||||||
|
.cat-card-icon {
|
||||||
|
@apply text-xl shrink-0;
|
||||||
|
}
|
||||||
|
|
||||||
/* ── Mobile touch targets ─────────────────────────────────── */
|
/* ── Mobile touch targets ─────────────────────────────────── */
|
||||||
@media (max-width: 1023px) {
|
@media (max-width: 1023px) {
|
||||||
.nav-item { @apply py-3.5; }
|
.nav-item { @apply py-3.5; }
|
||||||
|
|||||||
@@ -6,39 +6,26 @@ Alpine.plugin(sort);
|
|||||||
window.Alpine = Alpine;
|
window.Alpine = Alpine;
|
||||||
Alpine.start();
|
Alpine.start();
|
||||||
|
|
||||||
// Meow sound toggle (stored in localStorage)
|
// ── PWA Service Worker ────────────────────────────────────────
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
window.addEventListener('load', () => {
|
||||||
|
navigator.serviceWorker.register('/sw.js').catch(() => {/* silently fail */});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── KolManager helpers (toast notifications only — no meow) ──
|
||||||
window.KolManager = {
|
window.KolManager = {
|
||||||
meowEnabled: localStorage.getItem('meow') !== 'false',
|
|
||||||
|
|
||||||
toggleMeow() {
|
|
||||||
this.meowEnabled = !this.meowEnabled;
|
|
||||||
localStorage.setItem('meow', this.meowEnabled);
|
|
||||||
},
|
|
||||||
|
|
||||||
playMeow() {
|
|
||||||
if (!this.meowEnabled) return;
|
|
||||||
const ctx = new (window.AudioContext || window.webkitAudioContext)();
|
|
||||||
const o = ctx.createOscillator();
|
|
||||||
const g = ctx.createGain();
|
|
||||||
o.connect(g);
|
|
||||||
g.connect(ctx.destination);
|
|
||||||
o.type = 'sine';
|
|
||||||
o.frequency.setValueAtTime(880, ctx.currentTime);
|
|
||||||
o.frequency.exponentialRampToValueAtTime(1200, ctx.currentTime + 0.05);
|
|
||||||
o.frequency.exponentialRampToValueAtTime(900, ctx.currentTime + 0.15);
|
|
||||||
g.gain.setValueAtTime(0.3, ctx.currentTime);
|
|
||||||
g.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + 0.3);
|
|
||||||
o.start(ctx.currentTime);
|
|
||||||
o.stop(ctx.currentTime + 0.3);
|
|
||||||
},
|
|
||||||
|
|
||||||
notify(msg) {
|
notify(msg) {
|
||||||
this.playMeow();
|
|
||||||
const el = document.createElement('div');
|
const el = document.createElement('div');
|
||||||
el.className = 'fixed top-4 right-4 z-50 cat-card px-5 py-3 flex items-center gap-2 shadow-lg border border-pink-200 animate-bounce';
|
el.className = 'fixed top-4 right-4 z-50 cat-card px-5 py-3 flex items-center gap-2 shadow-lg border border-pink-200';
|
||||||
|
el.style.cssText = 'animation: slideIn .3s ease';
|
||||||
el.innerHTML = `<span class="text-xl">🐱</span><span class="text-sm font-medium text-pink-700">${msg}</span>`;
|
el.innerHTML = `<span class="text-xl">🐱</span><span class="text-sm font-medium text-pink-700">${msg}</span>`;
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
setTimeout(() => el.remove(), 3500);
|
setTimeout(() => {
|
||||||
|
el.style.opacity = '0';
|
||||||
|
el.style.transition = 'opacity .3s';
|
||||||
|
setTimeout(() => el.remove(), 300);
|
||||||
|
}, 3200);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -46,7 +33,6 @@ window.KolManager = {
|
|||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const flash = document.getElementById('flash-message');
|
const flash = document.getElementById('flash-message');
|
||||||
if (flash) {
|
if (flash) {
|
||||||
window.KolManager.playMeow();
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
flash.style.opacity = '0';
|
flash.style.opacity = '0';
|
||||||
flash.style.transform = 'translateY(-10px)';
|
flash.style.transform = 'translateY(-10px)';
|
||||||
|
|||||||
219
resources/views/categories/index.blade.php
Normal file
219
resources/views/categories/index.blade.php
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
@section('title', 'Categories')
|
||||||
|
@section('page-title', '🏷️ Category Management')
|
||||||
|
@section('page-subtitle', 'Organise clients, schedules & content by category')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="max-w-4xl mx-auto space-y-5">
|
||||||
|
|
||||||
|
@if(session('success'))
|
||||||
|
<div x-data="{ show: true }" x-show="show" x-init="setTimeout(() => show = false, 4000)"
|
||||||
|
class="flex items-center justify-between gap-3 bg-green-50 border border-green-200 rounded-2xl px-4 py-3 text-sm text-green-700">
|
||||||
|
<span>{{ session('success') }}</span>
|
||||||
|
<button @click="show = false" class="text-green-500 hover:text-green-700 text-lg leading-none">✕</button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
{{-- Add form --}}
|
||||||
|
<div class="cat-card overflow-hidden" x-data="{ open: {{ $errors->any() ? 'true' : 'false' }} }">
|
||||||
|
<div class="flex items-center gap-3 px-5 py-4 border-b border-pink-50">
|
||||||
|
<button type="button" @click="open = !open"
|
||||||
|
class="btn-sakura text-xs"
|
||||||
|
x-text="open ? '✕ Close' : '+ Add New Category'">
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div x-show="open" x-transition style="display:none">
|
||||||
|
<form action="{{ route('client-categories.store') }}" method="POST"
|
||||||
|
class="p-5 grid grid-cols-2 sm:grid-cols-4 gap-3 items-end border-b border-pink-50">
|
||||||
|
@csrf
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Name <span class="text-pink-400">*</span></label>
|
||||||
|
<input type="text" name="name" required maxlength="100"
|
||||||
|
placeholder="e.g. Energy Drinks"
|
||||||
|
class="input-soft" value="{{ old('name') }}">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Parent (optional)</label>
|
||||||
|
<select name="parent_id" class="input-soft">
|
||||||
|
<option value="">— Root category —</option>
|
||||||
|
@foreach($parents as $p)
|
||||||
|
<option value="{{ $p->id }}" {{ old('parent_id') == $p->id ? 'selected' : '' }}>
|
||||||
|
{{ $p->icon }} {{ $p->name }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Icon (emoji)</label>
|
||||||
|
<input type="text" name="icon" maxlength="10" placeholder="🏷️"
|
||||||
|
class="input-soft" value="{{ old('icon') }}">
|
||||||
|
</div>
|
||||||
|
<div class="flex items-end gap-2">
|
||||||
|
<div class="flex-1">
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Color</label>
|
||||||
|
<input type="color" name="color" value="{{ old('color', '#FFB7C5') }}"
|
||||||
|
class="w-full h-[42px] rounded-2xl border border-pink-200 cursor-pointer p-1 bg-white">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn-sakura px-4 py-2.5 shrink-0 text-sm">Add</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- List --}}
|
||||||
|
<div class="cat-card overflow-hidden">
|
||||||
|
<div class="flex items-center gap-3 px-5 py-4 border-b border-pink-50">
|
||||||
|
<span class="text-xl">🗂️</span>
|
||||||
|
<h2 class="font-bold text-gray-700">All Categories</h2>
|
||||||
|
<span class="ml-auto text-xs bg-pink-100 text-pink-600 font-semibold px-2.5 py-0.5 rounded-full">
|
||||||
|
{{ $categories->count() }} total
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@php $roots = $categories->whereNull('parent_id'); @endphp
|
||||||
|
|
||||||
|
@forelse($roots as $root)
|
||||||
|
<div x-data="{ editing: false }" class="border-b border-pink-50 last:border-0">
|
||||||
|
{{-- Root row --}}
|
||||||
|
<div class="flex items-center gap-3 px-5 py-3 hover:bg-pink-50/40 transition-colors">
|
||||||
|
<span class="text-xl w-7 text-center shrink-0">{{ $root->icon ?: '🏷️' }}</span>
|
||||||
|
@if($root->color)
|
||||||
|
<span class="w-3 h-3 rounded-full shrink-0" style="background:{{ $root->color }}"></span>
|
||||||
|
@endif
|
||||||
|
<div class="flex-1 min-w-0">
|
||||||
|
<div class="font-semibold text-gray-700 text-sm">{{ $root->name }}</div>
|
||||||
|
<div class="text-xs text-gray-400">{{ $root->children->count() }} sub · {{ $root->clients_count }} client(s)</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex gap-2 shrink-0">
|
||||||
|
<button @click="editing = !editing"
|
||||||
|
class="text-xs px-3 py-1.5 rounded-full border border-blue-200 text-blue-500 hover:bg-blue-50">
|
||||||
|
✏️ Edit
|
||||||
|
</button>
|
||||||
|
@unless($root->is_system)
|
||||||
|
<form action="{{ route('client-categories.destroy', $root) }}" method="POST"
|
||||||
|
onsubmit="return confirm('Remove this category? Its children will be promoted.')">
|
||||||
|
@csrf @method('DELETE')
|
||||||
|
<button class="text-xs px-3 py-1.5 rounded-full border border-red-100 text-red-400 hover:bg-red-50">
|
||||||
|
🗑️
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@endunless
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Edit form --}}
|
||||||
|
<div x-show="editing" x-transition style="display:none"
|
||||||
|
class="px-5 py-4 bg-pink-50/30 border-t border-pink-50">
|
||||||
|
<form action="{{ route('client-categories.update', $root) }}" method="POST"
|
||||||
|
class="grid grid-cols-2 sm:grid-cols-4 gap-3 items-end">
|
||||||
|
@csrf @method('PUT')
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Name</label>
|
||||||
|
<input type="text" name="name" required value="{{ $root->name }}" class="input-soft">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Parent</label>
|
||||||
|
<select name="parent_id" class="input-soft">
|
||||||
|
<option value="">— Root —</option>
|
||||||
|
@foreach($parents as $p)
|
||||||
|
@if($p->id !== $root->id)
|
||||||
|
<option value="{{ $p->id }}" {{ $root->parent_id == $p->id ? 'selected' : '' }}>
|
||||||
|
{{ $p->icon }} {{ $p->name }}
|
||||||
|
</option>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Icon</label>
|
||||||
|
<input type="text" name="icon" value="{{ $root->icon }}" maxlength="10" class="input-soft">
|
||||||
|
</div>
|
||||||
|
<div class="flex items-end gap-2">
|
||||||
|
<div class="flex-1">
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Color</label>
|
||||||
|
<input type="color" name="color" value="{{ $root->color ?: '#FFB7C5' }}"
|
||||||
|
class="w-full h-[42px] rounded-2xl border border-pink-200 cursor-pointer p-1 bg-white">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn-sakura px-3 py-2.5 text-sm shrink-0">Save</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Children --}}
|
||||||
|
@foreach($root->children as $child)
|
||||||
|
<div x-data="{ editingC: false }">
|
||||||
|
<div class="flex items-center gap-3 px-5 py-2.5 pl-12 border-t border-pink-50/60 hover:bg-pink-50/20 transition-colors">
|
||||||
|
<span class="text-base w-6 text-center shrink-0">{{ $child->icon ?: '↳' }}</span>
|
||||||
|
@if($child->color)
|
||||||
|
<span class="w-2.5 h-2.5 rounded-full shrink-0" style="background:{{ $child->color }}"></span>
|
||||||
|
@endif
|
||||||
|
<div class="flex-1 min-w-0">
|
||||||
|
<div class="text-sm font-medium text-gray-600">↳ {{ $child->name }}</div>
|
||||||
|
<div class="text-xs text-gray-400">{{ $child->clients_count }} client(s)</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex gap-2 shrink-0">
|
||||||
|
<button @click="editingC = !editingC"
|
||||||
|
class="text-xs px-2.5 py-1 rounded-full border border-blue-200 text-blue-500 hover:bg-blue-50">
|
||||||
|
✏️
|
||||||
|
</button>
|
||||||
|
@unless($child->is_system)
|
||||||
|
<form action="{{ route('client-categories.destroy', $child) }}" method="POST"
|
||||||
|
onsubmit="return confirm('Remove subcategory?')">
|
||||||
|
@csrf @method('DELETE')
|
||||||
|
<button class="text-xs px-2.5 py-1 rounded-full border border-red-100 text-red-400 hover:bg-red-50">
|
||||||
|
🗑️
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@endunless
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div x-show="editingC" x-transition style="display:none"
|
||||||
|
class="px-5 py-4 pl-12 bg-pink-50/20 border-t border-pink-50/60">
|
||||||
|
<form action="{{ route('client-categories.update', $child) }}" method="POST"
|
||||||
|
class="grid grid-cols-2 sm:grid-cols-4 gap-3 items-end">
|
||||||
|
@csrf @method('PUT')
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Name</label>
|
||||||
|
<input type="text" name="name" required value="{{ $child->name }}" class="input-soft">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Parent</label>
|
||||||
|
<select name="parent_id" class="input-soft">
|
||||||
|
<option value="">— Root —</option>
|
||||||
|
@foreach($parents as $p)
|
||||||
|
@if($p->id !== $child->id)
|
||||||
|
<option value="{{ $p->id }}" {{ $child->parent_id == $p->id ? 'selected' : '' }}>
|
||||||
|
{{ $p->icon }} {{ $p->name }}
|
||||||
|
</option>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Icon</label>
|
||||||
|
<input type="text" name="icon" value="{{ $child->icon }}" maxlength="10" class="input-soft">
|
||||||
|
</div>
|
||||||
|
<div class="flex items-end gap-2">
|
||||||
|
<div class="flex-1">
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Color</label>
|
||||||
|
<input type="color" name="color" value="{{ $child->color ?: '#FFB7C5' }}"
|
||||||
|
class="w-full h-[42px] rounded-2xl border border-pink-200 cursor-pointer p-1 bg-white">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn-sakura px-3 py-2.5 text-sm shrink-0">Save</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@empty
|
||||||
|
<div class="text-center py-14 text-gray-400">
|
||||||
|
<div class="text-4xl mb-2">🏷️</div>
|
||||||
|
<p class="text-sm">No categories yet. Add your first one above.</p>
|
||||||
|
</div>
|
||||||
|
@endforelse
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
@@ -42,6 +42,22 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">🏷️ Category</label>
|
||||||
|
<select name="category_id" class="input-soft">
|
||||||
|
<option value="">— No Category —</option>
|
||||||
|
@foreach($categoryTree as $parent)
|
||||||
|
<option value="{{ $parent->id }}" {{ old('category_id') == $parent->id ? 'selected' : '' }}>
|
||||||
|
{{ $parent->icon }} {{ $parent->name }}
|
||||||
|
</option>
|
||||||
|
@foreach($parent->children as $child)
|
||||||
|
<option value="{{ $child->id }}" {{ old('category_id') == $child->id ? 'selected' : '' }}>
|
||||||
|
↳ {{ $child->icon }} {{ $child->name }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,22 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">🏷️ Category</label>
|
||||||
|
<select name="category_id" class="input-soft">
|
||||||
|
<option value="">— No Category —</option>
|
||||||
|
@foreach($categoryTree as $parent)
|
||||||
|
<option value="{{ $parent->id }}" {{ old('category_id', $client->category_id) == $parent->id ? 'selected' : '' }}>
|
||||||
|
{{ $parent->icon }} {{ $parent->name }}
|
||||||
|
</option>
|
||||||
|
@foreach($parent->children as $child)
|
||||||
|
<option value="{{ $child->id }}" {{ old('category_id', $client->category_id) == $child->id ? 'selected' : '' }}>
|
||||||
|
↳ {{ $child->icon }} {{ $child->name }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -5,33 +5,117 @@
|
|||||||
@section('page-subtitle', 'Manage your brand partners and contacts')
|
@section('page-subtitle', 'Manage your brand partners and contacts')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-5">
|
|
||||||
<div class="relative">
|
{{-- ── Toolbar + collapsible filter ───────────────────────── --}}
|
||||||
<input type="text" placeholder="Search clients..." class="input-soft pl-9 text-sm"
|
<div x-data="{ open: {{ request('category') || request('status') ? 'true' : 'false' }} }">
|
||||||
oninput="filterClients(this.value)" id="search-input">
|
|
||||||
<span class="absolute left-3 top-2.5 text-gray-400 text-sm">🔍</span>
|
<div class="flex items-center justify-between gap-2 mb-3">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<a href="{{ route('clients.create') }}" class="btn-sakura text-sm">+ Add</a>
|
||||||
|
@if(request('category') || request('status'))
|
||||||
|
<a href="{{ route('clients.index') }}"
|
||||||
|
class="text-xs px-3 py-2 rounded-full border border-gray-200 text-gray-500 hover:bg-gray-50 flex items-center gap-1">
|
||||||
|
✕ Clear filters
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<a href="{{ route('clients.create') }}" class="btn-sakura text-sm text-center">+ Add Client</a>
|
<button @click="open = !open"
|
||||||
|
class="flex items-center gap-1.5 text-xs px-3 py-2 rounded-full border transition-colors"
|
||||||
|
:class="open ? 'border-pink-300 bg-pink-50 text-pink-600' : 'border-gray-200 text-gray-500 hover:bg-gray-50'">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" d="M3 4h18M7 10h10M11 16h2"/>
|
||||||
|
</svg>
|
||||||
|
Filter
|
||||||
|
@if(request('category') || request('status'))
|
||||||
|
<span class="w-2 h-2 rounded-full bg-pink-400 inline-block ml-0.5"></span>
|
||||||
|
@endif
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- ── Filters panel (collapsible) ────────────────────────── --}}
|
||||||
|
<div x-show="open" x-transition.duration.150ms>
|
||||||
|
<form method="GET" action="{{ route('clients.index') }}" id="filter-form" class="cat-card p-3 mb-4">
|
||||||
|
{{-- Row 1: search + dropdowns --}}
|
||||||
|
<div class="flex flex-col sm:flex-row sm:items-center gap-2">
|
||||||
|
{{-- Search (fills remaining space on desktop) --}}
|
||||||
|
<div class="relative flex-1 min-w-0">
|
||||||
|
<span class="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-sm pointer-events-none">🔍</span>
|
||||||
|
<input type="text" placeholder="Filter by name…" class="input-soft pl-9 text-sm py-2 w-full"
|
||||||
|
oninput="filterClients(this.value)" id="search-input">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Category dropdown --}}
|
||||||
|
<select name="category" class="input-soft text-sm py-2 sm:w-48 shrink-0"
|
||||||
|
onchange="this.form.submit()">
|
||||||
|
<option value="">All Categories</option>
|
||||||
|
@foreach($categories as $parent)
|
||||||
|
<option value="{{ $parent->id }}"
|
||||||
|
{{ request('category') == $parent->id ? 'selected' : '' }}>
|
||||||
|
{{ $parent->icon }} {{ $parent->name }}
|
||||||
|
</option>
|
||||||
|
@foreach($parent->children as $child)
|
||||||
|
<option value="{{ $child->id }}"
|
||||||
|
{{ request('category') == $child->id ? 'selected' : '' }}>
|
||||||
|
↳ {{ $child->name }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
|
||||||
|
{{-- Status dropdown --}}
|
||||||
|
<select name="status" class="input-soft text-sm py-2 sm:w-36 shrink-0"
|
||||||
|
onchange="this.form.submit()">
|
||||||
|
<option value="">All Statuses</option>
|
||||||
|
@foreach($statuses as $s)
|
||||||
|
<option value="{{ $s->value }}" {{ request('status') === $s->value ? 'selected' : '' }}>
|
||||||
|
{{ $s->label() }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>{{-- end x-data --}}
|
||||||
|
|
||||||
|
{{-- ── Client grid ─────────────────────────────────────────── --}}
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4" id="clients-grid">
|
<div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4" id="clients-grid">
|
||||||
@forelse($clients as $client)
|
@forelse($clients as $client)
|
||||||
<div class="cat-card p-4 flex flex-col gap-3 hover:shadow-md transition-shadow duration-200"
|
<div class="cat-card p-4 flex flex-col gap-3 hover:shadow-md transition-shadow duration-200"
|
||||||
data-name="{{ strtolower($client->name) }}">
|
data-name="{{ strtolower($client->name) }} {{ strtolower($client->company ?? '') }}">
|
||||||
|
|
||||||
<div class="flex items-start gap-3">
|
<div class="flex items-start gap-3">
|
||||||
|
@if($client->avatar)
|
||||||
|
<div class="w-11 h-11 rounded-2xl overflow-hidden shrink-0 shadow-sm ring-2 ring-pink-100">
|
||||||
|
<img src="{{ \Illuminate\Support\Facades\Storage::url($client->avatar) }}"
|
||||||
|
alt="{{ $client->name }}"
|
||||||
|
class="w-full h-full object-cover">
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
<div class="w-11 h-11 rounded-2xl flex items-center justify-center text-white font-bold text-base shadow-sm shrink-0"
|
<div class="w-11 h-11 rounded-2xl flex items-center justify-center text-white font-bold text-base shadow-sm shrink-0"
|
||||||
style="background: linear-gradient(135deg, #FFB7C5, #E8D5F5);">
|
style="background: linear-gradient(135deg, {{ $client->category?->color ?? '#FFB7C5' }}, #E8D5F5);">
|
||||||
{{ $client->initials }}
|
{{ $client->initials }}
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
<div class="flex-1 min-w-0">
|
<div class="flex-1 min-w-0">
|
||||||
<div class="flex items-center gap-2 flex-wrap">
|
<div class="flex items-center gap-2 flex-wrap">
|
||||||
<h3 class="font-bold text-gray-800 text-sm truncate">{{ $client->name }}</h3>
|
<h3 class="font-bold text-gray-800 text-sm truncate">{{ $client->name }}</h3>
|
||||||
<span class="badge {{ $client->status->badgeClass() }} text-xs shrink-0">{{ $client->status->label() }}</span>
|
<span class="badge {{ $client->status->badgeClass() }} text-xs shrink-0">
|
||||||
|
{{ $client->status->label() }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@if($client->company)
|
@if($client->company)
|
||||||
<div class="text-xs text-gray-400 truncate">{{ $client->company }}</div>
|
<div class="text-xs text-gray-400 truncate">{{ $client->company }}</div>
|
||||||
@endif
|
@endif
|
||||||
|
@if($client->category)
|
||||||
|
<div class="text-xs mt-0.5" style="color: {{ $client->category->color === '#FDFD96' ? '#8B8000' : $client->category->color }}">
|
||||||
|
{{ $client->category->icon }} {{ $client->category->name }}
|
||||||
|
@if($client->category->parent)
|
||||||
|
<span class="text-gray-300 mx-0.5">·</span>
|
||||||
|
{{ $client->category->parent->name }}
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -62,18 +146,29 @@
|
|||||||
|
|
||||||
<div class="flex gap-2 pt-2 border-t border-pink-50">
|
<div class="flex gap-2 pt-2 border-t border-pink-50">
|
||||||
<a href="{{ route('clients.show', $client) }}" class="btn-sakura text-xs py-1.5 flex-1 text-center">View</a>
|
<a href="{{ route('clients.show', $client) }}" class="btn-sakura text-xs py-1.5 flex-1 text-center">View</a>
|
||||||
<a href="{{ route('clients.edit', $client) }}" class="flex-1 text-center text-xs py-1.5 px-3 rounded-full border border-pink-200 text-gray-600 hover:bg-pink-50">Edit</a>
|
<a href="{{ route('clients.edit', $client) }}"
|
||||||
<form action="{{ route('clients.destroy', $client) }}" method="POST" onsubmit="return confirm('Remove this client?')">
|
class="flex-1 text-center text-xs py-1.5 px-3 rounded-full border border-pink-200 text-gray-600 hover:bg-pink-50">
|
||||||
|
Edit
|
||||||
|
</a>
|
||||||
|
{{-- Share button disabled --}}
|
||||||
|
<form action="{{ route('clients.destroy', $client) }}" method="POST"
|
||||||
|
onsubmit="return confirm('Remove this client?')">
|
||||||
@csrf @method('DELETE')
|
@csrf @method('DELETE')
|
||||||
<button class="text-xs py-1.5 px-3 rounded-full border border-red-100 text-red-400 hover:bg-red-50">Del</button>
|
<button class="text-xs py-1.5 px-3 rounded-full border border-red-100 text-red-400 hover:bg-red-50">
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@empty
|
@empty
|
||||||
<div class="col-span-full text-center py-16 text-gray-400">
|
<div class="col-span-full text-center py-16 text-gray-400">
|
||||||
<span class="text-5xl block mb-3">🐱</span>
|
<span class="text-5xl block mb-3">🐱</span>
|
||||||
<p class="text-base font-medium">No clients yet!</p>
|
<p class="text-base font-medium">No clients found!</p>
|
||||||
|
@if(request('category') || request('status'))
|
||||||
|
<a href="{{ route('clients.index') }}" class="text-sm text-pink-500 mt-2 block">Clear filters</a>
|
||||||
|
@else
|
||||||
<a href="{{ route('clients.create') }}" class="btn-sakura mt-4 inline-block">Add your first client</a>
|
<a href="{{ route('clients.create') }}" class="btn-sakura mt-4 inline-block">Add your first client</a>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endforelse
|
@endforelse
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,12 +8,55 @@
|
|||||||
<div class="max-w-5xl mx-auto">
|
<div class="max-w-5xl mx-auto">
|
||||||
|
|
||||||
{{-- Profile Header --}}
|
{{-- Profile Header --}}
|
||||||
<div class="cat-card p-4 mb-4">
|
<div class="cat-card p-4 mb-4"
|
||||||
|
x-data="{
|
||||||
|
avatarUrl: '{{ $client->avatar ? asset('storage/' . $client->avatar) : '' }}',
|
||||||
|
uploading: false,
|
||||||
|
async pickAvatar(input) {
|
||||||
|
if (!input.files.length) return;
|
||||||
|
this.uploading = true;
|
||||||
|
const fd = new FormData();
|
||||||
|
fd.append('avatar', input.files[0]);
|
||||||
|
fd.append('_token', document.querySelector('meta[name=csrf-token]').content);
|
||||||
|
const res = await fetch('{{ route('clients.upload-avatar', $client) }}', { method: 'POST', body: fd });
|
||||||
|
const data = await res.json();
|
||||||
|
if (res.ok) this.avatarUrl = data.url + '?t=' + Date.now();
|
||||||
|
this.uploading = false;
|
||||||
|
input.value = '';
|
||||||
|
},
|
||||||
|
async removeAvatar() {
|
||||||
|
if (!confirm('Remove profile picture?')) return;
|
||||||
|
const fd = new FormData();
|
||||||
|
fd.append('_token', document.querySelector('meta[name=csrf-token]').content);
|
||||||
|
fd.append('_method', 'DELETE');
|
||||||
|
await fetch('{{ route('clients.delete-avatar', $client) }}', { method: 'POST', body: fd });
|
||||||
|
this.avatarUrl = '';
|
||||||
|
}
|
||||||
|
}">
|
||||||
<div class="flex items-start gap-4">
|
<div class="flex items-start gap-4">
|
||||||
<div class="w-14 h-14 rounded-3xl flex items-center justify-center text-white font-bold text-xl shadow shrink-0"
|
{{-- Avatar with upload overlay --}}
|
||||||
|
<div class="relative shrink-0 group">
|
||||||
|
<template x-if="avatarUrl">
|
||||||
|
<img :src="avatarUrl" alt="{{ $client->name }}"
|
||||||
|
class="w-16 h-16 rounded-3xl object-cover shadow border border-pink-100">
|
||||||
|
</template>
|
||||||
|
<template x-if="!avatarUrl">
|
||||||
|
<div class="w-16 h-16 rounded-3xl flex items-center justify-center text-white font-bold text-xl shadow"
|
||||||
style="background: linear-gradient(135deg, #FFB7C5, #E8D5F5);">
|
style="background: linear-gradient(135deg, #FFB7C5, #E8D5F5);">
|
||||||
{{ $client->initials }}
|
{{ $client->initials }}
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
|
{{-- Upload overlay --}}
|
||||||
|
<label class="absolute inset-0 rounded-3xl bg-black/30 flex items-center justify-center
|
||||||
|
opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer"
|
||||||
|
:class="{ 'opacity-100': uploading }"
|
||||||
|
title="Change photo">
|
||||||
|
<span x-show="!uploading" class="text-white text-lg">📷</span>
|
||||||
|
<span x-show="uploading" class="text-white text-xs">…</span>
|
||||||
|
<input type="file" accept="image/*" class="hidden" @change="pickAvatar($event.target)">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="flex-1 min-w-0">
|
<div class="flex-1 min-w-0">
|
||||||
<h2 class="text-lg font-bold text-gray-800 leading-tight">{{ $client->name }}</h2>
|
<h2 class="text-lg font-bold text-gray-800 leading-tight">{{ $client->name }}</h2>
|
||||||
@if($client->company) <p class="text-sm text-gray-500">{{ $client->company }}</p> @endif
|
@if($client->company) <p class="text-sm text-gray-500">{{ $client->company }}</p> @endif
|
||||||
@@ -31,13 +74,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{-- Action buttons below on mobile, inline on larger screens --}}
|
|
||||||
<div class="flex gap-2 mt-3">
|
<div class="flex gap-2 mt-3 flex-wrap">
|
||||||
<a href="{{ route('clients.edit', $client) }}" class="btn-sakura text-sm px-4 py-2">Edit</a>
|
<a href="{{ route('clients.edit', $client) }}" class="btn-sakura text-sm px-4 py-2">Edit</a>
|
||||||
<a href="{{ route('invoices.create') }}?client={{ $client->id }}"
|
<a href="{{ route('invoices.create') }}?client={{ $client->id }}"
|
||||||
class="text-sm px-4 py-2 rounded-full border border-pink-200 text-gray-600 hover:bg-pink-50 font-semibold">
|
class="text-sm px-4 py-2 rounded-full border border-pink-200 text-gray-600 hover:bg-pink-50 font-semibold">
|
||||||
🧾 New Invoice
|
🧾 New Invoice
|
||||||
</a>
|
</a>
|
||||||
|
<button x-show="avatarUrl" @click="removeAvatar()"
|
||||||
|
class="text-sm px-4 py-2 rounded-full border border-red-200 text-red-400 hover:bg-red-50 font-semibold">
|
||||||
|
🗑️ Remove Photo
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,9 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
<div class="max-w-2xl mx-auto">
|
<div class="max-w-2xl mx-auto">
|
||||||
<div class="cat-card p-4 lg:p-8">
|
<div class="cat-card p-4 lg:p-8">
|
||||||
<form action="{{ route('content.store') }}" method="POST" class="space-y-4">
|
<form action="{{ route('content.store') }}" method="POST" class="space-y-4"
|
||||||
@csrf
|
x-data="contractCheck('{{ route('contracts.check') }}')"
|
||||||
|
@submit.prevent="submitIfClear($el)">
|
||||||
|
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||||
<div class="sm:col-span-2">
|
<div class="sm:col-span-2">
|
||||||
@@ -40,19 +41,38 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Client</label>
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Client</label>
|
||||||
<select name="client_id" class="input-soft">
|
<select name="client_id" class="input-soft" x-model="clientId" @change="checkContract()">
|
||||||
<option value="">— None —</option>
|
<option value="">— None —</option>
|
||||||
@foreach($clients as $client)
|
@foreach($clients as $client)
|
||||||
<option value="{{ $client->id }}">{{ $client->name }}</option>
|
<option value="{{ $client->id }}">{{ $client->name }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Category</label>
|
||||||
|
<select name="category_id" class="input-soft" x-model="categoryId" @change="checkContract()">
|
||||||
|
<option value="">— None —</option>
|
||||||
|
@foreach($categoryTree as $parent)
|
||||||
|
<option value="{{ $parent->id }}">{{ $parent->icon }} {{ $parent->name }}</option>
|
||||||
|
@foreach($parent->children as $child)
|
||||||
|
<option value="{{ $child->id }}"> ↳ {{ $child->name }}</option>
|
||||||
|
@endforeach
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Target Date</label>
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Target Date</label>
|
||||||
<input type="date" name="target_date" value="{{ old('target_date') }}" class="input-soft">
|
<input type="date" name="target_date" value="{{ old('target_date') }}" class="input-soft">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- Contract warning --}}
|
||||||
|
<div x-show="contractWarning" x-transition
|
||||||
|
class="rounded-2xl bg-amber-50 border border-amber-200 px-4 py-3 text-sm" style="display:none">
|
||||||
|
<div class="font-semibold text-amber-700 mb-1">⚠️ Exclusive Contract Active</div>
|
||||||
|
<p class="text-amber-600 text-xs" x-text="contractMessage"></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
{{-- Storyline Maker --}}
|
{{-- Storyline Maker --}}
|
||||||
<div class="bg-pink-50 rounded-2xl p-4 space-y-3">
|
<div class="bg-pink-50 rounded-2xl p-4 space-y-3">
|
||||||
<h3 class="font-bold text-gray-700 flex items-center gap-2 text-sm">✍️ Storyline Maker</h3>
|
<h3 class="font-bold text-gray-700 flex items-center gap-2 text-sm">✍️ Storyline Maker</h3>
|
||||||
@@ -95,7 +115,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col sm:flex-row gap-3 pt-1">
|
<div class="flex flex-col sm:flex-row gap-3 pt-1">
|
||||||
<button type="submit" class="btn-sakura flex-1 py-3">🎬 Create Brief</button>
|
<button type="submit" class="btn-sakura flex-1 py-3"
|
||||||
|
:class="{ 'opacity-50 cursor-not-allowed': contractWarning }">🎬 Create Brief</button>
|
||||||
<a href="{{ route('content.index') }}"
|
<a href="{{ route('content.index') }}"
|
||||||
class="flex-1 py-3 text-center rounded-full border border-pink-200 text-gray-600 hover:bg-pink-50 font-semibold text-sm">
|
class="flex-1 py-3 text-center rounded-full border border-pink-200 text-gray-600 hover:bg-pink-50 font-semibold text-sm">
|
||||||
Cancel
|
Cancel
|
||||||
@@ -104,4 +125,35 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@push('scripts')
|
||||||
|
<script>
|
||||||
|
function contractCheck(checkUrl) {
|
||||||
|
return {
|
||||||
|
categoryId: '',
|
||||||
|
clientId: '',
|
||||||
|
contractWarning: false,
|
||||||
|
contractMessage: '',
|
||||||
|
async checkContract() {
|
||||||
|
if (!this.categoryId) { this.contractWarning = false; return; }
|
||||||
|
const params = new URLSearchParams({ category_id: this.categoryId, client_id: this.clientId || '' });
|
||||||
|
const res = await fetch(checkUrl + '?' + params);
|
||||||
|
const data = await res.json();
|
||||||
|
if (data) {
|
||||||
|
this.contractWarning = true;
|
||||||
|
this.contractMessage = `"${data.title}" — ${data.client_name} holds exclusive rights in the ${data.category} category until ${data.end_date} (${data.days_left} days left).`;
|
||||||
|
} else {
|
||||||
|
this.contractWarning = false;
|
||||||
|
this.contractMessage = '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
submitIfClear(form) {
|
||||||
|
if (this.contractWarning) {
|
||||||
|
if (!confirm('⚠️ An exclusive contract is active for this category.\n\nAre you sure you want to proceed?')) return;
|
||||||
|
}
|
||||||
|
form.submit();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -43,6 +43,22 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Category</label>
|
||||||
|
<select name="category_id" class="input-soft">
|
||||||
|
<option value="">— None —</option>
|
||||||
|
@foreach($categoryTree as $parent)
|
||||||
|
<option value="{{ $parent->id }}" {{ old('category_id', $brief->category_id) == $parent->id ? 'selected' : '' }}>
|
||||||
|
{{ $parent->icon }} {{ $parent->name }}
|
||||||
|
</option>
|
||||||
|
@foreach($parent->children as $child)
|
||||||
|
<option value="{{ $child->id }}" {{ old('category_id', $brief->category_id) == $child->id ? 'selected' : '' }}>
|
||||||
|
↳ {{ $child->name }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Target Date</label>
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Target Date</label>
|
||||||
<input type="date" name="target_date" value="{{ old('target_date', $brief->target_date?->toDateString()) }}" class="input-soft">
|
<input type="date" name="target_date" value="{{ old('target_date', $brief->target_date?->toDateString()) }}" class="input-soft">
|
||||||
|
|||||||
217
resources/views/contracts/index.blade.php
Normal file
217
resources/views/contracts/index.blade.php
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
@section('title', 'Brand Contracts')
|
||||||
|
@section('page-title', '📋 Brand Contracts')
|
||||||
|
@section('page-subtitle', 'Manage exclusive brand agreements per category')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="max-w-4xl mx-auto space-y-5">
|
||||||
|
|
||||||
|
@if(session('success'))
|
||||||
|
<div x-data="{ show: true }" x-show="show" x-init="setTimeout(() => show = false, 4000)"
|
||||||
|
class="flex items-center justify-between gap-3 bg-green-50 border border-green-200 rounded-2xl px-4 py-3 text-sm text-green-700">
|
||||||
|
<span>{{ session('success') }}</span>
|
||||||
|
<button @click="show = false" class="text-green-500 hover:text-green-700 text-lg leading-none">✕</button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
{{-- Add Contract --}}
|
||||||
|
<div class="cat-card overflow-hidden" x-data="{ open: {{ $errors->any() ? 'true' : 'false' }} }">
|
||||||
|
<div class="flex items-center gap-3 px-5 py-4 border-b border-pink-50">
|
||||||
|
<button type="button" @click="open = !open"
|
||||||
|
class="btn-sakura text-xs"
|
||||||
|
x-text="open ? '✕ Close' : '+ Add New Contract'">
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div x-show="open" x-transition style="display:none">
|
||||||
|
<form action="{{ route('contracts.store') }}" method="POST"
|
||||||
|
class="p-5 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 border-b border-pink-50">
|
||||||
|
@csrf
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Contract Title <span class="text-pink-400">*</span></label>
|
||||||
|
<input type="text" name="title" required maxlength="255"
|
||||||
|
placeholder="e.g. Exclusive – Energy Drinks 2025"
|
||||||
|
class="input-soft" value="{{ old('title') }}">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Brand / Client</label>
|
||||||
|
<select name="client_id" class="input-soft">
|
||||||
|
<option value="">— No specific client —</option>
|
||||||
|
@foreach($clients as $c)
|
||||||
|
<option value="{{ $c->id }}" {{ old('client_id') == $c->id ? 'selected' : '' }}>
|
||||||
|
{{ $c->name }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Category (exclusive) <span class="text-pink-400">*</span></label>
|
||||||
|
<select name="category_id" required class="input-soft">
|
||||||
|
<option value="">— Select category —</option>
|
||||||
|
@foreach($categoryTree as $parent)
|
||||||
|
<option value="{{ $parent->id }}" {{ old('category_id') == $parent->id ? 'selected' : '' }}>
|
||||||
|
{{ $parent->icon }} {{ $parent->name }}
|
||||||
|
</option>
|
||||||
|
@foreach($parent->children as $child)
|
||||||
|
<option value="{{ $child->id }}" {{ old('category_id') == $child->id ? 'selected' : '' }}>
|
||||||
|
↳ {{ $child->name }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Start Date <span class="text-pink-400">*</span></label>
|
||||||
|
<input type="date" name="start_date" required class="input-soft"
|
||||||
|
value="{{ old('start_date', today()->toDateString()) }}">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">End Date <span class="text-pink-400">*</span></label>
|
||||||
|
<input type="date" name="end_date" required class="input-soft"
|
||||||
|
value="{{ old('end_date') }}">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Notes</label>
|
||||||
|
<input type="text" name="notes" maxlength="500" placeholder="Optional notes…"
|
||||||
|
class="input-soft" value="{{ old('notes') }}">
|
||||||
|
</div>
|
||||||
|
<div class="sm:col-span-2 lg:col-span-3 flex justify-end pt-1">
|
||||||
|
<button type="submit" class="btn-sakura px-6 py-2.5">📋 Add Contract</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Contracts List --}}
|
||||||
|
<div class="cat-card overflow-hidden">
|
||||||
|
<div class="flex items-center gap-3 px-5 py-4 border-b border-pink-50">
|
||||||
|
<span class="text-xl">📋</span>
|
||||||
|
<h2 class="font-bold text-gray-700">All Contracts</h2>
|
||||||
|
<span class="ml-auto text-xs bg-pink-100 text-pink-600 font-semibold px-2.5 py-0.5 rounded-full">
|
||||||
|
{{ $contracts->count() }} total
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@forelse($contracts as $contract)
|
||||||
|
<div x-data="{ editing: false }" class="border-b border-pink-50 last:border-0">
|
||||||
|
<div class="flex items-center gap-3 px-5 py-3 hover:bg-pink-50/30 transition-colors">
|
||||||
|
<span class="badge {{ $contract->statusColor }} shrink-0">{{ $contract->statusLabel }}</span>
|
||||||
|
<div class="flex-1 min-w-0">
|
||||||
|
<div class="font-semibold text-gray-700 text-sm truncate">{{ $contract->title }}</div>
|
||||||
|
<div class="text-xs text-gray-400 flex flex-wrap gap-x-3 mt-0.5">
|
||||||
|
@if($contract->client)<span>👤 {{ $contract->client->name }}</span>@endif
|
||||||
|
@if($contract->category)<span>🏷️ {{ $contract->category->fullName }}</span>@endif
|
||||||
|
<span>📅 {{ $contract->start_date->format('d M Y') }} – {{ $contract->end_date->format('d M Y') }}</span>
|
||||||
|
@if($contract->isCurrentlyActive())
|
||||||
|
<span class="text-pink-500 font-medium">{{ $contract->days_remaining }}d left</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@if($contract->notes)
|
||||||
|
<div class="text-xs text-gray-400 mt-0.5 italic truncate">{{ $contract->notes }}</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<div class="flex gap-1.5 shrink-0">
|
||||||
|
<form action="{{ route('contracts.toggle', $contract) }}" method="POST">
|
||||||
|
@csrf @method('PATCH')
|
||||||
|
<button class="text-xs px-2.5 py-1.5 rounded-full border
|
||||||
|
{{ $contract->is_active ? 'border-amber-200 text-amber-500 hover:bg-amber-50' : 'border-green-200 text-green-500 hover:bg-green-50' }}"
|
||||||
|
title="{{ $contract->is_active ? 'Pause' : 'Activate' }}">
|
||||||
|
{{ $contract->is_active ? '⏸️' : '▶️' }}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
<button @click="editing = !editing"
|
||||||
|
class="text-xs px-2.5 py-1.5 rounded-full border border-blue-200 text-blue-500 hover:bg-blue-50">
|
||||||
|
✏️
|
||||||
|
</button>
|
||||||
|
<form action="{{ route('contracts.destroy', $contract) }}" method="POST"
|
||||||
|
onsubmit="return confirm('Delete this contract?')">
|
||||||
|
@csrf @method('DELETE')
|
||||||
|
<button class="text-xs px-2.5 py-1.5 rounded-full border border-red-100 text-red-400 hover:bg-red-50">
|
||||||
|
🗑️
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div x-show="editing" x-transition style="display:none"
|
||||||
|
class="px-5 pb-5 pt-3 bg-pink-50/20 border-t border-pink-50">
|
||||||
|
<form action="{{ route('contracts.update', $contract) }}" method="POST"
|
||||||
|
class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3">
|
||||||
|
@csrf @method('PUT')
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Title</label>
|
||||||
|
<input type="text" name="title" required value="{{ $contract->title }}" class="input-soft">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Brand / Client</label>
|
||||||
|
<select name="client_id" class="input-soft">
|
||||||
|
<option value="">— No specific client —</option>
|
||||||
|
@foreach($clients as $c)
|
||||||
|
<option value="{{ $c->id }}" {{ $contract->client_id == $c->id ? 'selected' : '' }}>{{ $c->name }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Category</label>
|
||||||
|
<select name="category_id" required class="input-soft">
|
||||||
|
<option value="">— Select —</option>
|
||||||
|
@foreach($categoryTree as $parent)
|
||||||
|
<option value="{{ $parent->id }}" {{ $contract->category_id == $parent->id ? 'selected' : '' }}>
|
||||||
|
{{ $parent->icon }} {{ $parent->name }}
|
||||||
|
</option>
|
||||||
|
@foreach($parent->children as $child)
|
||||||
|
<option value="{{ $child->id }}" {{ $contract->category_id == $child->id ? 'selected' : '' }}>
|
||||||
|
↳ {{ $child->name }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Start Date</label>
|
||||||
|
<input type="date" name="start_date" required value="{{ $contract->start_date->toDateString() }}" class="input-soft">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">End Date</label>
|
||||||
|
<input type="date" name="end_date" required value="{{ $contract->end_date->toDateString() }}" class="input-soft">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Notes</label>
|
||||||
|
<input type="text" name="notes" value="{{ $contract->notes }}" class="input-soft">
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-4 sm:col-span-2 lg:col-span-3">
|
||||||
|
<label class="flex items-center gap-2 cursor-pointer">
|
||||||
|
<input type="checkbox" name="is_active" value="1"
|
||||||
|
class="w-4 h-4 accent-pink-400 rounded"
|
||||||
|
{{ $contract->is_active ? 'checked' : '' }}>
|
||||||
|
<span class="text-sm text-gray-600">Active</span>
|
||||||
|
</label>
|
||||||
|
<button type="submit" class="btn-sakura px-5 py-2 text-sm ml-auto">💾 Save</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@empty
|
||||||
|
<div class="text-center py-14 text-gray-400">
|
||||||
|
<div class="text-4xl mb-2">📋</div>
|
||||||
|
<p class="text-sm">No contracts yet. Add your first exclusive agreement above.</p>
|
||||||
|
</div>
|
||||||
|
@endforelse
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- How it works --}}
|
||||||
|
<div class="cat-card overflow-hidden border-blue-100 bg-blue-50/30">
|
||||||
|
<div class="flex items-center gap-3 px-5 py-3 border-b border-blue-100">
|
||||||
|
<span class="text-xl">💡</span>
|
||||||
|
<h2 class="font-semibold text-gray-600 text-sm">How Brand Contracts Work</h2>
|
||||||
|
</div>
|
||||||
|
<ul class="text-xs text-gray-500 space-y-1.5 px-5 py-4">
|
||||||
|
<li>🔒 When a contract is <strong>Active</strong>, creating schedules or content for a competing brand in the same category will show a warning.</li>
|
||||||
|
<li>✅ The contracted brand itself is always allowed — no warning shown.</li>
|
||||||
|
<li>🏷️ Blocking a <strong>parent category</strong> also blocks all its subcategories.</li>
|
||||||
|
<li>📅 Contracts only block during their active date range. Expired contracts are ignored automatically.</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
@@ -45,22 +45,22 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- ── Stat Pills (BELOW schedule) ─────────────────────────── --}}
|
{{-- ── Stat Pills (BELOW schedule) ─────────────────────────── --}}
|
||||||
<div class="grid grid-cols-2 gap-3 mb-4">
|
<div class="grid grid-cols-2 sm:grid-cols-4 gap-3 mb-4">
|
||||||
<div class="stat-pill">
|
<a href="{{ route('clients.index') }}" class="stat-pill hover:shadow-md transition-shadow">
|
||||||
<div class="text-2xl lg:text-3xl font-extrabold text-pink-500">{{ $stats['total_clients'] }}</div>
|
<div class="text-2xl lg:text-3xl font-extrabold text-pink-500">{{ $stats['total_clients'] }}</div>
|
||||||
<div class="text-xs lg:text-sm font-semibold text-gray-600">Total Clients</div>
|
<div class="text-xs lg:text-sm font-semibold text-gray-600">Total Clients</div>
|
||||||
<div class="text-xs text-gray-400">{{ $stats['active_clients'] }} active</div>
|
<div class="text-xs text-gray-400">{{ $stats['active_clients'] }} active</div>
|
||||||
</div>
|
</a>
|
||||||
<div class="stat-pill">
|
<a href="{{ route('schedule.index') }}" class="stat-pill hover:shadow-md transition-shadow">
|
||||||
<div class="text-2xl lg:text-3xl font-extrabold text-purple-500">{{ $stats['upcoming_events'] }}</div>
|
<div class="text-2xl lg:text-3xl font-extrabold text-purple-500">{{ $stats['upcoming_events'] }}</div>
|
||||||
<div class="text-xs lg:text-sm font-semibold text-gray-600">Upcoming Events</div>
|
<div class="text-xs lg:text-sm font-semibold text-gray-600">Upcoming Events</div>
|
||||||
<div class="text-xs text-gray-400">Next 3 months</div>
|
<div class="text-xs text-gray-400">Next 3 months</div>
|
||||||
</div>
|
</a>
|
||||||
<div class="stat-pill">
|
<a href="{{ route('invoices.index') }}" class="stat-pill hover:shadow-md transition-shadow">
|
||||||
<div class="text-2xl lg:text-3xl font-extrabold text-amber-500">{{ $stats['pending_invoices'] }}</div>
|
<div class="text-2xl lg:text-3xl font-extrabold text-amber-500">{{ $stats['pending_invoices'] }}</div>
|
||||||
<div class="text-xs lg:text-sm font-semibold text-gray-600">Pending Invoices</div>
|
<div class="text-xs lg:text-sm font-semibold text-gray-600">Pending Invoices</div>
|
||||||
<div class="text-xs text-gray-400">Awaiting payment</div>
|
<div class="text-xs text-gray-400">Awaiting payment</div>
|
||||||
</div>
|
</a>
|
||||||
<div class="stat-pill">
|
<div class="stat-pill">
|
||||||
<div class="text-lg lg:text-2xl font-extrabold text-emerald-500 leading-tight">
|
<div class="text-lg lg:text-2xl font-extrabold text-emerald-500 leading-tight">
|
||||||
Rp {{ number_format($stats['total_revenue'], 0, ',', '.') }}
|
Rp {{ number_format($stats['total_revenue'], 0, ',', '.') }}
|
||||||
@@ -70,6 +70,25 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- ── Secondary Stats ──────────────────────────────────────── --}}
|
||||||
|
<div class="grid grid-cols-3 gap-3 mb-4">
|
||||||
|
<a href="{{ route('client-categories.index') }}" class="stat-pill hover:shadow-md transition-shadow">
|
||||||
|
<div class="text-2xl font-extrabold text-indigo-500">{{ $stats['total_categories'] }}</div>
|
||||||
|
<div class="text-xs font-semibold text-gray-600">Categories</div>
|
||||||
|
<div class="text-xs text-gray-400">{{ $stats['total_subcategories'] }} subcategories</div>
|
||||||
|
</a>
|
||||||
|
<a href="{{ route('contracts.index') }}" class="stat-pill hover:shadow-md transition-shadow">
|
||||||
|
<div class="text-2xl font-extrabold text-rose-500">{{ $stats['active_contracts'] }}</div>
|
||||||
|
<div class="text-xs font-semibold text-gray-600">Brand Contracts</div>
|
||||||
|
<div class="text-xs text-gray-400">{{ $stats['total_contracts'] }} total</div>
|
||||||
|
</a>
|
||||||
|
<a href="{{ route('files.index') }}" class="stat-pill hover:shadow-md transition-shadow">
|
||||||
|
<div class="text-2xl font-extrabold text-teal-500">{{ $stats['total_files'] }}</div>
|
||||||
|
<div class="text-xs font-semibold text-gray-600">Files Saved</div>
|
||||||
|
<div class="text-xs text-gray-400">In file manager</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
{{-- ── Bottom Row ───────────────────────────────────────────── --}}
|
{{-- ── Bottom Row ───────────────────────────────────────────── --}}
|
||||||
<div class="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
<div class="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
||||||
|
|
||||||
|
|||||||
@@ -6,17 +6,119 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
{{-- ── Upload Form (collapsible on mobile) ─────────────────── --}}
|
{{-- ── Video Player Modal ───────────────────────────────────── --}}
|
||||||
<div class="cat-card p-4 mb-4" x-data="{ open: false }">
|
<div id="video-player-modal"
|
||||||
|
class="fixed inset-0 z-50 flex items-center justify-center bg-black/80 hidden"
|
||||||
|
onclick="if(event.target===this)closeVideoModal()">
|
||||||
|
<div class="relative w-full max-w-3xl mx-4">
|
||||||
|
<div class="flex items-center justify-between mb-3 px-1">
|
||||||
|
<p class="text-white text-sm font-semibold truncate" id="vpm-title"></p>
|
||||||
|
<button onclick="closeVideoModal()"
|
||||||
|
class="text-white/70 hover:text-white text-2xl leading-none ml-4 shrink-0">✕</button>
|
||||||
|
</div>
|
||||||
|
<video id="vpm-player"
|
||||||
|
class="w-full rounded-2xl bg-black shadow-2xl"
|
||||||
|
controls controlsList="nodownload"
|
||||||
|
style="max-height:70vh">
|
||||||
|
</video>
|
||||||
|
<div class="flex items-center justify-between mt-3 px-1 text-xs text-white/60">
|
||||||
|
<span id="vpm-meta"></span>
|
||||||
|
<a id="vpm-dl" href="#" target="_blank"
|
||||||
|
class="text-pink-300 hover:text-pink-200 font-medium">⬇️ Download</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- ── File Detail Popup Modal ──────────────────────────────── --}}
|
||||||
|
<div id="file-detail-modal"
|
||||||
|
class="fixed inset-0 z-50 flex items-end sm:items-center justify-center bg-black/40 hidden"
|
||||||
|
onclick="if(event.target===this)this.classList.add('hidden')">
|
||||||
|
<div class="cat-card p-5 w-full sm:max-w-sm rounded-b-none sm:rounded-3xl shadow-xl mx-0 sm:mx-4">
|
||||||
|
<div class="w-10 h-1 bg-gray-200 rounded-full mx-auto mb-4 sm:hidden"></div>
|
||||||
|
<div class="flex items-center justify-between mb-3">
|
||||||
|
<h3 class="font-bold text-gray-800 text-base" id="fdm-name">File</h3>
|
||||||
|
<button onclick="document.getElementById('file-detail-modal').classList.add('hidden')"
|
||||||
|
class="text-gray-400 hover:text-gray-600 text-xl leading-none">✕</button>
|
||||||
|
</div>
|
||||||
|
<div id="fdm-preview" class="mb-3 flex justify-center"></div>
|
||||||
|
<div class="text-sm text-gray-600 space-y-1.5" id="fdm-body"></div>
|
||||||
|
<div class="flex gap-2 mt-4">
|
||||||
|
<a id="fdm-view-btn" href="#" target="_blank"
|
||||||
|
class="btn-sakura flex-1 text-center py-2 text-sm">View / Download</a>
|
||||||
|
<button onclick="document.getElementById('file-detail-modal').classList.add('hidden')"
|
||||||
|
class="flex-1 py-2 rounded-full border border-pink-200 text-gray-600 text-sm hover:bg-pink-50">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- ── Upload Form (collapsible) ────────────────────────────── --}}
|
||||||
|
<div class="cat-card p-4 mb-4" id="upload-panel"
|
||||||
|
x-data="{
|
||||||
|
open: false,
|
||||||
|
uploading: false,
|
||||||
|
progress: 0,
|
||||||
|
statusMsg: '',
|
||||||
|
statusOk: true,
|
||||||
|
|
||||||
|
submitUpload(form) {
|
||||||
|
const fd = new FormData(form);
|
||||||
|
const xhr = new XMLHttpRequest();
|
||||||
|
|
||||||
|
xhr.upload.addEventListener('progress', (e) => {
|
||||||
|
if (e.lengthComputable) {
|
||||||
|
this.progress = Math.round((e.loaded / e.total) * 100);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
xhr.addEventListener('load', () => {
|
||||||
|
this.uploading = false;
|
||||||
|
if (xhr.status >= 200 && xhr.status < 300) {
|
||||||
|
this.statusOk = true;
|
||||||
|
this.statusMsg = '✅ File uploaded successfully!';
|
||||||
|
this.progress = 100;
|
||||||
|
form.reset();
|
||||||
|
setTimeout(() => {
|
||||||
|
this.open = false;
|
||||||
|
this.statusMsg = '';
|
||||||
|
this.progress = 0;
|
||||||
|
window.location.reload();
|
||||||
|
}, 1200);
|
||||||
|
} else {
|
||||||
|
this.statusOk = false;
|
||||||
|
try {
|
||||||
|
const body = JSON.parse(xhr.responseText);
|
||||||
|
this.statusMsg = body.message ?? 'Upload failed. Please try again.';
|
||||||
|
} catch {
|
||||||
|
this.statusMsg = 'Upload failed. Please try again.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
xhr.addEventListener('error', () => {
|
||||||
|
this.uploading = false;
|
||||||
|
this.statusOk = false;
|
||||||
|
this.statusMsg = 'Network error. Please try again.';
|
||||||
|
});
|
||||||
|
|
||||||
|
xhr.open('POST', form.action);
|
||||||
|
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||||
|
xhr.setRequestHeader('Accept', 'application/json');
|
||||||
|
this.uploading = true;
|
||||||
|
this.progress = 0;
|
||||||
|
this.statusMsg = '';
|
||||||
|
xhr.send(fd);
|
||||||
|
}
|
||||||
|
}">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<h3 class="text-sm font-bold text-gray-700 flex items-center gap-2">📤 Upload File</h3>
|
<h3 class="text-sm font-bold text-gray-700 flex items-center gap-2">📤 Upload File</h3>
|
||||||
<button class="btn-sakura text-xs px-4 py-1.5" @click="open = !open"
|
<button class="btn-sakura text-xs px-4 py-1.5" @click="open = !open; statusMsg = ''; progress = 0;"
|
||||||
x-text="open ? '✕ Close' : '+ Upload'"></button>
|
x-text="open ? '✕ Close' : '+ Upload'"></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form x-show="open" x-transition
|
<div x-show="open" x-transition>
|
||||||
action="{{ route('files.store') }}" method="POST" enctype="multipart/form-data"
|
<form action="{{ route('files.store') }}" method="POST" enctype="multipart/form-data"
|
||||||
class="mt-4 grid grid-cols-1 sm:grid-cols-3 gap-3">
|
class="mt-4 grid grid-cols-1 sm:grid-cols-3 gap-3"
|
||||||
|
@submit.prevent="submitUpload($el)">
|
||||||
@csrf
|
@csrf
|
||||||
<div class="sm:col-span-3">
|
<div class="sm:col-span-3">
|
||||||
<label class="block text-xs font-semibold text-gray-600 mb-1">
|
<label class="block text-xs font-semibold text-gray-600 mb-1">
|
||||||
@@ -57,9 +159,33 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="sm:flex sm:items-end">
|
<div class="sm:flex sm:items-end">
|
||||||
<button type="submit" class="btn-sakura w-full py-2.5">📤 Upload</button>
|
<button type="submit" class="btn-sakura w-full py-2.5" :disabled="uploading">
|
||||||
|
<span x-show="!uploading">📤 Upload</span>
|
||||||
|
<span x-show="uploading">Uploading…</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
{{-- Progress Bar --}}
|
||||||
|
<div x-show="uploading || progress > 0" x-transition class="mt-3">
|
||||||
|
<div class="flex items-center justify-between text-xs text-gray-500 mb-1">
|
||||||
|
<span>Uploading…</span>
|
||||||
|
<span x-text="progress + '%'"></span>
|
||||||
|
</div>
|
||||||
|
<div class="w-full bg-pink-100 rounded-full h-2.5 overflow-hidden">
|
||||||
|
<div class="h-2.5 rounded-full transition-all duration-200"
|
||||||
|
style="background:#FFB7C5"
|
||||||
|
:style="'width:' + progress + '%'"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Status Message --}}
|
||||||
|
<div x-show="statusMsg" x-transition
|
||||||
|
class="mt-3 px-4 py-2.5 rounded-xl text-sm font-medium"
|
||||||
|
:class="statusOk ? 'bg-green-50 text-green-700' : 'bg-red-50 text-red-600'"
|
||||||
|
x-text="statusMsg">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- ── Folder Filter Chips ──────────────────────────────────── --}}
|
{{-- ── Folder Filter Chips ──────────────────────────────────── --}}
|
||||||
@@ -88,15 +214,37 @@
|
|||||||
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-3">
|
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-3">
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@php $fileData = ['name' => $file->name ?: $file->original_name, 'url' => $file->url, 'size' => $file->human_size, 'folder' => $file->folder, 'client' => $file->client?->name, 'is_image' => $file->is_image, 'is_video' => $file->is_video, 'icon' => $file->icon, 'created_at' => $file->created_at->format('d M Y')] @endphp
|
||||||
<div class="cat-card p-3 flex flex-col gap-2">
|
<div class="cat-card p-3 flex flex-col gap-2">
|
||||||
{{-- Preview / Icon --}}
|
{{-- Preview / Icon --}}
|
||||||
@if($file->is_image)
|
@if($file->is_image)
|
||||||
<div class="w-full aspect-square rounded-2xl overflow-hidden bg-pink-50">
|
<div class="w-full aspect-square rounded-2xl overflow-hidden bg-pink-50 cursor-pointer"
|
||||||
|
onclick="showFileDetail({{ json_encode($fileData) }})">
|
||||||
<img src="{{ $file->url }}" alt="{{ $file->name }}"
|
<img src="{{ $file->url }}" alt="{{ $file->name }}"
|
||||||
class="w-full h-full object-cover">
|
class="w-full h-full object-cover">
|
||||||
</div>
|
</div>
|
||||||
|
@elseif($file->is_video)
|
||||||
|
<div class="w-full aspect-square rounded-2xl overflow-hidden bg-gray-900 relative cursor-pointer group"
|
||||||
|
onclick="openVideoPlayer({{ json_encode($fileData) }})">
|
||||||
|
{{-- Native video poster (browser generates a frame) --}}
|
||||||
|
<video src="{{ $file->url }}"
|
||||||
|
class="w-full h-full object-cover opacity-80"
|
||||||
|
preload="metadata"
|
||||||
|
muted playsinline
|
||||||
|
style="pointer-events:none">
|
||||||
|
</video>
|
||||||
|
{{-- Play overlay --}}
|
||||||
|
<div class="absolute inset-0 flex items-center justify-center
|
||||||
|
bg-black/20 group-hover:bg-black/40 transition-colors">
|
||||||
|
<div class="w-12 h-12 rounded-full bg-white/90 flex items-center justify-center shadow-lg
|
||||||
|
group-hover:scale-110 transition-transform">
|
||||||
|
<span class="text-gray-800 text-xl ml-0.5">▶</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@else
|
@else
|
||||||
<div class="w-full aspect-square rounded-2xl bg-pink-50 flex items-center justify-center text-4xl">
|
<div class="w-full aspect-square rounded-2xl bg-pink-50 flex items-center justify-center text-4xl cursor-pointer"
|
||||||
|
onclick="showFileDetail({{ json_encode($fileData) }})">
|
||||||
{{ $file->icon }}
|
{{ $file->icon }}
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@@ -124,7 +272,7 @@
|
|||||||
<form action="{{ route('files.destroy', $file) }}" method="POST"
|
<form action="{{ route('files.destroy', $file) }}" method="POST"
|
||||||
onsubmit="return confirm('Delete this file?')">
|
onsubmit="return confirm('Delete this file?')">
|
||||||
@csrf @method('DELETE')
|
@csrf @method('DELETE')
|
||||||
<button class="text-xs py-1.5 px-3 rounded-full border border-red-100 text-red-400 hover:bg-red-50">
|
<button class="text-xs py-1.5 px-2.5 rounded-full border border-red-100 text-red-400 hover:bg-red-50">
|
||||||
✕
|
✕
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
@@ -138,11 +286,66 @@
|
|||||||
<div class="text-center py-16 text-gray-400">
|
<div class="text-center py-16 text-gray-400">
|
||||||
<span class="text-5xl block mb-3">📁</span>
|
<span class="text-5xl block mb-3">📁</span>
|
||||||
<p class="text-sm">No files yet.</p>
|
<p class="text-sm">No files yet.</p>
|
||||||
<button onclick="document.querySelector('[\\@click=\\'open = !open\\']').click()"
|
<button onclick="document.getElementById('upload-panel')._x_dataStack[0].open = true; document.getElementById('upload-panel').scrollIntoView({behavior:'smooth'})"
|
||||||
class="btn-sakura mt-4 inline-block text-sm">Upload your first file</button>
|
class="btn-sakura mt-4 inline-block text-sm">Upload your first file</button>
|
||||||
</div>
|
</div>
|
||||||
@endforelse
|
@endforelse
|
||||||
|
|
||||||
<div class="mt-4">{{ $files->links() }}</div>
|
<div class="mt-4">{{ $files->links() }}</div>
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script>
|
||||||
|
function showFileDetail(file) {
|
||||||
|
document.getElementById('fdm-name').textContent = file.name;
|
||||||
|
document.getElementById('fdm-view-btn').href = file.url;
|
||||||
|
|
||||||
|
const preview = document.getElementById('fdm-preview');
|
||||||
|
if (file.is_image) {
|
||||||
|
preview.innerHTML = `<img src="${file.url}" alt="${file.name}" class="max-h-48 rounded-2xl object-contain border border-pink-100">`;
|
||||||
|
} else {
|
||||||
|
preview.innerHTML = `<span class="text-6xl">${file.icon}</span>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const rows = [
|
||||||
|
['Size', file.size],
|
||||||
|
['Folder', file.folder],
|
||||||
|
file.client ? ['Client', file.client] : null,
|
||||||
|
['Uploaded', file.created_at],
|
||||||
|
].filter(Boolean);
|
||||||
|
|
||||||
|
document.getElementById('fdm-body').innerHTML = rows.map(([label, value]) =>
|
||||||
|
`<div class="flex gap-2"><span class="text-gray-400 w-16 shrink-0">${label}</span><span class="font-medium text-gray-700 truncate">${value}</span></div>`
|
||||||
|
).join('');
|
||||||
|
|
||||||
|
document.getElementById('file-detail-modal').classList.remove('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
function openVideoPlayer(file) {
|
||||||
|
const player = document.getElementById('vpm-player');
|
||||||
|
player.src = file.url;
|
||||||
|
player.load();
|
||||||
|
|
||||||
|
document.getElementById('vpm-title').textContent = file.name;
|
||||||
|
document.getElementById('vpm-meta').textContent = file.size + (file.client ? ' · ' + file.client : '');
|
||||||
|
document.getElementById('vpm-dl').href = file.url;
|
||||||
|
|
||||||
|
document.getElementById('video-player-modal').classList.remove('hidden');
|
||||||
|
document.body.style.overflow = 'hidden';
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeVideoModal() {
|
||||||
|
const player = document.getElementById('vpm-player');
|
||||||
|
player.pause();
|
||||||
|
player.src = '';
|
||||||
|
document.getElementById('video-player-modal').classList.add('hidden');
|
||||||
|
document.body.style.overflow = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close video modal on Escape
|
||||||
|
document.addEventListener('keydown', e => {
|
||||||
|
if (e.key === 'Escape') closeVideoModal();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
111
resources/views/gate/login.blade.php
Normal file
111
resources/views/gate/login.blade.php
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" data-theme="light">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta name="theme-color" content="#FFB7C5">
|
||||||
|
<title>KOL Manager — Login</title>
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||||
|
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
||||||
|
</head>
|
||||||
|
<body class="bg-cream font-sans antialiased min-h-screen flex items-center justify-center px-4"
|
||||||
|
x-data="{ show: false, shaking: false }">
|
||||||
|
|
||||||
|
{{-- ── Decorative blobs ───────────────────────────────────────── --}}
|
||||||
|
<div class="fixed inset-0 overflow-hidden pointer-events-none select-none" aria-hidden="true">
|
||||||
|
<div class="absolute -top-32 -left-32 w-96 h-96 rounded-full opacity-20"
|
||||||
|
style="background: radial-gradient(circle, #FFB7C5, transparent)"></div>
|
||||||
|
<div class="absolute -bottom-32 -right-32 w-96 h-96 rounded-full opacity-20"
|
||||||
|
style="background: radial-gradient(circle, #E8D5F5, transparent)"></div>
|
||||||
|
<div class="absolute top-1/2 left-1/4 w-48 h-48 rounded-full opacity-10"
|
||||||
|
style="background: radial-gradient(circle, #FFC8DD, transparent)"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- ── Login card ─────────────────────────────────────────────── --}}
|
||||||
|
<div class="relative z-10 w-full max-w-sm">
|
||||||
|
|
||||||
|
{{-- Logo / header --}}
|
||||||
|
<div class="text-center mb-8 select-none">
|
||||||
|
<div class="text-7xl mb-3 inline-block animate-bounce" style="animation-duration:2s">🐱</div>
|
||||||
|
<h1 class="text-2xl font-extrabold text-pink-500 leading-tight">KOL Manager</h1>
|
||||||
|
<p class="text-sm text-gray-400 mt-1">Your Purr-fect Assistant</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Card --}}
|
||||||
|
<div class="bg-white rounded-3xl shadow-xl border border-pink-100 p-8">
|
||||||
|
|
||||||
|
<h2 class="text-base font-bold text-gray-700 mb-1">Welcome back 👋</h2>
|
||||||
|
<p class="text-xs text-gray-400 mb-6">Enter the app password to continue.</p>
|
||||||
|
|
||||||
|
{{-- Error --}}
|
||||||
|
@error('password')
|
||||||
|
<div class="flex items-center gap-2 bg-red-50 border border-red-200 text-red-600 text-xs px-4 py-3 rounded-2xl mb-4"
|
||||||
|
x-data x-init="$el.closest('[x-data]').shaking = true; setTimeout(() => $el.closest('[x-data]').shaking = false, 500)">
|
||||||
|
<span class="text-base">😿</span>
|
||||||
|
<span>{{ $message }}</span>
|
||||||
|
</div>
|
||||||
|
@enderror
|
||||||
|
|
||||||
|
<form method="POST" action="{{ route('gate.attempt') }}"
|
||||||
|
:class="shaking ? 'animate-[shake_0.4s_ease-in-out]' : ''">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
{{-- Password field --}}
|
||||||
|
<div class="relative mb-5">
|
||||||
|
<label for="password" class="block text-xs font-semibold text-gray-500 mb-1.5">
|
||||||
|
Password
|
||||||
|
</label>
|
||||||
|
<div class="relative">
|
||||||
|
<input
|
||||||
|
:type="show ? 'text' : 'password'"
|
||||||
|
id="password"
|
||||||
|
name="password"
|
||||||
|
autocomplete="current-password"
|
||||||
|
autofocus
|
||||||
|
placeholder="Enter password…"
|
||||||
|
class="w-full rounded-2xl border border-pink-100 bg-pink-50/40 px-4 py-3 pr-11 text-sm text-gray-700
|
||||||
|
placeholder-gray-300 outline-none transition
|
||||||
|
focus:border-pink-300 focus:ring-2 focus:ring-pink-100
|
||||||
|
@error('password') border-red-300 bg-red-50/40 @enderror"
|
||||||
|
>
|
||||||
|
{{-- Show/hide toggle --}}
|
||||||
|
<button type="button"
|
||||||
|
@click="show = !show"
|
||||||
|
class="absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-pink-400 transition-colors select-none"
|
||||||
|
tabindex="-1"
|
||||||
|
:title="show ? 'Hide password' : 'Show password'">
|
||||||
|
<span x-text="show ? '🙈' : '👁️'" class="text-base leading-none"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Submit --}}
|
||||||
|
<button type="submit"
|
||||||
|
class="w-full py-3 rounded-2xl font-bold text-sm text-white shadow-md
|
||||||
|
transition-all duration-200 active:scale-95 hover:shadow-lg hover:brightness-105"
|
||||||
|
style="background: linear-gradient(135deg, #FFB7C5, #E8A0B4)">
|
||||||
|
🐾 Enter the App
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Footer hint --}}
|
||||||
|
<p class="text-center text-xs text-gray-400 mt-5">
|
||||||
|
<!-- Session lasts 24 hours after login. -->
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Shake keyframe --}}
|
||||||
|
<style>
|
||||||
|
@keyframes shake {
|
||||||
|
0%, 100% { transform: translateX(0); }
|
||||||
|
20% { transform: translateX(-6px); }
|
||||||
|
40% { transform: translateX(6px); }
|
||||||
|
60% { transform: translateX(-4px); }
|
||||||
|
80% { transform: translateX(4px); }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -31,9 +31,9 @@
|
|||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Currency</label>
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Currency</label>
|
||||||
<select name="currency" class="input-soft">
|
<select name="currency" class="input-soft">
|
||||||
<option value="IDR" selected>IDR (Rupiah)</option>
|
@foreach(['IDR' => 'IDR (Rupiah)', 'USD' => 'USD (Dollar)', 'SGD' => 'SGD', 'MYR' => 'MYR (Ringgit)'] as $code => $label)
|
||||||
<option value="USD">USD (Dollar)</option>
|
<option value="{{ $code }}" {{ old('currency', $invoiceSettings->default_currency ?? 'IDR') === $code ? 'selected' : '' }}>{{ $label }}</option>
|
||||||
<option value="SGD">SGD</option>
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Tax Rate (%)</label>
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Tax Rate (%)</label>
|
||||||
<input type="number" name="tax_rate" x-model="taxRate" @input="recalc()"
|
<input type="number" name="tax_rate" x-model="taxRate" @input="recalc()"
|
||||||
value="{{ old('tax_rate', 11) }}" class="input-soft" step="0.01">
|
value="{{ old('tax_rate', $invoiceSettings->default_tax_rate ?? 11) }}" class="input-soft" step="0.01">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -93,6 +93,18 @@
|
|||||||
<button type="button" @click="removeItem(index)"
|
<button type="button" @click="removeItem(index)"
|
||||||
class="text-red-400 hover:text-red-600 text-lg shrink-0 pt-4">✕</button>
|
class="text-red-400 hover:text-red-600 text-lg shrink-0 pt-4">✕</button>
|
||||||
</div>
|
</div>
|
||||||
|
{{-- Taxable checkbox --}}
|
||||||
|
<div class="mt-2 flex items-center gap-2">
|
||||||
|
<input type="hidden" :name="`items[${index}][is_taxable]`" value="0">
|
||||||
|
<input type="checkbox" :name="`items[${index}][is_taxable]`"
|
||||||
|
:id="`taxable_${index}`"
|
||||||
|
x-model="item.is_taxable" @change="recalc()"
|
||||||
|
value="1"
|
||||||
|
class="w-3.5 h-3.5 accent-pink-400">
|
||||||
|
<label :for="`taxable_${index}`" class="text-xs text-gray-500 cursor-pointer select-none">
|
||||||
|
Taxable
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@@ -101,34 +113,43 @@
|
|||||||
{{-- Totals --}}
|
{{-- Totals --}}
|
||||||
<div class="bg-pink-50 rounded-2xl p-4 mb-5">
|
<div class="bg-pink-50 rounded-2xl p-4 mb-5">
|
||||||
<div class="flex justify-between text-sm py-1">
|
<div class="flex justify-between text-sm py-1">
|
||||||
<span class="text-gray-500">Subtotal</span>
|
<span class="text-gray-500">Subtotal (all items)</span>
|
||||||
<span class="font-semibold">Rp <span x-text="formatNum(subtotal)"></span></span>
|
<span class="font-semibold">Rp <span x-text="formatNum(subtotal)"></span></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between text-sm py-1">
|
<div class="flex justify-between text-sm py-1 text-amber-600">
|
||||||
<span class="text-gray-500">Tax (<span x-text="taxRate"></span>%)</span>
|
<span>Tax (<span x-text="taxRate"></span>% — paid by client)</span>
|
||||||
<span class="font-semibold">Rp <span x-text="formatNum(taxAmount)"></span></span>
|
<span class="font-semibold">Rp <span x-text="formatNum(taxAmount)"></span></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between text-base font-bold py-2 mt-1 border-t border-pink-200">
|
<div class="flex justify-between text-base font-bold py-2 mt-1 border-t border-pink-200">
|
||||||
<span class="text-gray-700">Total</span>
|
<span class="text-gray-700">Grand Total</span>
|
||||||
<span class="text-pink-600">Rp <span x-text="formatNum(total)"></span></span>
|
<span class="text-pink-600">Rp <span x-text="formatNum(total)"></span></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Bank Info --}}
|
{{-- Bank Info --}}
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3 mb-5">
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3 mb-5">
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Bank Name</label>
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Bank Name</label>
|
||||||
<input type="text" name="bank_name" value="{{ old('bank_name') }}"
|
<input type="text" name="bank_name"
|
||||||
|
value="{{ old('bank_name', $invoiceSettings->default_bank_name) }}"
|
||||||
class="input-soft text-sm" placeholder="BCA, Mandiri...">
|
class="input-soft text-sm" placeholder="BCA, Mandiri...">
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Branch Name</label>
|
||||||
|
<input type="text" name="branch_name"
|
||||||
|
value="{{ old('branch_name', $invoiceSettings->default_branch_name) }}"
|
||||||
|
class="input-soft text-sm" placeholder="e.g. KCP Sudirman">
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Account Number</label>
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Account Number</label>
|
||||||
<input type="text" name="bank_account" value="{{ old('bank_account') }}"
|
<input type="text" name="bank_account"
|
||||||
|
value="{{ old('bank_account', $invoiceSettings->default_bank_account) }}"
|
||||||
class="input-soft text-sm">
|
class="input-soft text-sm">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Account Holder</label>
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Account Holder</label>
|
||||||
<input type="text" name="bank_holder" value="{{ old('bank_holder') }}"
|
<input type="text" name="bank_holder"
|
||||||
|
value="{{ old('bank_holder', $invoiceSettings->default_bank_holder) }}"
|
||||||
class="input-soft text-sm">
|
class="input-soft text-sm">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -136,7 +157,7 @@
|
|||||||
<div class="mb-5">
|
<div class="mb-5">
|
||||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Notes</label>
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Notes</label>
|
||||||
<textarea name="notes" rows="2" class="input-soft resize-none"
|
<textarea name="notes" rows="2" class="input-soft resize-none"
|
||||||
placeholder="Payment terms, etc.">{{ old('notes') }}</textarea>
|
placeholder="Payment terms, etc.">{{ old('notes', $invoiceSettings->default_notes) }}</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col sm:flex-row gap-3">
|
<div class="flex flex-col sm:flex-row gap-3">
|
||||||
@@ -154,12 +175,19 @@
|
|||||||
<script>
|
<script>
|
||||||
function invoiceForm() {
|
function invoiceForm() {
|
||||||
return {
|
return {
|
||||||
items: [{ description: '', quantity: 1, unit_price: 0 }],
|
items: [{ description: @json($invoiceSettings->default_service_description ?? ''), quantity: 1, unit_price: 0, is_taxable: true }],
|
||||||
taxRate: 11,
|
taxRate: {{ $invoiceSettings->default_tax_rate ?? 11 }},
|
||||||
get subtotal() { return this.items.reduce((s, i) => s + (i.quantity * i.unit_price), 0); },
|
get subtotal() {
|
||||||
get taxAmount() { return Math.round(this.subtotal * this.taxRate / 100); },
|
return this.items.reduce((s, i) => s + (i.quantity * i.unit_price), 0);
|
||||||
get total() { return this.subtotal + this.taxAmount; },
|
},
|
||||||
addItem() { this.items.push({ description: '', quantity: 1, unit_price: 0 }); },
|
get taxAmount() {
|
||||||
|
const taxable = this.items
|
||||||
|
.filter(i => i.is_taxable)
|
||||||
|
.reduce((s, i) => s + (i.quantity * i.unit_price), 0);
|
||||||
|
return Math.round(taxable * this.taxRate / 100);
|
||||||
|
},
|
||||||
|
get total() { return this.subtotal; }, // grand total = pre-tax (tax borne by client)
|
||||||
|
addItem() { this.items.push({ description: '', quantity: 1, unit_price: 0, is_taxable: true }); },
|
||||||
removeItem(i) { if (this.items.length > 1) this.items.splice(i, 1); },
|
removeItem(i) { if (this.items.length > 1) this.items.splice(i, 1); },
|
||||||
recalc() {},
|
recalc() {},
|
||||||
formatNum(n) { return Number(n).toLocaleString('id-ID'); },
|
formatNum(n) { return Number(n).toLocaleString('id-ID'); },
|
||||||
|
|||||||
@@ -88,6 +88,18 @@
|
|||||||
<button type="button" @click="removeItem(index)"
|
<button type="button" @click="removeItem(index)"
|
||||||
class="text-red-400 hover:text-red-600 text-lg shrink-0 pt-4">✕</button>
|
class="text-red-400 hover:text-red-600 text-lg shrink-0 pt-4">✕</button>
|
||||||
</div>
|
</div>
|
||||||
|
{{-- Taxable checkbox --}}
|
||||||
|
<div class="mt-2 flex items-center gap-2">
|
||||||
|
<input type="hidden" :name="`items[${index}][is_taxable]`" value="0">
|
||||||
|
<input type="checkbox" :name="`items[${index}][is_taxable]`"
|
||||||
|
:id="`taxable_${index}`"
|
||||||
|
x-model="item.is_taxable" @change="recalc()"
|
||||||
|
value="1"
|
||||||
|
class="w-3.5 h-3.5 accent-pink-400">
|
||||||
|
<label :for="`taxable_${index}`" class="text-xs text-gray-500 cursor-pointer select-none">
|
||||||
|
Taxable
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@@ -96,26 +108,31 @@
|
|||||||
{{-- Totals --}}
|
{{-- Totals --}}
|
||||||
<div class="bg-pink-50 rounded-2xl p-4 mb-5">
|
<div class="bg-pink-50 rounded-2xl p-4 mb-5">
|
||||||
<div class="flex justify-between text-sm py-1">
|
<div class="flex justify-between text-sm py-1">
|
||||||
<span class="text-gray-500">Subtotal</span>
|
<span class="text-gray-500">Subtotal (all items)</span>
|
||||||
<span class="font-semibold">Rp <span x-text="formatNum(subtotal)"></span></span>
|
<span class="font-semibold">Rp <span x-text="formatNum(subtotal)"></span></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between text-sm py-1">
|
<div class="flex justify-between text-sm py-1 text-amber-600">
|
||||||
<span class="text-gray-500">Tax (<span x-text="taxRate"></span>%)</span>
|
<span>Tax (<span x-text="taxRate"></span>% — paid by client)</span>
|
||||||
<span class="font-semibold">Rp <span x-text="formatNum(taxAmount)"></span></span>
|
<span class="font-semibold">Rp <span x-text="formatNum(taxAmount)"></span></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between text-base font-bold py-2 mt-1 border-t border-pink-200">
|
<div class="flex justify-between text-base font-bold py-2 mt-1 border-t border-pink-200">
|
||||||
<span class="text-gray-700">Total</span>
|
<span class="text-gray-700">Grand Total</span>
|
||||||
<span class="text-pink-600">Rp <span x-text="formatNum(total)"></span></span>
|
<span class="text-pink-600">Rp <span x-text="formatNum(total)"></span></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Bank Info --}}
|
{{-- Bank Info --}}
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3 mb-5">
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3 mb-5">
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Bank Name</label>
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Bank Name</label>
|
||||||
<input type="text" name="bank_name" value="{{ old('bank_name', $invoice->bank_name) }}"
|
<input type="text" name="bank_name" value="{{ old('bank_name', $invoice->bank_name) }}"
|
||||||
class="input-soft text-sm">
|
class="input-soft text-sm">
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Branch Name</label>
|
||||||
|
<input type="text" name="branch_name" value="{{ old('branch_name', $invoice->branch_name) }}"
|
||||||
|
class="input-soft text-sm" placeholder="e.g. KCP Sudirman">
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Account Number</label>
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Account Number</label>
|
||||||
<input type="text" name="bank_account" value="{{ old('bank_account', $invoice->bank_account) }}"
|
<input type="text" name="bank_account" value="{{ old('bank_account', $invoice->bank_account) }}"
|
||||||
@@ -147,13 +164,25 @@
|
|||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script>
|
<script>
|
||||||
function invoiceEditForm() {
|
function invoiceEditForm() {
|
||||||
|
@php
|
||||||
|
$itemsJson = $invoice->items->map(function($i) {
|
||||||
|
return ['description' => $i->description, 'quantity' => $i->quantity, 'unit_price' => (float)$i->unit_price, 'is_taxable' => (bool)$i->is_taxable];
|
||||||
|
});
|
||||||
|
@endphp
|
||||||
return {
|
return {
|
||||||
items: @json($invoice->items->map(fn($i) => ['description' => $i->description, 'quantity' => $i->quantity, 'unit_price' => (float)$i->unit_price])),
|
items: @json($itemsJson),
|
||||||
taxRate: {{ $invoice->tax_rate }},
|
taxRate: {{ $invoice->tax_rate }},
|
||||||
get subtotal() { return this.items.reduce((s, i) => s + (i.quantity * i.unit_price), 0); },
|
get subtotal() {
|
||||||
get taxAmount() { return Math.round(this.subtotal * this.taxRate / 100); },
|
return this.items.reduce((s, i) => s + (i.quantity * i.unit_price), 0);
|
||||||
get total() { return this.subtotal + this.taxAmount; },
|
},
|
||||||
addItem() { this.items.push({ description: '', quantity: 1, unit_price: 0 }); },
|
get taxAmount() {
|
||||||
|
const taxable = this.items
|
||||||
|
.filter(i => i.is_taxable)
|
||||||
|
.reduce((s, i) => s + (i.quantity * i.unit_price), 0);
|
||||||
|
return Math.round(taxable * this.taxRate / 100);
|
||||||
|
},
|
||||||
|
get total() { return this.subtotal; },
|
||||||
|
addItem() { this.items.push({ description: '', quantity: 1, unit_price: 0, is_taxable: true }); },
|
||||||
removeItem(i) { if (this.items.length > 1) this.items.splice(i, 1); },
|
removeItem(i) { if (this.items.length > 1) this.items.splice(i, 1); },
|
||||||
recalc() {},
|
recalc() {},
|
||||||
formatNum(n) { return Number(n).toLocaleString('id-ID'); },
|
formatNum(n) { return Number(n).toLocaleString('id-ID'); },
|
||||||
|
|||||||
@@ -6,19 +6,14 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-5">
|
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-5">
|
||||||
<div class="flex gap-2 flex-wrap">
|
|
||||||
@foreach(['all','draft','sent','paid','overdue'] as $s)
|
<div class="flex gap-2 shrink-0">
|
||||||
<a href="{{ request()->fullUrlWithQuery(['status' => $s]) }}"
|
<a href="{{ route('invoice-settings.edit') }}"
|
||||||
class="px-3 py-1.5 rounded-full text-xs font-semibold transition-colors
|
class="text-xs px-3 py-2 rounded-full border border-gray-200 text-gray-500 hover:bg-gray-50 flex items-center gap-1">
|
||||||
{{ request('status', 'all') === $s
|
⚙️ Settings
|
||||||
? 'text-white'
|
|
||||||
: 'bg-white text-gray-500 hover:bg-pink-50 border border-pink-100' }}"
|
|
||||||
style="{{ request('status', 'all') === $s ? 'background:#FFB7C5' : '' }}">
|
|
||||||
{{ ucfirst($s) }}
|
|
||||||
</a>
|
</a>
|
||||||
@endforeach
|
<a href="{{ route('invoices.create') }}" class="btn-sakura text-sm">+ New Invoice</a>
|
||||||
</div>
|
</div>
|
||||||
<a href="{{ route('invoices.create') }}" class="btn-sakura text-sm shrink-0">+ New Invoice</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Mobile card list --}}
|
{{-- Mobile card list --}}
|
||||||
@@ -41,6 +36,7 @@
|
|||||||
<a href="{{ route('invoices.show', $invoice) }}" class="flex-1 text-center text-xs py-1.5 px-3 rounded-full border border-pink-200 text-pink-600 hover:bg-pink-50">View</a>
|
<a href="{{ route('invoices.show', $invoice) }}" class="flex-1 text-center text-xs py-1.5 px-3 rounded-full border border-pink-200 text-pink-600 hover:bg-pink-50">View</a>
|
||||||
<a href="{{ route('invoices.pdf', $invoice) }}" target="_blank" class="flex-1 text-center text-xs py-1.5 px-3 rounded-full border border-pink-200 text-pink-600 hover:bg-pink-50">PDF</a>
|
<a href="{{ route('invoices.pdf', $invoice) }}" target="_blank" class="flex-1 text-center text-xs py-1.5 px-3 rounded-full border border-pink-200 text-pink-600 hover:bg-pink-50">PDF</a>
|
||||||
<a href="{{ route('invoices.edit', $invoice) }}" class="flex-1 text-center text-xs py-1.5 px-3 rounded-full border border-pink-200 text-gray-600 hover:bg-pink-50">Edit</a>
|
<a href="{{ route('invoices.edit', $invoice) }}" class="flex-1 text-center text-xs py-1.5 px-3 rounded-full border border-pink-200 text-gray-600 hover:bg-pink-50">Edit</a>
|
||||||
|
{{-- Share button disabled --}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@empty
|
@empty
|
||||||
@@ -85,6 +81,7 @@
|
|||||||
<a href="{{ route('invoices.show', $invoice) }}" class="text-xs text-pink-500 hover:underline">View</a>
|
<a href="{{ route('invoices.show', $invoice) }}" class="text-xs text-pink-500 hover:underline">View</a>
|
||||||
<a href="{{ route('invoices.pdf', $invoice) }}" class="text-xs text-pink-500 hover:underline" target="_blank">PDF</a>
|
<a href="{{ route('invoices.pdf', $invoice) }}" class="text-xs text-pink-500 hover:underline" target="_blank">PDF</a>
|
||||||
<a href="{{ route('invoices.edit', $invoice) }}" class="text-xs text-gray-500 hover:underline">Edit</a>
|
<a href="{{ route('invoices.edit', $invoice) }}" class="text-xs text-gray-500 hover:underline">Edit</a>
|
||||||
|
{{-- Share button disabled --}}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -100,4 +97,5 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-4">{{ $invoices->links() }}</div>
|
<div class="mt-4">{{ $invoices->links() }}</div>
|
||||||
|
{{-- Share scripts disabled --}}
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -2,54 +2,107 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
@php
|
||||||
|
$accent = $invoiceSettings->accent_color ?? '#FFB7C5';
|
||||||
|
$hex = ltrim($accent, '#');
|
||||||
|
$r = hexdec(substr($hex, 0, 2));
|
||||||
|
$g = hexdec(substr($hex, 2, 2));
|
||||||
|
$b = hexdec(substr($hex, 4, 2));
|
||||||
|
// 92% white + 8% accent → very light tint
|
||||||
|
$tint = sprintf('#%02X%02X%02X',
|
||||||
|
(int)(255 * 0.92 + $r * 0.08),
|
||||||
|
(int)(255 * 0.92 + $g * 0.08),
|
||||||
|
(int)(255 * 0.92 + $b * 0.08)
|
||||||
|
);
|
||||||
|
// 80% white + 20% accent → medium-light tint (for borders)
|
||||||
|
$tintMid = sprintf('#%02X%02X%02X',
|
||||||
|
(int)(255 * 0.80 + $r * 0.20),
|
||||||
|
(int)(255 * 0.80 + $g * 0.20),
|
||||||
|
(int)(255 * 0.80 + $b * 0.20)
|
||||||
|
);
|
||||||
|
@endphp
|
||||||
<style>
|
<style>
|
||||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||||
body { font-family: 'Helvetica', Arial, sans-serif; color: #374151; font-size: 13px; padding: 40px; }
|
body { font-family: 'Helvetica', Arial, sans-serif; color: #374151; font-size: 13px; padding: 40px; }
|
||||||
.header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 40px; }
|
|
||||||
.logo { font-size: 22px; font-weight: 900; color: #FFB7C5; }
|
/* ── Header ───────────────────────────────── */
|
||||||
.logo-sub { font-size: 11px; color: #9CA3AF; margin-top: 2px; }
|
.header-table { width: 100%; margin-bottom: 36px; }
|
||||||
.inv-number { font-size: 22px; font-weight: 700; color: #1F2937; text-align: right; }
|
.logo-name { font-size: 22px; font-weight: 900; color: {{ $accent }}; }
|
||||||
.badge { display: inline-block; padding: 3px 12px; border-radius: 20px; font-size: 11px; font-weight: 700; background: #FDE68A; color: #92400E; }
|
.logo-sub { font-size: 11px; color: #9CA3AF; margin-top: 3px; }
|
||||||
.section-title { font-size: 10px; font-weight: 700; color: #9CA3AF; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
|
.inv-number { font-size: 22px; font-weight: 700; color: #1F2937; }
|
||||||
.billing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-bottom: 32px; }
|
|
||||||
|
|
||||||
|
/* ── Billing grid ─────────────────────────── */
|
||||||
|
.billing-table { width: 100%; margin-bottom: 28px; }
|
||||||
|
.section-title { font-size: 10px; font-weight: 700; color: #9CA3AF;
|
||||||
|
text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
|
||||||
.billing-name { font-weight: 700; font-size: 15px; color: #111827; }
|
.billing-name { font-weight: 700; font-size: 15px; color: #111827; }
|
||||||
.billing-detail { font-size: 12px; color: #6B7280; margin-top: 2px; }
|
.billing-detail{ font-size: 12px; color: #6B7280; margin-top: 2px; }
|
||||||
.detail-table { width: 100%; font-size: 12px; }
|
.detail-table { font-size: 12px; width: auto; float: right; }
|
||||||
.detail-table td { padding: 3px 0; }
|
.detail-table td { padding: 3px 0; }
|
||||||
.detail-table td:first-child { color: #9CA3AF; }
|
.detail-table .lbl { color: #9CA3AF; padding-right: 16px; white-space: nowrap; }
|
||||||
.detail-table td:last-child { font-weight: 600; text-align: right; }
|
.detail-table .val { font-weight: 600; text-align: right; white-space: nowrap; }
|
||||||
table.items { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
|
|
||||||
table.items thead { background: #FFF0F5; }
|
/* ── Line items ───────────────────────────── */
|
||||||
table.items th { padding: 10px 12px; text-align: left; font-size: 10px; font-weight: 700; color: #9CA3AF; text-transform: uppercase; }
|
table.items { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
|
||||||
table.items th:last-child, table.items td:last-child { text-align: right; }
|
table.items thead td { background: {{ $tint }}; padding: 10px 12px;
|
||||||
table.items th:nth-child(2), table.items td:nth-child(2) { text-align: center; }
|
font-size: 10px; font-weight: 700; color: #9CA3AF; text-transform: uppercase; }
|
||||||
table.items td { padding: 10px 12px; border-bottom: 1px solid #FDE8F0; font-size: 12px; }
|
table.items tbody td { padding: 10px 12px; border-bottom: 1px solid {{ $tintMid }}; font-size: 12px; }
|
||||||
.totals { display: flex; justify-content: flex-end; margin-bottom: 24px; }
|
.td-right { text-align: right; }
|
||||||
.totals-box { width: 260px; }
|
.td-center { text-align: center; }
|
||||||
.totals-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 12px; }
|
|
||||||
.totals-row.total { border-top: 2px solid #FFB7C5; margin-top: 6px; padding-top: 8px; font-size: 15px; font-weight: 800; color: #FFB7C5; }
|
/* ── Totals ───────────────────────────────── */
|
||||||
.bank-box { background: #FFF5F7; border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; }
|
.totals-wrap { width: 100%; margin-bottom: 24px; }
|
||||||
|
.totals-inner { width: 260px; float: right; }
|
||||||
|
.totals-inner table { width: 100%; font-size: 12px; border-collapse: collapse; }
|
||||||
|
.totals-inner table td { padding: 4px 0; }
|
||||||
|
.totals-inner table td.amount { text-align: right; font-weight: 600; }
|
||||||
|
.totals-total td { border-top: 2px solid {{ $accent }};
|
||||||
|
padding-top: 8px !important; margin-top: 6px;
|
||||||
|
font-size: 15px; font-weight: 800; color: {{ $accent }}; }
|
||||||
|
.clearfix::after { content: ""; display: table; clear: both; }
|
||||||
|
|
||||||
|
/* ── Payment info ─────────────────────────── */
|
||||||
|
.bank-box { background: {{ $tint }}; border-radius: 10px;
|
||||||
|
padding: 14px 16px; margin-bottom: 16px; }
|
||||||
.bank-title { font-weight: 700; font-size: 12px; color: #374151; margin-bottom: 4px; }
|
.bank-title { font-weight: 700; font-size: 12px; color: #374151; margin-bottom: 4px; }
|
||||||
.bank-detail { font-size: 12px; color: #6B7280; }
|
.bank-detail { font-size: 12px; color: #6B7280; }
|
||||||
|
|
||||||
.notes { font-size: 11px; color: #9CA3AF; font-style: italic; }
|
.notes { font-size: 11px; color: #9CA3AF; font-style: italic; }
|
||||||
.footer { margin-top: 40px; text-align: center; font-size: 11px; color: #D1D5DB; }
|
.footer { margin-top: 40px; text-align: center; font-size: 11px; color: #D1D5DB; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="header">
|
{{-- ── Header ─────────────────────────────────────────────────── --}}
|
||||||
<div>
|
<table class="header-table" cellpadding="0" cellspacing="0">
|
||||||
<div class="logo">🐱 KOL Manager</div>
|
<tr>
|
||||||
<div class="logo-sub">Personal Talent Assistant</div>
|
<td style="vertical-align:middle;">
|
||||||
</div>
|
<table cellpadding="0" cellspacing="0">
|
||||||
<div style="text-align:right">
|
<tr>
|
||||||
|
@if($invoiceSettings->header_logo && file_exists(storage_path('app/public/' . $invoiceSettings->header_logo)))
|
||||||
|
<td style="vertical-align:middle; padding-right:12px; width:64px;">
|
||||||
|
<img src="{{ storage_path('app/public/' . $invoiceSettings->header_logo) }}"
|
||||||
|
style="width:52px; height:52px; object-fit:cover; border-radius:12px; display:block;" alt="Logo">
|
||||||
|
</td>
|
||||||
|
@endif
|
||||||
|
<td style="vertical-align:middle;">
|
||||||
|
<div class="logo-name">{{ $invoiceSettings->header_name ?: 'KOL Manager' }}</div>
|
||||||
|
<div class="logo-sub">{{ $invoiceSettings->header_title ?: 'Personal Talent Assistant' }}</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
<td style="text-align:right; vertical-align:top;">
|
||||||
<div class="inv-number">{{ $invoice->invoice_number }}</div>
|
<div class="inv-number">{{ $invoice->invoice_number }}</div>
|
||||||
<div style="margin-top:4px"><span class="badge">{{ $invoice->status->label() }}</span></div>
|
</td>
|
||||||
</div>
|
</tr>
|
||||||
</div>
|
</table>
|
||||||
|
|
||||||
<div class="billing-grid">
|
{{-- ── Billing Info ─────────────────────────────────────────────── --}}
|
||||||
<div>
|
<table class="billing-table" cellpadding="0" cellspacing="0">
|
||||||
|
<tr>
|
||||||
|
<td style="width:50%; vertical-align:top; padding-right:24px;">
|
||||||
<div class="section-title">Bill To</div>
|
<div class="section-title">Bill To</div>
|
||||||
@if($invoice->client)
|
@if($invoice->client)
|
||||||
<div class="billing-name">{{ $invoice->client->name }}</div>
|
<div class="billing-name">{{ $invoice->client->name }}</div>
|
||||||
@@ -59,53 +112,78 @@
|
|||||||
@else
|
@else
|
||||||
<div class="billing-detail">—</div>
|
<div class="billing-detail">—</div>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</td>
|
||||||
<div style="text-align:right">
|
<td style="width:50%; vertical-align:top; text-align:right;">
|
||||||
<div class="section-title">Invoice Details</div>
|
<div class="section-title">Invoice Details</div>
|
||||||
<table class="detail-table">
|
<table class="detail-table" cellpadding="0" cellspacing="0">
|
||||||
<tr><td>Issue Date</td><td>{{ $invoice->issue_date->format('d M Y') }}</td></tr>
|
<tr><td class="lbl">Issue Date</td><td class="val">{{ $invoice->issue_date->format('d M Y') }}</td></tr>
|
||||||
<tr><td>Due Date</td><td>{{ $invoice->due_date->format('d M Y') }}</td></tr>
|
<tr><td class="lbl">Due Date</td><td class="val">{{ $invoice->due_date->format('d M Y') }}</td></tr>
|
||||||
@if($invoice->paid_date)
|
@if($invoice->paid_date)
|
||||||
<tr><td>Paid Date</td><td>{{ $invoice->paid_date->format('d M Y') }}</td></tr>
|
<tr><td class="lbl">Paid Date</td><td class="val">{{ $invoice->paid_date->format('d M Y') }}</td></tr>
|
||||||
@endif
|
@endif
|
||||||
<tr><td>Currency</td><td>{{ $invoice->currency }}</td></tr>
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</td>
|
||||||
</div>
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
<table class="items">
|
{{-- ── Line Items ───────────────────────────────────────────────── --}}
|
||||||
|
<table class="items" cellpadding="0" cellspacing="0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Description</th>
|
<td style="width:50%;">Description</td>
|
||||||
<th>Qty</th>
|
<td class="td-center" style="width:10%;">Qty</td>
|
||||||
<th style="text-align:right">Unit Price</th>
|
<td class="td-right" style="width:20%;">Unit Price</td>
|
||||||
<th>Total</th>
|
<td class="td-right" style="width:20%;">Total</td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach($invoice->items as $item)
|
@foreach($invoice->items as $item)
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $item->description }}</td>
|
<td>
|
||||||
<td style="text-align:center">{{ $item->quantity }}</td>
|
{{ $item->description }}
|
||||||
<td style="text-align:right">Rp {{ number_format($item->unit_price, 0, ',', '.') }}</td>
|
@if(!$item->is_taxable)
|
||||||
<td style="text-align:right; font-weight:600">Rp {{ number_format($item->total, 0, ',', '.') }}</td>
|
<span style="margin-left:6px; font-size:10px; background:#F3F4F6; color:#6B7280; padding:2px 8px; border-radius:10px; font-weight:600;">Non-Taxable</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td class="td-center">{{ $item->quantity }}</td>
|
||||||
|
<td class="td-right">Rp {{ number_format($item->unit_price, 0, ',', '.') }}</td>
|
||||||
|
<td class="td-right" style="font-weight:600;">Rp {{ number_format($item->total, 0, ',', '.') }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="totals">
|
{{-- ── Totals ───────────────────────────────────────────────────── --}}
|
||||||
<div class="totals-box">
|
<div class="totals-wrap clearfix">
|
||||||
<div class="totals-row"><span>Subtotal</span><span>Rp {{ number_format($invoice->subtotal, 0, ',', '.') }}</span></div>
|
<div class="totals-inner">
|
||||||
<div class="totals-row"><span>Tax ({{ $invoice->tax_rate }}%)</span><span>Rp {{ number_format($invoice->tax_amount, 0, ',', '.') }}</span></div>
|
<table cellpadding="0" cellspacing="0">
|
||||||
<div class="totals-row total"><span>Total</span><span>{{ $invoice->formatted_total }}</span></div>
|
<tr>
|
||||||
|
<td style="color:#6B7280;">Subtotal</td>
|
||||||
|
<td class="amount">Rp {{ number_format($invoice->subtotal, 0, ',', '.') }}</td>
|
||||||
|
</tr>
|
||||||
|
@if($invoice->tax_rate > 0)
|
||||||
|
<tr>
|
||||||
|
<td style="color:#D97706;">Tax ({{ $invoice->tax_rate }}% — paid by client)</td>
|
||||||
|
<td class="amount" style="color:#D97706;">Rp {{ number_format($invoice->tax_amount, 0, ',', '.') }}</td>
|
||||||
|
</tr>
|
||||||
|
@endif
|
||||||
|
<tr class="totals-total">
|
||||||
|
<td>Grand Total</td>
|
||||||
|
<td class="amount">{{ $invoice->formatted_total }}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- ── Payment Info ──────────────────────────────────────────────── --}}
|
||||||
@if($invoice->bank_name)
|
@if($invoice->bank_name)
|
||||||
<div class="bank-box">
|
<div class="bank-box">
|
||||||
<div class="bank-title">💳 Payment Information</div>
|
<div class="bank-title">Payment Information</div>
|
||||||
<div class="bank-detail">{{ $invoice->bank_name }} · {{ $invoice->bank_account }} · a/n {{ $invoice->bank_holder }}</div>
|
<div class="bank-detail">
|
||||||
|
{{ $invoice->bank_name }}
|
||||||
|
@if($invoice->branch_name) · {{ $invoice->branch_name }} @endif
|
||||||
|
· {{ $invoice->bank_account }} · a/n {{ $invoice->bank_holder }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@@ -113,7 +191,7 @@
|
|||||||
<div class="notes">{{ $invoice->notes }}</div>
|
<div class="notes">{{ $invoice->notes }}</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<div class="footer">Generated by KOL Manager · Thank you for the collaboration! 🐱</div>
|
<div class="footer">Generated by KOL Manager · Thank you for the collaboration!</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
233
resources/views/invoices/settings.blade.php
Normal file
233
resources/views/invoices/settings.blade.php
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'Invoice Settings')
|
||||||
|
@section('page-title', 'Invoice Settings 🧾')
|
||||||
|
@section('page-subtitle', 'Customize number format, header, and invoice defaults')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="max-w-2xl mx-auto">
|
||||||
|
<div class="flex items-center gap-3 mb-5">
|
||||||
|
<a href="{{ route('invoices.index') }}"
|
||||||
|
class="text-xs px-3 py-2 rounded-full border border-pink-200 text-gray-500 hover:bg-pink-50">
|
||||||
|
← Back to Invoices
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if(session('success'))
|
||||||
|
<div x-data="{ show: true }" x-show="show" x-init="setTimeout(() => show = false, 4000)"
|
||||||
|
class="flex items-center justify-between gap-3 bg-green-50 border border-green-200 rounded-2xl px-4 py-3 text-sm text-green-700 mb-4">
|
||||||
|
<span>{{ session('success') }}</span>
|
||||||
|
<button @click="show = false" class="text-green-500 hover:text-green-700 text-lg leading-none">✕</button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<form action="{{ route('invoice-settings.update') }}" method="POST" enctype="multipart/form-data"
|
||||||
|
class="space-y-5">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
{{-- Number Format --}}
|
||||||
|
<div class="cat-card p-5">
|
||||||
|
<h2 class="text-sm font-bold text-gray-700 mb-4 flex items-center gap-2">🔢 Invoice Number Format</h2>
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">
|
||||||
|
Prefix <span class="text-pink-400">*</span>
|
||||||
|
</label>
|
||||||
|
<input type="text" name="invoice_prefix"
|
||||||
|
value="{{ old('invoice_prefix', $settings->invoice_prefix) }}"
|
||||||
|
class="input-soft text-sm" placeholder="INV-EA" required
|
||||||
|
id="prefix-input" oninput="updatePreview()">
|
||||||
|
<p class="text-xs text-gray-400 mt-1">e.g. <code>INV-EA</code> → <strong>INV-EA-001</strong></p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">
|
||||||
|
Next Number <span class="text-pink-400">*</span>
|
||||||
|
</label>
|
||||||
|
<input type="number" name="invoice_next_number"
|
||||||
|
value="{{ old('invoice_next_number', $settings->invoice_next_number) }}"
|
||||||
|
class="input-soft text-sm" min="1" required
|
||||||
|
id="number-input" oninput="updatePreview()">
|
||||||
|
<p class="text-xs text-gray-400 mt-1">Used for the next new invoice</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mt-3 bg-pink-50 rounded-xl px-4 py-2.5 text-sm text-gray-600">
|
||||||
|
Preview: <strong class="text-pink-600" id="number-preview">
|
||||||
|
{{ rtrim(old('invoice_prefix', $settings->invoice_prefix), '-') }}-{{ str_pad((string) (old('invoice_next_number', $settings->invoice_next_number) ?? 1), 3, '0', STR_PAD_LEFT) }}
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Header / Branding --}}
|
||||||
|
<div class="cat-card p-5">
|
||||||
|
<h2 class="text-sm font-bold text-gray-700 mb-4 flex items-center gap-2">🎨 Invoice Header</h2>
|
||||||
|
|
||||||
|
{{-- Logo auto-upload (independent of main Save form) --}}
|
||||||
|
<div class="mb-4"
|
||||||
|
x-data="{
|
||||||
|
uploading: false,
|
||||||
|
errorMsg: '',
|
||||||
|
logoUrl: '{{ $settings->header_logo ? asset('storage/' . $settings->header_logo) : '' }}',
|
||||||
|
|
||||||
|
async pickFile(input) {
|
||||||
|
if (!input.files.length) return;
|
||||||
|
this.uploading = true;
|
||||||
|
this.errorMsg = '';
|
||||||
|
const fd = new FormData();
|
||||||
|
fd.append('header_logo', input.files[0]);
|
||||||
|
fd.append('_token', document.querySelector('meta[name=csrf-token]').content);
|
||||||
|
try {
|
||||||
|
const res = await fetch('{{ route('invoice-settings.upload-logo') }}', { method: 'POST', body: fd });
|
||||||
|
const data = await res.json();
|
||||||
|
if (res.ok) {
|
||||||
|
this.logoUrl = data.url + '?t=' + Date.now();
|
||||||
|
} else {
|
||||||
|
this.errorMsg = data.message ?? 'Upload failed.';
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
this.errorMsg = 'Network error. Please try again.';
|
||||||
|
}
|
||||||
|
this.uploading = false;
|
||||||
|
input.value = '';
|
||||||
|
},
|
||||||
|
|
||||||
|
async removeLogo() {
|
||||||
|
if (!confirm('Remove this logo?')) return;
|
||||||
|
const fd = new FormData();
|
||||||
|
fd.append('_token', document.querySelector('meta[name=csrf-token]').content);
|
||||||
|
fd.append('_method', 'DELETE');
|
||||||
|
await fetch('{{ route('invoice-settings.delete-logo') }}', { method: 'POST', body: fd });
|
||||||
|
this.logoUrl = '';
|
||||||
|
}
|
||||||
|
}">
|
||||||
|
|
||||||
|
{{-- Current logo preview --}}
|
||||||
|
<template x-if="logoUrl">
|
||||||
|
<div class="flex items-center gap-3 mb-3">
|
||||||
|
<img :src="logoUrl" alt="Logo"
|
||||||
|
class="h-16 w-16 object-cover rounded-2xl border border-pink-100 shrink-0">
|
||||||
|
<div class="flex-1 min-w-0">
|
||||||
|
<p class="text-xs font-semibold text-gray-600">Current Logo</p>
|
||||||
|
<p class="text-xs text-gray-400 mt-0.5">Choose a new file to replace it</p>
|
||||||
|
</div>
|
||||||
|
<button type="button" @click="removeLogo()"
|
||||||
|
class="text-xs px-3 py-1.5 rounded-full border border-red-200 text-red-400 hover:bg-red-50 shrink-0">
|
||||||
|
🗑️ Remove
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Logo / Profile Picture</label>
|
||||||
|
<div class="relative">
|
||||||
|
<input type="file" accept="image/*"
|
||||||
|
@change="pickFile($event.target)"
|
||||||
|
class="w-full text-sm text-gray-600
|
||||||
|
file:mr-3 file:py-1.5 file:px-4
|
||||||
|
file:rounded-full file:border-0
|
||||||
|
file:text-xs file:font-semibold
|
||||||
|
file:bg-pink-50 file:text-pink-600
|
||||||
|
hover:file:bg-pink-100 cursor-pointer"
|
||||||
|
:disabled="uploading">
|
||||||
|
<span x-show="uploading" class="text-xs text-pink-500 mt-1 block">Uploading…</span>
|
||||||
|
<span x-show="errorMsg" x-text="errorMsg" class="text-xs text-red-500 mt-1 block"></span>
|
||||||
|
</div>
|
||||||
|
<p class="text-xs text-gray-400 mt-1">Max 2 MB. Uploads immediately on file selection.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Talent / Business Name</label>
|
||||||
|
<input type="text" name="header_name"
|
||||||
|
value="{{ old('header_name', $settings->header_name) }}"
|
||||||
|
class="input-soft text-sm" placeholder="Your name or brand">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Title / Tagline</label>
|
||||||
|
<input type="text" name="header_title"
|
||||||
|
value="{{ old('header_title', $settings->header_title) }}"
|
||||||
|
class="input-soft text-sm" placeholder="Content Creator · KOL">
|
||||||
|
</div>
|
||||||
|
<div x-data="{ color: '{{ old('accent_color', $settings->accent_color ?? '#FFB7C5') }}' }">
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Accent Color</label>
|
||||||
|
<div class="flex items-center gap-3 mt-1">
|
||||||
|
<input type="color" name="accent_color" x-model="color"
|
||||||
|
class="w-10 h-10 rounded-xl cursor-pointer border-2 border-pink-100 p-0.5">
|
||||||
|
</div>
|
||||||
|
<p class="text-xs text-gray-400 mt-1.5">Applied to your invoice header name and totals.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Invoice Defaults --}}
|
||||||
|
<div class="cat-card p-5">
|
||||||
|
<h2 class="text-sm font-bold text-gray-700 mb-4 flex items-center gap-2">📋 Invoice Defaults</h2>
|
||||||
|
<p class="text-xs text-gray-400 mb-4">These values will pre-fill every new invoice you create.</p>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Tax Rate (%)</label>
|
||||||
|
<input type="number" name="default_tax_rate" step="0.01" min="0" max="100"
|
||||||
|
value="{{ old('default_tax_rate', $settings->default_tax_rate ?? 11) }}"
|
||||||
|
class="input-soft text-sm" placeholder="11">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Currency</label>
|
||||||
|
<select name="default_currency" class="input-soft text-sm">
|
||||||
|
@foreach(['IDR' => 'IDR (Rupiah)', 'USD' => 'USD (Dollar)', 'SGD' => 'SGD', 'MYR' => 'MYR (Ringgit)'] as $code => $label)
|
||||||
|
<option value="{{ $code }}" {{ old('default_currency', $settings->default_currency ?? 'IDR') === $code ? 'selected' : '' }}>
|
||||||
|
{{ $label }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Service Description</label>
|
||||||
|
<input type="text" name="default_service_description"
|
||||||
|
value="{{ old('default_service_description', $settings->default_service_description) }}"
|
||||||
|
class="input-soft text-sm" placeholder="e.g. Instagram Feed Post — 1 carousel">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Bank Name</label>
|
||||||
|
<input type="text" name="default_bank_name"
|
||||||
|
value="{{ old('default_bank_name', $settings->default_bank_name) }}"
|
||||||
|
class="input-soft text-sm" placeholder="BCA, Mandiri…">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Branch Name</label>
|
||||||
|
<input type="text" name="default_branch_name"
|
||||||
|
value="{{ old('default_branch_name', $settings->default_branch_name) }}"
|
||||||
|
class="input-soft text-sm" placeholder="KCP Sudirman">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Account Number</label>
|
||||||
|
<input type="text" name="default_bank_account"
|
||||||
|
value="{{ old('default_bank_account', $settings->default_bank_account) }}"
|
||||||
|
class="input-soft text-sm" placeholder="1234567890">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Account Holder</label>
|
||||||
|
<input type="text" name="default_bank_holder"
|
||||||
|
value="{{ old('default_bank_holder', $settings->default_bank_holder) }}"
|
||||||
|
class="input-soft text-sm" placeholder="Your full name">
|
||||||
|
</div>
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Notes / Payment Terms</label>
|
||||||
|
<textarea name="default_notes" rows="2" class="input-soft text-sm resize-none"
|
||||||
|
placeholder="e.g. Payment due within 14 days from invoice date.">{{ old('default_notes', $settings->default_notes) }}</textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn-sakura w-full py-3">💾 Save Settings</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script>
|
||||||
|
function updatePreview() {
|
||||||
|
const prefix = document.getElementById('prefix-input').value.replace(/-+$/, '') || 'INV';
|
||||||
|
const num = parseInt(document.getElementById('number-input').value) || 1;
|
||||||
|
document.getElementById('number-preview').textContent = prefix + '-' + String(num).padStart(3, '0');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
@endsection
|
||||||
@@ -18,9 +18,20 @@
|
|||||||
<div class="cat-card p-8">
|
<div class="cat-card p-8">
|
||||||
{{-- Invoice Header --}}
|
{{-- Invoice Header --}}
|
||||||
<div class="flex justify-between items-start mb-8">
|
<div class="flex justify-between items-start mb-8">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
@if($invoiceSettings->header_logo)
|
||||||
|
<img src="{{ asset('storage/' . $invoiceSettings->header_logo) }}"
|
||||||
|
alt="Logo" class="h-14 w-14 object-cover rounded-2xl border border-pink-100 shrink-0">
|
||||||
|
@endif
|
||||||
<div>
|
<div>
|
||||||
<div class="text-2xl font-extrabold text-pink-500 flex items-center gap-2">🐱 KOL Manager</div>
|
<div class="text-xl font-extrabold"
|
||||||
<div class="text-sm text-gray-400 mt-1">Personal Talent Assistant</div>
|
style="color:{{ $invoiceSettings->accent_color ?? '#FFB7C5' }}">
|
||||||
|
{{ $invoiceSettings->header_name ?: '🐱 KOL Manager' }}
|
||||||
|
</div>
|
||||||
|
<div class="text-sm text-gray-400 mt-0.5">
|
||||||
|
{{ $invoiceSettings->header_title ?: 'Personal Talent Assistant' }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<div class="text-2xl font-bold text-gray-800">{{ $invoice->invoice_number }}</div>
|
<div class="text-2xl font-bold text-gray-800">{{ $invoice->invoice_number }}</div>
|
||||||
@@ -52,9 +63,21 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Line Items --}}
|
{{-- Line Items --}}
|
||||||
|
@php
|
||||||
|
$accent = $invoiceSettings->accent_color ?? '#FFB7C5';
|
||||||
|
$hex = ltrim($accent, '#');
|
||||||
|
$r = hexdec(substr($hex, 0, 2));
|
||||||
|
$g = hexdec(substr($hex, 2, 2));
|
||||||
|
$b = hexdec(substr($hex, 4, 2));
|
||||||
|
$tint = sprintf('#%02X%02X%02X',
|
||||||
|
(int)(255 * 0.92 + $r * 0.08),
|
||||||
|
(int)(255 * 0.92 + $g * 0.08),
|
||||||
|
(int)(255 * 0.92 + $b * 0.08)
|
||||||
|
);
|
||||||
|
@endphp
|
||||||
<table class="w-full mb-6">
|
<table class="w-full mb-6">
|
||||||
<thead class="bg-pink-50">
|
<thead>
|
||||||
<tr class="text-xs text-gray-500 uppercase">
|
<tr class="text-xs text-gray-500 uppercase" style="background:{{ $tint }}">
|
||||||
<th class="text-left py-3 px-4 rounded-l-2xl">Description</th>
|
<th class="text-left py-3 px-4 rounded-l-2xl">Description</th>
|
||||||
<th class="text-center py-3 px-4">Qty</th>
|
<th class="text-center py-3 px-4">Qty</th>
|
||||||
<th class="text-right py-3 px-4">Unit Price</th>
|
<th class="text-right py-3 px-4">Unit Price</th>
|
||||||
@@ -64,7 +87,12 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach($invoice->items as $item)
|
@foreach($invoice->items as $item)
|
||||||
<tr class="border-b border-pink-50">
|
<tr class="border-b border-pink-50">
|
||||||
<td class="py-3 px-4 text-sm text-gray-700">{{ $item->description }}</td>
|
<td class="py-3 px-4 text-sm text-gray-700">
|
||||||
|
{{ $item->description }}
|
||||||
|
@if(!$item->is_taxable)
|
||||||
|
<span class="ml-1.5 text-xs bg-gray-100 text-gray-500 px-2 py-0.5 rounded-full font-medium">Non-Taxable</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
<td class="py-3 px-4 text-sm text-center text-gray-600">{{ $item->quantity }}</td>
|
<td class="py-3 px-4 text-sm text-center text-gray-600">{{ $item->quantity }}</td>
|
||||||
<td class="py-3 px-4 text-sm text-right text-gray-600">Rp {{ number_format($item->unit_price, 0, ',', '.') }}</td>
|
<td class="py-3 px-4 text-sm text-right text-gray-600">Rp {{ number_format($item->unit_price, 0, ',', '.') }}</td>
|
||||||
<td class="py-3 px-4 text-sm text-right font-semibold text-gray-800">Rp {{ number_format($item->total, 0, ',', '.') }}</td>
|
<td class="py-3 px-4 text-sm text-right font-semibold text-gray-800">Rp {{ number_format($item->total, 0, ',', '.') }}</td>
|
||||||
@@ -75,24 +103,32 @@
|
|||||||
|
|
||||||
{{-- Totals --}}
|
{{-- Totals --}}
|
||||||
<div class="flex justify-end mb-8">
|
<div class="flex justify-end mb-8">
|
||||||
<div class="w-64 space-y-2 text-sm">
|
<div class="w-72 space-y-2 text-sm">
|
||||||
<div class="flex justify-between text-gray-500">
|
<div class="flex justify-between text-gray-500">
|
||||||
<span>Subtotal</span><span class="font-medium">Rp {{ number_format($invoice->subtotal, 0, ',', '.') }}</span>
|
<span>Subtotal</span><span class="font-medium">Rp {{ number_format($invoice->subtotal, 0, ',', '.') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between text-gray-500">
|
@if($invoice->tax_rate > 0)
|
||||||
<span>Tax ({{ $invoice->tax_rate }}%)</span><span class="font-medium">Rp {{ number_format($invoice->tax_amount, 0, ',', '.') }}</span>
|
<div class="flex justify-between text-amber-600">
|
||||||
|
<span>Tax ({{ $invoice->tax_rate }}% — paid by client)</span>
|
||||||
|
<span class="font-medium">Rp {{ number_format($invoice->tax_amount, 0, ',', '.') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between text-base font-bold text-pink-600 pt-2 border-t border-pink-200">
|
@endif
|
||||||
<span>Total</span><span>{{ $invoice->formatted_total }}</span>
|
<div class="flex justify-between text-base font-bold pt-2 border-t border-pink-200"
|
||||||
|
style="color:{{ $invoiceSettings->accent_color ?? '#FFB7C5' }}">
|
||||||
|
<span>Grand Total</span><span>{{ $invoice->formatted_total }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Bank Info --}}
|
{{-- Bank Info --}}
|
||||||
@if($invoice->bank_name)
|
@if($invoice->bank_name)
|
||||||
<div class="bg-pink-50 rounded-2xl p-4 text-sm">
|
<div class="rounded-2xl p-4 text-sm" style="background:{{ $tint }}">
|
||||||
<div class="font-semibold text-gray-700 mb-2">💳 Payment Info</div>
|
<div class="font-semibold text-gray-700 mb-2">💳 Payment Info</div>
|
||||||
<div class="text-gray-600">{{ $invoice->bank_name }} · {{ $invoice->bank_account }} · {{ $invoice->bank_holder }}</div>
|
<div class="text-gray-600">
|
||||||
|
{{ $invoice->bank_name }}
|
||||||
|
@if($invoice->branch_name) · {{ $invoice->branch_name }} @endif
|
||||||
|
· {{ $invoice->bank_account }} · a/n {{ $invoice->bank_holder }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,20 @@
|
|||||||
<html lang="en" data-theme="light">
|
<html lang="en" data-theme="light">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
|
||||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||||
|
<meta name="theme-color" content="#FFB7C5">
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="default">
|
||||||
|
<meta name="apple-mobile-web-app-title" content="{{ config('app.name') }}">
|
||||||
|
<link rel="manifest" href="/manifest.json">
|
||||||
|
<link rel="apple-touch-icon" href="/icons/icon-192.png">
|
||||||
<title>{{ config('app.name') }} — @yield('title', 'Dashboard')</title>
|
<title>{{ config('app.name') }} — @yield('title', 'Dashboard')</title>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||||
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
||||||
</head>
|
</head>
|
||||||
<body class="bg-cream font-sans antialiased" x-data="{ sidebarOpen: false }">
|
<body class="bg-cream font-sans antialiased" x-data="appShell()">
|
||||||
|
|
||||||
{{-- ── Backdrop (mobile only) ─────────────────────────────────── --}}
|
{{-- ── Backdrop (mobile only) ─────────────────────────────────── --}}
|
||||||
<div
|
<div
|
||||||
@@ -33,20 +39,16 @@
|
|||||||
transition-transform duration-300 ease-in-out
|
transition-transform duration-300 ease-in-out
|
||||||
lg:translate-x-0"
|
lg:translate-x-0"
|
||||||
>
|
>
|
||||||
{{-- Logo / Close trigger --}}
|
{{-- Logo --}}
|
||||||
<div class="flex items-center justify-between gap-3 mb-8 px-2">
|
<div class="flex items-center justify-between gap-3 mb-8 px-2">
|
||||||
<button
|
<a href="{{ route('dashboard') }}" @click="sidebarOpen = false"
|
||||||
@click="sidebarOpen = false"
|
class="flex items-center gap-3 group focus:outline-none">
|
||||||
class="flex items-center gap-3 group focus:outline-none"
|
|
||||||
aria-label="Close menu"
|
|
||||||
>
|
|
||||||
<span class="text-3xl transition-transform duration-200 group-hover:scale-110 group-active:scale-95 select-none">🐱</span>
|
<span class="text-3xl transition-transform duration-200 group-hover:scale-110 group-active:scale-95 select-none">🐱</span>
|
||||||
<div class="text-left">
|
<div class="text-left">
|
||||||
<div class="text-lg font-extrabold text-pink-500 leading-tight">KOL Manager</div>
|
<div class="text-lg font-extrabold text-pink-500 leading-tight">KOL Manager</div>
|
||||||
<div class="text-xs text-gray-400">Your Purr-fect Assistant</div>
|
<div class="text-xs text-gray-400">Your Purr-fect Assistant</div>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</a>
|
||||||
{{-- X button — mobile only --}}
|
|
||||||
<button @click="sidebarOpen = false" class="lg:hidden text-gray-400 hover:text-pink-500 text-xl leading-none" aria-label="Close">✕</button>
|
<button @click="sidebarOpen = false" class="lg:hidden text-gray-400 hover:text-pink-500 text-xl leading-none" aria-label="Close">✕</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -65,9 +67,6 @@
|
|||||||
class="nav-item {{ request()->routeIs('schedule.*') ? 'active' : '' }}">
|
class="nav-item {{ request()->routeIs('schedule.*') ? 'active' : '' }}">
|
||||||
<span class="text-lg shrink-0">📅</span>
|
<span class="text-lg shrink-0">📅</span>
|
||||||
<span class="flex-1">Schedule</span>
|
<span class="flex-1">Schedule</span>
|
||||||
@if($alertCount > 0)
|
|
||||||
<span class="badge-sakura shrink-0">{{ $alertCount }}</span>
|
|
||||||
@endif
|
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="{{ route('clients.index') }}"
|
<a href="{{ route('clients.index') }}"
|
||||||
@@ -76,6 +75,18 @@
|
|||||||
<span class="text-lg shrink-0">👥</span> Clients / CRM
|
<span class="text-lg shrink-0">👥</span> Clients / CRM
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<a href="{{ route('client-categories.index') }}"
|
||||||
|
@click="sidebarOpen = false"
|
||||||
|
class="nav-item {{ request()->routeIs('client-categories.*') ? 'active' : '' }}">
|
||||||
|
<span class="text-lg shrink-0">🏷️</span> Categories
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="{{ route('contracts.index') }}"
|
||||||
|
@click="sidebarOpen = false"
|
||||||
|
class="nav-item {{ request()->routeIs('contracts.*') ? 'active' : '' }}">
|
||||||
|
<span class="text-lg shrink-0">📋</span> Brand Contracts
|
||||||
|
</a>
|
||||||
|
|
||||||
<a href="{{ route('social-hub.index') }}"
|
<a href="{{ route('social-hub.index') }}"
|
||||||
@click="sidebarOpen = false"
|
@click="sidebarOpen = false"
|
||||||
class="nav-item {{ request()->routeIs('social-hub.*') ? 'active' : '' }}">
|
class="nav-item {{ request()->routeIs('social-hub.*') ? 'active' : '' }}">
|
||||||
@@ -109,17 +120,30 @@
|
|||||||
class="nav-item {{ request()->routeIs('files.*') ? 'active' : '' }}">
|
class="nav-item {{ request()->routeIs('files.*') ? 'active' : '' }}">
|
||||||
<span class="text-lg shrink-0">📁</span> Files
|
<span class="text-lg shrink-0">📁</span> Files
|
||||||
</a>
|
</a>
|
||||||
</nav>
|
|
||||||
|
|
||||||
{{-- Meow Toggle --}}
|
<a href="{{ route('notes.index') }}"
|
||||||
<div class="mt-4 px-2 border-t border-pink-50 pt-4">
|
@click="sidebarOpen = false"
|
||||||
<button onclick="window.KolManager.toggleMeow()"
|
class="nav-item {{ request()->routeIs('notes.*') ? 'active' : '' }}">
|
||||||
class="flex items-center gap-2 text-sm text-gray-500 hover:text-pink-500 transition-colors w-full">
|
<span class="text-lg shrink-0">📝</span> Notes
|
||||||
<span class="text-base">🔔</span>
|
</a>
|
||||||
<span>Meow Sounds</span>
|
|
||||||
|
<div class="text-xs font-bold text-gray-400 uppercase tracking-wider mt-4 mb-1 px-2">Settings</div>
|
||||||
|
|
||||||
|
<a href="{{ route('settings.notifications') }}"
|
||||||
|
@click="sidebarOpen = false"
|
||||||
|
class="nav-item {{ request()->routeIs('settings.*') ? 'active' : '' }}">
|
||||||
|
<span class="text-lg shrink-0">🔔</span> Notifications
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{{-- Logout --}}
|
||||||
|
<form method="POST" action="{{ route('gate.logout') }}" class="mt-auto pt-4">
|
||||||
|
@csrf
|
||||||
|
<button type="submit"
|
||||||
|
class="nav-item w-full text-left text-gray-400 hover:text-red-400 hover:bg-red-50 transition-colors">
|
||||||
|
<span class="text-lg shrink-0">🚪</span> Lock App
|
||||||
</button>
|
</button>
|
||||||
<div class="text-xs text-gray-400 mt-1">Toggle notification sounds</div>
|
</form>
|
||||||
</div>
|
</nav>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
{{-- ── Main wrapper ─────────────────────────────────────────────── --}}
|
{{-- ── Main wrapper ─────────────────────────────────────────────── --}}
|
||||||
@@ -127,36 +151,94 @@
|
|||||||
|
|
||||||
<div class="flex-1 flex flex-col min-w-0">
|
<div class="flex-1 flex flex-col min-w-0">
|
||||||
|
|
||||||
{{-- ── Mobile / Desktop Topbar ─────────────────────────── --}}
|
{{-- ── Topbar ───────────────────────────────────────────── --}}
|
||||||
<header class="sticky top-0 z-20 bg-white border-b border-pink-100 px-4 lg:px-8 py-3 lg:py-4 flex items-center gap-3 shadow-sm">
|
<header class="sticky top-0 z-20 bg-white border-b border-pink-100 px-4 lg:px-8 py-3 lg:py-4 flex items-center gap-3 shadow-sm">
|
||||||
|
|
||||||
{{-- Cat icon — hamburger for mobile --}}
|
{{-- Hamburger (mobile) --}}
|
||||||
<button
|
<button
|
||||||
@click="sidebarOpen = true"
|
@click="sidebarOpen = true"
|
||||||
class="lg:hidden text-2xl transition-transform duration-150 active:scale-90 focus:outline-none select-none"
|
class="lg:hidden text-2xl transition-transform duration-150 active:scale-90 focus:outline-none select-none"
|
||||||
aria-label="Open menu"
|
aria-label="Open menu"
|
||||||
>🐱</button>
|
>🐱</button>
|
||||||
|
|
||||||
<div class="flex-1 min-w-0">
|
{{-- Page title (hidden when search open) --}}
|
||||||
|
<div class="flex-1 min-w-0" x-show="!searchOpen" x-transition>
|
||||||
<h1 class="text-base lg:text-xl font-bold text-gray-800 truncate">@yield('page-title', 'Dashboard')</h1>
|
<h1 class="text-base lg:text-xl font-bold text-gray-800 truncate">@yield('page-title', 'Dashboard')</h1>
|
||||||
<p class="text-xs lg:text-sm text-gray-400 hidden sm:block">@yield('page-subtitle', today()->format('l, d F Y'))</p>
|
<p class="text-xs lg:text-sm text-gray-400 hidden sm:block">@yield('page-subtitle', today()->format('l, d F Y'))</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- ── Global Search bar ─────────────────────────── --}}
|
||||||
|
<div class="flex-1 min-w-0" x-show="searchOpen" x-transition style="display:none">
|
||||||
|
<div class="relative">
|
||||||
|
<span class="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-sm pointer-events-none">🔍</span>
|
||||||
|
<input
|
||||||
|
id="global-search-input"
|
||||||
|
type="text"
|
||||||
|
placeholder="Search clients, events, invoices…"
|
||||||
|
class="input-soft pl-9 pr-4 py-2 text-sm w-full"
|
||||||
|
x-model="searchQuery"
|
||||||
|
@input.debounce.300ms="doSearch()"
|
||||||
|
@keydown.escape="closeSearch()"
|
||||||
|
x-ref="searchInput"
|
||||||
|
>
|
||||||
|
{{-- Search results dropdown --}}
|
||||||
|
<div
|
||||||
|
x-show="searchResults.length > 0 || (searchQuery.length >= 2 && !searchLoading)"
|
||||||
|
class="absolute top-full left-0 right-0 mt-2 bg-white rounded-2xl shadow-xl border border-pink-100 z-50 max-h-80 overflow-y-auto"
|
||||||
|
@click.outside="searchResults = []"
|
||||||
|
>
|
||||||
|
<template x-if="searchLoading">
|
||||||
|
<div class="px-4 py-3 text-sm text-gray-400 flex items-center gap-2">
|
||||||
|
<span class="animate-spin">🐾</span> Searching…
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template x-if="!searchLoading && searchResults.length === 0 && searchQuery.length >= 2">
|
||||||
|
<div class="px-4 py-3 text-sm text-gray-400">No results for "<span x-text="searchQuery"></span>"</div>
|
||||||
|
</template>
|
||||||
|
<template x-for="group in searchResults" :key="group.type">
|
||||||
|
<div>
|
||||||
|
<div class="px-4 py-1.5 text-xs font-bold text-gray-400 uppercase tracking-wide bg-pink-50/60 sticky top-0"
|
||||||
|
x-text="group.label"></div>
|
||||||
|
<template x-for="item in group.items" :key="item.url">
|
||||||
|
<a :href="item.url"
|
||||||
|
class="flex items-center gap-3 px-4 py-2.5 hover:bg-pink-50 transition-colors"
|
||||||
|
@click="closeSearch()">
|
||||||
|
<span class="text-lg shrink-0" x-text="item.icon"></span>
|
||||||
|
<div class="min-w-0">
|
||||||
|
<div class="text-sm font-semibold text-gray-700 truncate" x-text="item.title"></div>
|
||||||
|
<div class="text-xs text-gray-400 truncate" x-text="item.subtitle"></div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="border-t border-pink-50 px-4 py-2">
|
||||||
|
<a :href="'/search?q=' + encodeURIComponent(searchQuery)"
|
||||||
|
class="text-xs text-pink-500 hover:text-pink-700 font-medium flex items-center gap-1"
|
||||||
|
@click="closeSearch()">
|
||||||
|
🔍 See all results for "<span x-text="searchQuery"></span>"
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Right actions --}}
|
||||||
<div class="flex items-center gap-2 shrink-0">
|
<div class="flex items-center gap-2 shrink-0">
|
||||||
@if($alertCount > 0)
|
{{-- Search toggle --}}
|
||||||
<a href="{{ route('schedule.index') }}"
|
<button
|
||||||
class="hidden sm:flex items-center gap-1.5 bg-pink-50 text-pink-600 text-xs px-3 py-1.5 rounded-full border border-pink-200">
|
@click="toggleSearch()"
|
||||||
<span>🔔</span>
|
class="w-8 h-8 lg:w-9 lg:h-9 rounded-full flex items-center justify-center hover:bg-pink-50 transition-colors text-gray-500 hover:text-pink-500"
|
||||||
<span class="font-semibold">{{ $alertCount }} alert{{ $alertCount > 1 ? 's' : '' }}</span>
|
:title="searchOpen ? 'Close search' : 'Search'"
|
||||||
</a>
|
aria-label="Toggle search"
|
||||||
{{-- Mobile: just the badge --}}
|
>
|
||||||
<a href="{{ route('schedule.index') }}" class="sm:hidden badge-sakura flex items-center gap-1">
|
<span x-text="searchOpen ? '✕' : '🔍'" class="text-sm lg:text-base"></span>
|
||||||
🔔 {{ $alertCount }}
|
</button>
|
||||||
</a>
|
|
||||||
@endif
|
{{-- Avatar --}}
|
||||||
<div class="w-8 h-8 lg:w-9 lg:h-9 rounded-full flex items-center justify-center text-white font-bold text-xs lg:text-sm shadow-sm"
|
<div class="w-8 h-8 lg:w-9 lg:h-9 rounded-full flex items-center justify-center text-white font-bold text-xs lg:text-sm shadow-sm"
|
||||||
style="background: linear-gradient(135deg, #FFB7C5, #E8D5F5);">
|
style="background: linear-gradient(135deg, #FFB7C5, #E8D5F5);">
|
||||||
KOL
|
FUN
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
@@ -185,7 +267,47 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@stack('scripts')
|
@stack('scripts')
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function appShell() {
|
||||||
|
return {
|
||||||
|
sidebarOpen: false,
|
||||||
|
searchOpen: false,
|
||||||
|
searchQuery: '',
|
||||||
|
searchResults: [],
|
||||||
|
searchLoading: false,
|
||||||
|
_searchTimer: null,
|
||||||
|
|
||||||
|
toggleSearch() {
|
||||||
|
this.searchOpen = !this.searchOpen;
|
||||||
|
if (this.searchOpen) {
|
||||||
|
this.$nextTick(() => this.$refs.searchInput?.focus());
|
||||||
|
} else {
|
||||||
|
this.searchQuery = '';
|
||||||
|
this.searchResults = [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
closeSearch() {
|
||||||
|
this.searchOpen = false;
|
||||||
|
this.searchQuery = '';
|
||||||
|
this.searchResults = [];
|
||||||
|
},
|
||||||
|
|
||||||
|
async doSearch() {
|
||||||
|
if (this.searchQuery.length < 2) { this.searchResults = []; return; }
|
||||||
|
this.searchLoading = true;
|
||||||
|
try {
|
||||||
|
const res = await fetch(`/search/quick?q=${encodeURIComponent(this.searchQuery)}`, {
|
||||||
|
headers: { 'X-Requested-With': 'XMLHttpRequest' }
|
||||||
|
});
|
||||||
|
this.searchResults = await res.json();
|
||||||
|
} catch { this.searchResults = []; }
|
||||||
|
this.searchLoading = false;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
483
resources/views/notes/index.blade.php
Normal file
483
resources/views/notes/index.blade.php
Normal file
@@ -0,0 +1,483 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'Notes')
|
||||||
|
@section('page-title', '📝 Notes')
|
||||||
|
@section('page-subtitle', 'Quick notes, checklists & reminders')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<div x-data="notesApp({{ json_encode($notes) }})" x-cloak>
|
||||||
|
|
||||||
|
{{-- ── Toolbar ──────────────────────────────────────────────── --}}
|
||||||
|
<div class="flex items-center gap-2 mb-4">
|
||||||
|
<button @click="openNew()"
|
||||||
|
class="btn-sakura text-sm px-4 py-2 flex items-center gap-1.5 shrink-0">
|
||||||
|
+ New Note
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{{-- Search --}}
|
||||||
|
<div class="relative flex-1 max-w-xs">
|
||||||
|
<span class="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-sm pointer-events-none">🔍</span>
|
||||||
|
<input type="text" x-model="searchQuery" placeholder="Search notes…"
|
||||||
|
class="input-soft pl-9 text-sm py-2 w-full">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Count --}}
|
||||||
|
<span class="ml-auto text-xs text-gray-400 shrink-0"
|
||||||
|
x-text="notes.length + ' note' + (notes.length !== 1 ? 's' : '')"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- ── Pinned section ───────────────────────────────────────── --}}
|
||||||
|
<template x-if="filteredPinned.length > 0">
|
||||||
|
<div class="mb-5">
|
||||||
|
<div class="text-xs font-bold text-gray-400 uppercase tracking-wider mb-2 flex items-center gap-1.5">
|
||||||
|
📌 Pinned
|
||||||
|
</div>
|
||||||
|
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-3">
|
||||||
|
<template x-for="note in filteredPinned" :key="note.id">
|
||||||
|
<div class="rounded-3xl p-4 flex flex-col gap-2 shadow-sm border border-black/5 cursor-pointer
|
||||||
|
hover:shadow-md transition-shadow duration-200 group relative"
|
||||||
|
:style="`background:${note.color || '#FFFFFF'}`"
|
||||||
|
@click="openEdit(note)">
|
||||||
|
|
||||||
|
{{-- Pin badge --}}
|
||||||
|
<div class="absolute top-2.5 right-2.5 text-xs text-amber-400 opacity-60 group-hover:opacity-100">📌</div>
|
||||||
|
|
||||||
|
{{-- Title --}}
|
||||||
|
<p class="font-bold text-gray-800 text-sm leading-snug pr-5 line-clamp-2"
|
||||||
|
x-text="note.title || 'Untitled'"></p>
|
||||||
|
|
||||||
|
{{-- Content preview --}}
|
||||||
|
<div class="flex-1 text-xs text-gray-500 space-y-0.5 line-clamp-4">
|
||||||
|
<template x-for="(block, i) in (note.content || []).slice(0, 4)" :key="i">
|
||||||
|
<div class="flex items-start gap-1.5 min-w-0">
|
||||||
|
<template x-if="block.type === 'bullet'">
|
||||||
|
<span class="shrink-0 text-gray-400 mt-px">•</span>
|
||||||
|
</template>
|
||||||
|
<template x-if="block.type === 'checkbox'">
|
||||||
|
<span class="shrink-0 mt-px" x-text="block.checked ? '☑' : '☐'"></span>
|
||||||
|
</template>
|
||||||
|
<span class="truncate"
|
||||||
|
:class="block.type === 'checkbox' && block.checked ? 'line-through text-gray-400' : ''"
|
||||||
|
x-text="block.text || '…'"></span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Footer --}}
|
||||||
|
<div class="flex items-center justify-between mt-1">
|
||||||
|
<span class="text-xs text-gray-400" x-text="formatDate(note.updated_at)"></span>
|
||||||
|
<button @click.stop="deleteNote(note)"
|
||||||
|
class="opacity-0 group-hover:opacity-100 text-xs text-red-400 hover:text-red-600 transition-opacity leading-none px-1">✕</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
{{-- ── All / Other notes ────────────────────────────────────── --}}
|
||||||
|
<template x-if="filteredUnpinned.length > 0 || (filteredPinned.length > 0)">
|
||||||
|
<div>
|
||||||
|
<template x-if="filteredPinned.length > 0 && filteredUnpinned.length > 0">
|
||||||
|
<div class="text-xs font-bold text-gray-400 uppercase tracking-wider mb-2">Others</div>
|
||||||
|
</template>
|
||||||
|
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-3">
|
||||||
|
<template x-for="note in filteredUnpinned" :key="note.id">
|
||||||
|
<div class="rounded-3xl p-4 flex flex-col gap-2 shadow-sm border border-black/5 cursor-pointer
|
||||||
|
hover:shadow-md transition-shadow duration-200 group"
|
||||||
|
:style="`background:${note.color || '#FFFFFF'}`"
|
||||||
|
@click="openEdit(note)">
|
||||||
|
|
||||||
|
{{-- Title --}}
|
||||||
|
<p class="font-bold text-gray-800 text-sm leading-snug line-clamp-2"
|
||||||
|
x-text="note.title || 'Untitled'"></p>
|
||||||
|
|
||||||
|
{{-- Content preview --}}
|
||||||
|
<div class="flex-1 text-xs text-gray-500 space-y-0.5">
|
||||||
|
<template x-for="(block, i) in (note.content || []).slice(0, 4)" :key="i">
|
||||||
|
<div class="flex items-start gap-1.5 min-w-0">
|
||||||
|
<template x-if="block.type === 'bullet'">
|
||||||
|
<span class="shrink-0 text-gray-400 mt-px">•</span>
|
||||||
|
</template>
|
||||||
|
<template x-if="block.type === 'checkbox'">
|
||||||
|
<span class="shrink-0 mt-px" x-text="block.checked ? '☑' : '☐'"></span>
|
||||||
|
</template>
|
||||||
|
<span class="truncate"
|
||||||
|
:class="block.type === 'checkbox' && block.checked ? 'line-through text-gray-400' : ''"
|
||||||
|
x-text="block.text || '…'"></span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Footer --}}
|
||||||
|
<div class="flex items-center justify-between mt-1">
|
||||||
|
<span class="text-xs text-gray-400" x-text="formatDate(note.updated_at)"></span>
|
||||||
|
<button @click.stop="deleteNote(note)"
|
||||||
|
class="opacity-0 group-hover:opacity-100 text-xs text-red-400 hover:text-red-600 transition-opacity leading-none px-1">✕</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
{{-- ── Empty state ──────────────────────────────────────────── --}}
|
||||||
|
<template x-if="notes.length === 0">
|
||||||
|
<div class="text-center py-20 text-gray-400">
|
||||||
|
<span class="text-5xl block mb-3">📝</span>
|
||||||
|
<p class="text-sm font-medium mb-4">No notes yet.</p>
|
||||||
|
<button @click="openNew()" class="btn-sakura text-sm">Write your first note</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template x-if="notes.length > 0 && filteredPinned.length === 0 && filteredUnpinned.length === 0">
|
||||||
|
<div class="text-center py-12 text-gray-400">
|
||||||
|
<span class="text-3xl block mb-2">🔍</span>
|
||||||
|
<p class="text-sm">No notes match "<span x-text="searchQuery"></span>"</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
{{-- ════════════════════════════════════════════════════════════
|
||||||
|
Note Editor Modal
|
||||||
|
════════════════════════════════════════════════════════════ --}}
|
||||||
|
<div x-show="showModal"
|
||||||
|
x-transition:enter="transition ease-out duration-200"
|
||||||
|
x-transition:enter-start="opacity-0"
|
||||||
|
x-transition:enter-end="opacity-100"
|
||||||
|
x-transition:leave="transition ease-in duration-150"
|
||||||
|
x-transition:leave-start="opacity-100"
|
||||||
|
x-transition:leave-end="opacity-0"
|
||||||
|
class="fixed inset-0 z-50 flex items-end sm:items-center justify-center bg-black/40 px-0 sm:px-4"
|
||||||
|
style="display:none"
|
||||||
|
@keydown.escape.window="showModal = false">
|
||||||
|
|
||||||
|
<div class="w-full sm:max-w-lg rounded-t-3xl sm:rounded-3xl shadow-2xl flex flex-col overflow-hidden"
|
||||||
|
:style="`background:${editorColor || '#FFFFFF'}`"
|
||||||
|
style="max-height:90vh"
|
||||||
|
@click.stop>
|
||||||
|
|
||||||
|
{{-- ── Modal Header ─────────────────────────────── --}}
|
||||||
|
<div class="flex items-center gap-2 px-4 pt-4 pb-3 border-b border-black/5 shrink-0">
|
||||||
|
|
||||||
|
{{-- Color swatches --}}
|
||||||
|
<div class="flex gap-1.5 flex-wrap">
|
||||||
|
<template x-for="c in noteColors" :key="c">
|
||||||
|
<button @click="editorColor = c" type="button"
|
||||||
|
class="w-5 h-5 rounded-full border-2 transition-transform hover:scale-110 shrink-0"
|
||||||
|
:style="`background:${c}`"
|
||||||
|
:class="editorColor === c ? 'border-gray-500 scale-110' : 'border-gray-200'">
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Pin toggle --}}
|
||||||
|
<button @click="editorPinned = !editorPinned" type="button"
|
||||||
|
class="ml-auto text-sm px-2.5 py-1 rounded-full border transition-colors shrink-0"
|
||||||
|
:class="editorPinned ? 'border-amber-300 bg-amber-50 text-amber-600' : 'border-gray-200 text-gray-400 hover:border-amber-200 hover:text-amber-400'">
|
||||||
|
📌 <span x-text="editorPinned ? 'Pinned' : 'Pin'"></span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{{-- Close --}}
|
||||||
|
<button @click="showModal = false" type="button"
|
||||||
|
class="text-gray-400 hover:text-gray-600 text-xl leading-none shrink-0 ml-1">✕</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- ── Scrollable Body ──────────────────────────── --}}
|
||||||
|
<div class="flex-1 overflow-y-auto px-4 py-3 space-y-1">
|
||||||
|
|
||||||
|
{{-- Title --}}
|
||||||
|
<input type="text" x-model="editorTitle" x-ref="titleInput"
|
||||||
|
placeholder="Note title…"
|
||||||
|
class="w-full bg-transparent border-none outline-none font-bold text-gray-800 text-lg placeholder-gray-300 mb-2"
|
||||||
|
@keydown.enter.prevent="focusFirstBlock()">
|
||||||
|
|
||||||
|
{{-- Blocks --}}
|
||||||
|
<template x-for="(block, idx) in editorBlocks" :key="block.id">
|
||||||
|
<div class="flex items-center gap-2 group/block py-0.5">
|
||||||
|
|
||||||
|
{{-- Left side: bullet / checkbox / empty --}}
|
||||||
|
<template x-if="block.type === 'bullet'">
|
||||||
|
<span class="text-gray-400 text-sm shrink-0 select-none mt-px">•</span>
|
||||||
|
</template>
|
||||||
|
<template x-if="block.type === 'checkbox'">
|
||||||
|
<input type="checkbox" x-model="block.checked"
|
||||||
|
class="w-4 h-4 accent-pink-400 shrink-0 cursor-pointer mt-px"
|
||||||
|
@click.stop>
|
||||||
|
</template>
|
||||||
|
<template x-if="block.type === 'paragraph'">
|
||||||
|
<span class="w-4 shrink-0"></span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
{{-- Text input --}}
|
||||||
|
<input type="text"
|
||||||
|
x-model="block.text"
|
||||||
|
:placeholder="block.type === 'paragraph' ? 'Add text…' : block.type === 'bullet' ? 'List item…' : 'To-do item…'"
|
||||||
|
:class="block.type === 'checkbox' && block.checked ? 'line-through text-gray-400' : 'text-gray-700'"
|
||||||
|
class="flex-1 bg-transparent border-none outline-none text-sm placeholder-gray-300 py-0.5"
|
||||||
|
:data-block-id="block.id"
|
||||||
|
@keydown.enter.prevent="insertBlockAfter(idx)"
|
||||||
|
@keydown.backspace="handleBackspace($event, block, idx)">
|
||||||
|
|
||||||
|
{{-- Block type switcher (hover) --}}
|
||||||
|
<div class="flex gap-0.5 opacity-0 group-hover/block:opacity-100 transition-opacity shrink-0">
|
||||||
|
<button @click.stop="changeType(idx, 'paragraph')" type="button"
|
||||||
|
:class="block.type === 'paragraph' ? 'text-pink-500' : 'text-gray-300 hover:text-gray-500'"
|
||||||
|
class="text-xs px-1 leading-none" title="Text">T</button>
|
||||||
|
<button @click.stop="changeType(idx, 'bullet')" type="button"
|
||||||
|
:class="block.type === 'bullet' ? 'text-pink-500' : 'text-gray-300 hover:text-gray-500'"
|
||||||
|
class="text-xs px-1 leading-none" title="Bullet">•</button>
|
||||||
|
<button @click.stop="changeType(idx, 'checkbox')" type="button"
|
||||||
|
:class="block.type === 'checkbox' ? 'text-pink-500' : 'text-gray-300 hover:text-gray-500'"
|
||||||
|
class="text-xs px-1 leading-none" title="Checkbox">☐</button>
|
||||||
|
<button @click.stop="removeBlock(idx)" type="button"
|
||||||
|
class="text-xs px-1 leading-none text-gray-300 hover:text-red-400 ml-1" title="Remove">✕</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
{{-- Add block toolbar --}}
|
||||||
|
<div class="flex gap-2 pt-3 border-t border-black/5 mt-2">
|
||||||
|
<button @click="addBlock('paragraph')" type="button"
|
||||||
|
class="flex items-center gap-1 text-xs px-3 py-1.5 rounded-full border border-gray-200 text-gray-500 hover:bg-white/60 hover:border-gray-300 transition-colors">
|
||||||
|
<span class="font-semibold">T</span> Text
|
||||||
|
</button>
|
||||||
|
<button @click="addBlock('bullet')" type="button"
|
||||||
|
class="flex items-center gap-1 text-xs px-3 py-1.5 rounded-full border border-gray-200 text-gray-500 hover:bg-white/60 hover:border-gray-300 transition-colors">
|
||||||
|
• Bullet
|
||||||
|
</button>
|
||||||
|
<button @click="addBlock('checkbox')" type="button"
|
||||||
|
class="flex items-center gap-1 text-xs px-3 py-1.5 rounded-full border border-gray-200 text-gray-500 hover:bg-white/60 hover:border-gray-300 transition-colors">
|
||||||
|
☐ Checkbox
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- ── Modal Footer ─────────────────────────────── --}}
|
||||||
|
<div class="flex gap-2 px-4 pb-5 pt-3 border-t border-black/5 shrink-0">
|
||||||
|
<button @click="saveNote()" type="button"
|
||||||
|
class="btn-sakura flex-1 py-2.5 text-sm flex items-center justify-center gap-2"
|
||||||
|
:disabled="saving">
|
||||||
|
<span x-show="!saving">💾 Save Note</span>
|
||||||
|
<span x-show="saving" class="flex items-center gap-1.5"><span class="animate-spin inline-block">🐾</span> Saving…</span>
|
||||||
|
</button>
|
||||||
|
<button @click="showModal = false" type="button"
|
||||||
|
class="flex-1 py-2.5 rounded-full border border-pink-200 text-gray-600 text-sm hover:bg-pink-50 transition-colors">
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>{{-- end x-data --}}
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script>
|
||||||
|
function notesApp(initialNotes) {
|
||||||
|
return {
|
||||||
|
notes: initialNotes,
|
||||||
|
showModal: false,
|
||||||
|
editing: null,
|
||||||
|
|
||||||
|
// editor state
|
||||||
|
editorTitle: '',
|
||||||
|
editorBlocks: [],
|
||||||
|
editorColor: '#FFFFFF',
|
||||||
|
editorPinned: false,
|
||||||
|
saving: false,
|
||||||
|
nextBlockId: 1,
|
||||||
|
searchQuery: '',
|
||||||
|
|
||||||
|
noteColors: [
|
||||||
|
'#FFFFFF', '#FFE4E8', '#FFF9C4', '#E8F5E9',
|
||||||
|
'#E3F2FD', '#F3E5F5', '#FFF3E0', '#E0F7FA'
|
||||||
|
],
|
||||||
|
|
||||||
|
// ── Computed / Filtered ───────────────────────────────
|
||||||
|
get filteredPinned() {
|
||||||
|
return this.filterNotes(this.notes.filter(n => n.is_pinned));
|
||||||
|
},
|
||||||
|
|
||||||
|
get filteredUnpinned() {
|
||||||
|
return this.filterNotes(this.notes.filter(n => !n.is_pinned));
|
||||||
|
},
|
||||||
|
|
||||||
|
filterNotes(list) {
|
||||||
|
const q = this.searchQuery.trim().toLowerCase();
|
||||||
|
if (!q) return list;
|
||||||
|
return list.filter(n =>
|
||||||
|
(n.title || '').toLowerCase().includes(q) ||
|
||||||
|
(n.content || []).some(b => (b.text || '').toLowerCase().includes(q))
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
// ── Modal open/close ─────────────────────────────────
|
||||||
|
openNew() {
|
||||||
|
this.editing = null;
|
||||||
|
this.editorTitle = '';
|
||||||
|
this.editorBlocks = [this.makeBlock('paragraph')];
|
||||||
|
this.editorColor = '#FFFFFF';
|
||||||
|
this.editorPinned = false;
|
||||||
|
this.showModal = true;
|
||||||
|
this.$nextTick(() => this.$refs.titleInput?.focus());
|
||||||
|
},
|
||||||
|
|
||||||
|
openEdit(note) {
|
||||||
|
this.editing = note;
|
||||||
|
this.editorTitle = note.title || '';
|
||||||
|
this.editorBlocks = (note.content && note.content.length)
|
||||||
|
? note.content.map(b => ({ ...b, id: this.nextBlockId++ }))
|
||||||
|
: [this.makeBlock('paragraph')];
|
||||||
|
this.editorColor = note.color || '#FFFFFF';
|
||||||
|
this.editorPinned = !!note.is_pinned;
|
||||||
|
this.showModal = true;
|
||||||
|
this.$nextTick(() => this.$refs.titleInput?.focus());
|
||||||
|
},
|
||||||
|
|
||||||
|
// ── CRUD ─────────────────────────────────────────────
|
||||||
|
async saveNote() {
|
||||||
|
if (!this.editorTitle.trim()) {
|
||||||
|
this.$refs.titleInput?.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.saving = true;
|
||||||
|
const csrfToken = document.querySelector('meta[name=csrf-token]').content;
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
title: this.editorTitle.trim(),
|
||||||
|
content: this.editorBlocks.map(({ type, text, checked }) => ({ type, text: text || '', checked: !!checked })),
|
||||||
|
color: this.editorColor,
|
||||||
|
is_pinned: this.editorPinned,
|
||||||
|
};
|
||||||
|
|
||||||
|
const url = this.editing ? `/notes/${this.editing.id}` : '/notes';
|
||||||
|
const method = this.editing ? 'PUT' : 'POST';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await fetch(url, {
|
||||||
|
method,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'X-CSRF-TOKEN': csrfToken,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(payload),
|
||||||
|
});
|
||||||
|
const saved = await res.json();
|
||||||
|
|
||||||
|
if (this.editing) {
|
||||||
|
const idx = this.notes.findIndex(n => n.id === this.editing.id);
|
||||||
|
if (idx !== -1) this.notes.splice(idx, 1, saved);
|
||||||
|
} else {
|
||||||
|
this.notes.unshift(saved);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.showModal = false;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Save failed', err);
|
||||||
|
}
|
||||||
|
this.saving = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
async deleteNote(note) {
|
||||||
|
if (!confirm(`Delete "${note.title || 'this note'}"?`)) return;
|
||||||
|
const csrfToken = document.querySelector('meta[name=csrf-token]').content;
|
||||||
|
|
||||||
|
const res = await fetch(`/notes/${note.id}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: { 'Accept': 'application/json', 'X-CSRF-TOKEN': csrfToken },
|
||||||
|
});
|
||||||
|
if (res.ok) {
|
||||||
|
this.notes = this.notes.filter(n => n.id !== note.id);
|
||||||
|
if (this.editing && this.editing.id === note.id) {
|
||||||
|
this.showModal = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async togglePin(note) {
|
||||||
|
const csrfToken = document.querySelector('meta[name=csrf-token]').content;
|
||||||
|
const res = await fetch(`/notes/${note.id}/pin`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
headers: { 'Accept': 'application/json', 'X-CSRF-TOKEN': csrfToken },
|
||||||
|
});
|
||||||
|
if (res.ok) {
|
||||||
|
const updated = await res.json();
|
||||||
|
const idx = this.notes.findIndex(n => n.id === note.id);
|
||||||
|
if (idx !== -1) this.notes.splice(idx, 1, updated);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// ── Block editor helpers ──────────────────────────────
|
||||||
|
makeBlock(type = 'paragraph') {
|
||||||
|
return { id: this.nextBlockId++, type, text: '', checked: false };
|
||||||
|
},
|
||||||
|
|
||||||
|
insertBlockAfter(idx) {
|
||||||
|
const currentType = this.editorBlocks[idx]?.type ?? 'paragraph';
|
||||||
|
const newBlock = this.makeBlock(currentType);
|
||||||
|
this.editorBlocks.splice(idx + 1, 0, newBlock);
|
||||||
|
this.$nextTick(() => {
|
||||||
|
document.querySelector(`[data-block-id="${newBlock.id}"]`)?.focus();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
handleBackspace(e, block, idx) {
|
||||||
|
if (block.text === '' && this.editorBlocks.length > 1) {
|
||||||
|
e.preventDefault();
|
||||||
|
this.editorBlocks.splice(idx, 1);
|
||||||
|
this.$nextTick(() => {
|
||||||
|
const target = this.editorBlocks[Math.max(0, idx - 1)];
|
||||||
|
if (target) document.querySelector(`[data-block-id="${target.id}"]`)?.focus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
addBlock(type) {
|
||||||
|
const nb = this.makeBlock(type);
|
||||||
|
this.editorBlocks.push(nb);
|
||||||
|
this.$nextTick(() => {
|
||||||
|
document.querySelector(`[data-block-id="${nb.id}"]`)?.focus();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
removeBlock(idx) {
|
||||||
|
if (this.editorBlocks.length > 1) {
|
||||||
|
this.editorBlocks.splice(idx, 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
changeType(idx, type) {
|
||||||
|
this.editorBlocks[idx].type = type;
|
||||||
|
},
|
||||||
|
|
||||||
|
focusFirstBlock() {
|
||||||
|
const first = this.editorBlocks[0];
|
||||||
|
if (first) {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
document.querySelector(`[data-block-id="${first.id}"]`)?.focus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// ── Utilities ─────────────────────────────────────────
|
||||||
|
formatDate(dt) {
|
||||||
|
if (!dt) return '';
|
||||||
|
const d = new Date(dt);
|
||||||
|
const now = new Date();
|
||||||
|
const diff = now - d;
|
||||||
|
|
||||||
|
if (diff < 60000) return 'just now';
|
||||||
|
if (diff < 3600000) return Math.floor(diff / 60000) + 'm ago';
|
||||||
|
if (diff < 86400000) return Math.floor(diff / 3600000) + 'h ago';
|
||||||
|
if (diff < 604800000) return Math.floor(diff / 86400000) + 'd ago';
|
||||||
|
|
||||||
|
return d.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' });
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
@endsection
|
||||||
@@ -5,11 +5,21 @@
|
|||||||
@section('page-subtitle', 'Manage your service pricing')
|
@section('page-subtitle', 'Manage your service pricing')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-5">
|
<div class="flex flex-wrap items-center justify-between gap-3 mb-5">
|
||||||
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
<a href="{{ route('rate-cards.public') }}" target="_blank"
|
<a href="{{ route('rate-cards.public') }}" target="_blank"
|
||||||
class="text-sm text-pink-500 hover:underline flex items-center gap-1">
|
class="text-xs px-3 py-2 rounded-full border border-pink-200 text-pink-500 hover:bg-pink-50 flex items-center gap-1">
|
||||||
🔗 View Public Page →
|
🔗 Public Page
|
||||||
</a>
|
</a>
|
||||||
|
<a href="{{ route('rate-cards.pdf') }}"
|
||||||
|
class="text-xs px-3 py-2 rounded-full border border-blue-200 text-blue-500 hover:bg-blue-50 flex items-center gap-1">
|
||||||
|
📄 PDF
|
||||||
|
</a>
|
||||||
|
<a href="{{ route('rate-cards.profile') }}"
|
||||||
|
class="text-xs px-3 py-2 rounded-full border border-purple-200 text-purple-500 hover:bg-purple-50 flex items-center gap-1">
|
||||||
|
🎨 Profile
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
<a href="{{ route('rate-cards.create') }}" class="btn-sakura text-sm shrink-0">+ Add Service</a>
|
<a href="{{ route('rate-cards.create') }}" class="btn-sakura text-sm shrink-0">+ Add Service</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -57,11 +67,12 @@
|
|||||||
class="flex-1 text-center text-xs py-2 rounded-full border border-pink-200 text-gray-600 hover:bg-pink-50 font-medium">
|
class="flex-1 text-center text-xs py-2 rounded-full border border-pink-200 text-gray-600 hover:bg-pink-50 font-medium">
|
||||||
Edit
|
Edit
|
||||||
</a>
|
</a>
|
||||||
|
{{-- Share button disabled --}}
|
||||||
<form action="{{ route('rate-cards.destroy', $card) }}" method="POST"
|
<form action="{{ route('rate-cards.destroy', $card) }}" method="POST"
|
||||||
onsubmit="return confirm('Delete this entry?')">
|
onsubmit="return confirm('Delete this entry?')">
|
||||||
@csrf @method('DELETE')
|
@csrf @method('DELETE')
|
||||||
<button class="text-xs py-2 px-4 rounded-full border border-red-100 text-red-400 hover:bg-red-50">
|
<button class="text-xs py-2 px-3 rounded-full border border-red-100 text-red-400 hover:bg-red-50">
|
||||||
Delete
|
✕
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@@ -79,4 +90,5 @@
|
|||||||
<a href="{{ route('rate-cards.create') }}" class="btn-sakura mt-4 inline-block">Add your first service!</a>
|
<a href="{{ route('rate-cards.create') }}" class="btn-sakura mt-4 inline-block">Add your first service!</a>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
{{-- Share scripts disabled --}}
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
142
resources/views/rate-cards/pdf.blade.php
Normal file
142
resources/views/rate-cards/pdf.blade.php
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
@php
|
||||||
|
// Convert hex accent color to rgb for rgba() usage in dompdf
|
||||||
|
$accent = ltrim($profile->accent_color ?? '#FFB7C5', '#');
|
||||||
|
$ar = hexdec(substr($accent, 0, 2));
|
||||||
|
$ag = hexdec(substr($accent, 2, 2));
|
||||||
|
$ab = hexdec(substr($accent, 4, 2));
|
||||||
|
$accentRgb = "{$ar},{$ag},{$ab}";
|
||||||
|
|
||||||
|
$bg = $profile->bg_color ?? '#FFFBFE';
|
||||||
|
$text = $profile->text_color ?? '#374151';
|
||||||
|
$accentHex = '#' . $accent;
|
||||||
|
@endphp
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Rate Card — {{ $profile->owner_name }}</title>
|
||||||
|
<style>
|
||||||
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||||
|
body {
|
||||||
|
font-family: 'DejaVu Sans', sans-serif;
|
||||||
|
background: {{ $bg }};
|
||||||
|
color: {{ $text }};
|
||||||
|
padding: 36px 32px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.header {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 32px;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
border-bottom: 2px solid {{ $accentHex }};
|
||||||
|
}
|
||||||
|
.logo-img { max-height: 72px; max-width: 140px; margin: 0 auto 10px; display: block; }
|
||||||
|
.name { font-size: 24px; font-weight: 700; color: {{ $accentHex }}; }
|
||||||
|
.tagline { color: #9CA3AF; margin-top: 4px; font-size: 11px; }
|
||||||
|
.contacts { margin-top: 10px; font-size: 10px; color: #6B7280; }
|
||||||
|
.contacts span { margin: 0 6px; }
|
||||||
|
.platform-section { margin-bottom: 22px; }
|
||||||
|
.platform-title {
|
||||||
|
font-size: 13px; font-weight: 700;
|
||||||
|
color: {{ $text }};
|
||||||
|
margin-bottom: 8px;
|
||||||
|
padding: 5px 10px;
|
||||||
|
background-color: rgba({{ $accentRgb }}, 0.1);
|
||||||
|
border-left: 4px solid {{ $accentHex }};
|
||||||
|
}
|
||||||
|
table { width: 100%; border-collapse: collapse; }
|
||||||
|
th {
|
||||||
|
text-align: left; padding: 7px 10px;
|
||||||
|
background-color: rgba({{ $accentRgb }}, 0.08);
|
||||||
|
color: #6B7280; font-size: 9px;
|
||||||
|
text-transform: uppercase; letter-spacing: 0.05em;
|
||||||
|
border-bottom: 1px solid rgba({{ $accentRgb }}, 0.25);
|
||||||
|
}
|
||||||
|
td { padding: 8px 10px; border-bottom: 1px solid #F3F4F6; vertical-align: top; }
|
||||||
|
tr:last-child td { border-bottom: none; }
|
||||||
|
.service-name { font-weight: 600; color: {{ $text }}; }
|
||||||
|
.content-type {
|
||||||
|
display: inline-block; font-size: 9px;
|
||||||
|
background-color: rgba({{ $accentRgb }}, 0.1);
|
||||||
|
color: {{ $accentHex }};
|
||||||
|
padding: 1px 7px; border-radius: 10px; margin-top: 2px;
|
||||||
|
}
|
||||||
|
.desc { color: #9CA3AF; font-size: 10px; margin-top: 3px; }
|
||||||
|
.price { font-weight: 700; color: {{ $accentHex }}; font-size: 13px; }
|
||||||
|
.price-unit { color: #9CA3AF; font-size: 9px; }
|
||||||
|
.negotiable { color: #F59E0B; font-size: 9px; font-weight: 600; }
|
||||||
|
.footer { text-align: center; margin-top: 36px; color: #D1D5DB; font-size: 9px; border-top: 1px solid #F3F4F6; padding-top: 14px; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="header">
|
||||||
|
@if($profile->logo_path && file_exists(storage_path('app/private/' . $profile->logo_path)))
|
||||||
|
<img src="{{ storage_path('app/private/' . $profile->logo_path) }}" class="logo-img" alt="{{ $profile->owner_name }}">
|
||||||
|
@endif
|
||||||
|
<div class="name">{{ $profile->owner_name }}</div>
|
||||||
|
@if($profile->tagline)
|
||||||
|
<div class="tagline">{{ $profile->tagline }}</div>
|
||||||
|
@endif
|
||||||
|
<div class="contacts">
|
||||||
|
@if($profile->email)<span>✉ {{ $profile->email }}</span>@endif
|
||||||
|
@if($profile->whatsapp)<span>· {{ $profile->whatsapp }}</span>@endif
|
||||||
|
@if($profile->ig_handle)<span>· @{{ $profile->ig_handle }}</span>@endif
|
||||||
|
@if($profile->tiktok_handle)<span>· @{{ $profile->tiktok_handle }}</span>@endif
|
||||||
|
@if($profile->youtube_handle)<span>· {{ $profile->youtube_handle }}</span>@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@foreach($rateCards as $platform => $cards)
|
||||||
|
<div class="platform-section">
|
||||||
|
<div class="platform-title">
|
||||||
|
@php $icons = ['instagram' => 'Instagram', 'tiktok' => 'TikTok', 'youtube' => 'YouTube', 'general' => 'General']; @endphp
|
||||||
|
{{ $icons[$platform] ?? ucfirst($platform) }}
|
||||||
|
</div>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width:38%">Service</th>
|
||||||
|
<th style="width:37%">Description</th>
|
||||||
|
<th style="width:25%; text-align:right">Price</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach($cards as $card)
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<div class="service-name">{{ $card->service_name }}</div>
|
||||||
|
@if($card->content_type)
|
||||||
|
<span class="content-type">{{ $card->content_type }}</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@if($card->description)
|
||||||
|
<div class="desc">{{ $card->description }}</div>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td style="text-align:right">
|
||||||
|
@if($profile->show_prices)
|
||||||
|
<div class="price">{{ $card->formatted_price }}</div>
|
||||||
|
<div class="price-unit">{{ str_replace('_', ' ', $card->price_unit) }}</div>
|
||||||
|
@else
|
||||||
|
<div class="price" style="font-size:11px">On Request</div>
|
||||||
|
@endif
|
||||||
|
@if($card->is_negotiable)
|
||||||
|
<div class="negotiable">Negotiable</div>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
<div class="footer">
|
||||||
|
{{ $profile->custom_footer ?: 'Prices may vary. Contact for custom packages.' }}
|
||||||
|
· Generated {{ now()->format('d M Y') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
172
resources/views/rate-cards/profile.blade.php
Normal file
172
resources/views/rate-cards/profile.blade.php
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
@section('title', 'Rate Card Profile')
|
||||||
|
@section('page-title', '🎨 Rate Card Profile')
|
||||||
|
@section('page-subtitle', 'Customise your public rate card page')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="max-w-3xl mx-auto space-y-5">
|
||||||
|
|
||||||
|
@if(session('success'))
|
||||||
|
<div x-data="{ show: true }" x-show="show" x-init="setTimeout(() => show = false, 4000)"
|
||||||
|
class="flex items-center justify-between gap-3 bg-green-50 border border-green-200 rounded-2xl px-4 py-3 text-sm text-green-700">
|
||||||
|
<span>{{ session('success') }}</span>
|
||||||
|
<button @click="show = false" class="text-green-500 hover:text-green-700 text-lg leading-none">✕</button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<form action="{{ route('rate-cards.profile.update') }}" method="POST" enctype="multipart/form-data"
|
||||||
|
class="space-y-5">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
{{-- Identity --}}
|
||||||
|
<div class="cat-card overflow-hidden">
|
||||||
|
<div class="flex items-center gap-3 px-5 py-4 border-b border-pink-50">
|
||||||
|
<span class="text-xl">👤</span>
|
||||||
|
<h2 class="font-bold text-gray-700">Identity</h2>
|
||||||
|
</div>
|
||||||
|
<div class="p-5 grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Display Name <span class="text-pink-400">*</span></label>
|
||||||
|
<input type="text" name="owner_name" required
|
||||||
|
value="{{ old('owner_name', $profile->owner_name) }}"
|
||||||
|
class="input-soft" placeholder="e.g. Sakura KOL">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Tagline</label>
|
||||||
|
<input type="text" name="tagline"
|
||||||
|
value="{{ old('tagline', $profile->tagline) }}"
|
||||||
|
class="input-soft" placeholder="e.g. Lifestyle & Beauty Creator">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Email</label>
|
||||||
|
<input type="email" name="email"
|
||||||
|
value="{{ old('email', $profile->email) }}"
|
||||||
|
class="input-soft" placeholder="hi@example.com">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">WhatsApp Number</label>
|
||||||
|
<input type="text" name="whatsapp"
|
||||||
|
value="{{ old('whatsapp', $profile->whatsapp) }}"
|
||||||
|
class="input-soft" placeholder="+6012-345-6789">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Instagram Handle</label>
|
||||||
|
<div class="relative">
|
||||||
|
<span class="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-sm pointer-events-none">@</span>
|
||||||
|
<input type="text" name="ig_handle"
|
||||||
|
value="{{ old('ig_handle', $profile->ig_handle) }}"
|
||||||
|
class="input-soft pl-7" placeholder="yourhandle">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">TikTok Handle</label>
|
||||||
|
<div class="relative">
|
||||||
|
<span class="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-sm pointer-events-none">@</span>
|
||||||
|
<input type="text" name="tiktok_handle"
|
||||||
|
value="{{ old('tiktok_handle', $profile->tiktok_handle) }}"
|
||||||
|
class="input-soft pl-7" placeholder="yourhandle">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">YouTube Handle / Channel</label>
|
||||||
|
<input type="text" name="youtube_handle"
|
||||||
|
value="{{ old('youtube_handle', $profile->youtube_handle) }}"
|
||||||
|
class="input-soft" placeholder="@yourchannel">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Appearance --}}
|
||||||
|
<div class="cat-card overflow-hidden">
|
||||||
|
<div class="flex items-center gap-3 px-5 py-4 border-b border-pink-50">
|
||||||
|
<span class="text-xl">🎨</span>
|
||||||
|
<h2 class="font-bold text-gray-700">Appearance</h2>
|
||||||
|
</div>
|
||||||
|
<div class="p-5 grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Logo / Profile Image</label>
|
||||||
|
@if($profile->logo_path)
|
||||||
|
<div class="flex items-center gap-3 mb-2">
|
||||||
|
<img src="{{ route('files.serve-profile-logo') }}" alt="Logo"
|
||||||
|
class="w-16 h-16 object-cover rounded-2xl border border-pink-100">
|
||||||
|
<span class="text-xs text-gray-400">Current logo</span>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
<input type="file" name="logo" accept="image/*"
|
||||||
|
class="w-full text-sm text-gray-600
|
||||||
|
file:mr-3 file:py-2 file:px-4 file:rounded-full file:border-0
|
||||||
|
file:text-xs file:font-semibold file:bg-pink-50 file:text-pink-600
|
||||||
|
hover:file:bg-pink-100 cursor-pointer">
|
||||||
|
<p class="text-xs text-gray-400 mt-1">Max 2MB. PNG/JPG/WebP.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Background Color</label>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<input type="color" name="bg_color" value="{{ old('bg_color', $profile->bg_color) }}"
|
||||||
|
class="h-10 w-16 rounded-2xl border border-pink-200 cursor-pointer p-1 bg-white shrink-0"
|
||||||
|
oninput="document.getElementById('bg_text').value=this.value">
|
||||||
|
<input type="text" id="bg_text" value="{{ old('bg_color', $profile->bg_color) }}"
|
||||||
|
class="input-soft text-sm flex-1" readonly>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Accent Color</label>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<input type="color" name="accent_color" value="{{ old('accent_color', $profile->accent_color) }}"
|
||||||
|
class="h-10 w-16 rounded-2xl border border-pink-200 cursor-pointer p-1 bg-white shrink-0"
|
||||||
|
oninput="document.getElementById('accent_text').value=this.value">
|
||||||
|
<input type="text" id="accent_text" value="{{ old('accent_color', $profile->accent_color) }}"
|
||||||
|
class="input-soft text-sm flex-1" readonly>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Text Color</label>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<input type="color" name="text_color" value="{{ old('text_color', $profile->text_color) }}"
|
||||||
|
class="h-10 w-16 rounded-2xl border border-pink-200 cursor-pointer p-1 bg-white shrink-0"
|
||||||
|
oninput="document.getElementById('text_text').value=this.value">
|
||||||
|
<input type="text" id="text_text" value="{{ old('text_color', $profile->text_color) }}"
|
||||||
|
class="input-soft text-sm flex-1" readonly>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Custom Footer</label>
|
||||||
|
<input type="text" name="custom_footer"
|
||||||
|
value="{{ old('custom_footer', $profile->custom_footer) }}"
|
||||||
|
class="input-soft"
|
||||||
|
placeholder="e.g. Prices valid until Dec 2025 · DM for bundles">
|
||||||
|
</div>
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="flex items-start gap-3 cursor-pointer">
|
||||||
|
<input type="checkbox" name="show_prices" value="1"
|
||||||
|
class="w-4 h-4 accent-pink-400 mt-0.5 shrink-0"
|
||||||
|
{{ old('show_prices', $profile->show_prices) ? 'checked' : '' }}>
|
||||||
|
<div>
|
||||||
|
<span class="text-sm font-medium text-gray-700">Show prices publicly</span>
|
||||||
|
<p class="text-xs text-gray-400">Uncheck to show "On Request" instead of actual prices</p>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Actions --}}
|
||||||
|
<div class="flex flex-wrap items-center gap-3">
|
||||||
|
<button type="submit" class="btn-sakura px-6 py-2.5">💾 Save Profile</button>
|
||||||
|
<a href="{{ route('rate-cards.public') }}" target="_blank"
|
||||||
|
class="text-xs px-4 py-2.5 rounded-full border border-pink-200 text-pink-500 hover:bg-pink-50">
|
||||||
|
👁️ Preview Public Page
|
||||||
|
</a>
|
||||||
|
<a href="{{ route('rate-cards.pdf') }}"
|
||||||
|
class="text-xs px-4 py-2.5 rounded-full border border-blue-200 text-blue-500 hover:bg-blue-50">
|
||||||
|
📄 Download PDF
|
||||||
|
</a>
|
||||||
|
<a href="{{ route('rate-cards.index') }}"
|
||||||
|
class="text-xs px-4 py-2.5 rounded-full border border-gray-200 text-gray-500 hover:bg-gray-50">
|
||||||
|
← Back to Rate Cards
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
@@ -3,36 +3,76 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Rate Card — KOL Manager</title>
|
<title>Rate Card — {{ $profile->owner_name }}</title>
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||||
body { font-family: 'Nunito', sans-serif; background: #FFF8F0; color: #374151; padding: 40px 20px; }
|
body { font-family: 'Nunito', sans-serif; background: {{ $profile->bg_color }}; color: {{ $profile->text_color }}; padding: 40px 20px; }
|
||||||
.container { max-width: 800px; margin: 0 auto; }
|
.container { max-width: 820px; margin: 0 auto; }
|
||||||
.header { text-align: center; margin-bottom: 48px; }
|
.header { text-align: center; margin-bottom: 48px; }
|
||||||
.logo { font-size: 48px; margin-bottom: 12px; }
|
.logo-img { max-height: 100px; max-width: 200px; margin: 0 auto 16px; display: block; border-radius: 16px; }
|
||||||
.title { font-size: 32px; font-weight: 900; color: #FFB7C5; }
|
.title { font-size: 32px; font-weight: 900; color: {{ $profile->accent_color }}; }
|
||||||
.subtitle { color: #9CA3AF; margin-top: 6px; font-size: 14px; }
|
.tagline { color: #9CA3AF; margin-top: 6px; font-size: 14px; }
|
||||||
|
.contacts { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px 20px; margin-top: 16px; }
|
||||||
|
.contact-pill {
|
||||||
|
display: inline-flex; align-items: center; gap-6px;
|
||||||
|
background: white; border: 1px solid {{ $profile->accent_color }}44;
|
||||||
|
border-radius: 99px; padding: 6px 14px; font-size: 12px; color: {{ $profile->text_color }};
|
||||||
|
text-decoration: none; transition: background 0.2s;
|
||||||
|
}
|
||||||
|
.contact-pill:hover { background: {{ $profile->accent_color }}18; }
|
||||||
.platform-section { margin-bottom: 32px; }
|
.platform-section { margin-bottom: 32px; }
|
||||||
.platform-title { font-size: 18px; font-weight: 800; color: #374151; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
|
.platform-title { font-size: 18px; font-weight: 800; color: {{ $profile->text_color }}; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
|
||||||
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
|
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
|
||||||
.card { background: white; border-radius: 24px; padding: 20px; border: 1px solid #FFE4EC; box-shadow: 0 2px 8px rgba(255,183,197,0.15); }
|
.card { background: white; border-radius: 24px; padding: 20px; border: 1px solid {{ $profile->accent_color }}33; box-shadow: 0 2px 8px {{ $profile->accent_color }}22; }
|
||||||
.service { font-weight: 700; color: #1F2937; margin-bottom: 6px; }
|
.service { font-weight: 700; color: #1F2937; margin-bottom: 6px; }
|
||||||
.type { display: inline-block; background: #FFF0F5; color: #FFB7C5; font-size: 11px; font-weight: 600; padding: 2px 10px; border-radius: 20px; margin-bottom: 8px; }
|
.type { display: inline-block; background: {{ $profile->accent_color }}18; color: {{ $profile->accent_color }}; font-size: 11px; font-weight: 600; padding: 2px 10px; border-radius: 20px; margin-bottom: 8px; }
|
||||||
.desc { font-size: 12px; color: #9CA3AF; margin-bottom: 12px; line-height: 1.5; }
|
.desc { font-size: 12px; color: #9CA3AF; margin-bottom: 12px; line-height: 1.5; }
|
||||||
.price { font-size: 22px; font-weight: 900; color: #FFB7C5; }
|
.price { font-size: 22px; font-weight: 900; color: {{ $profile->accent_color }}; }
|
||||||
.price-meta { font-size: 11px; color: #D1D5DB; margin-top: 2px; }
|
.price-meta { font-size: 11px; color: #D1D5DB; margin-top: 2px; }
|
||||||
.negotiable { font-size: 11px; color: #F59E0B; font-weight: 600; }
|
.negotiable { font-size: 11px; color: #F59E0B; font-weight: 600; }
|
||||||
.footer { text-align: center; margin-top: 60px; color: #D1D5DB; font-size: 12px; }
|
.footer { text-align: center; margin-top: 60px; color: #D1D5DB; font-size: 12px; }
|
||||||
@media print { body { background: white; } .card { break-inside: avoid; } }
|
.pdf-btn {
|
||||||
|
display: inline-flex; align-items: center; gap: 6px;
|
||||||
|
background: {{ $profile->accent_color }}; color: white;
|
||||||
|
border: none; border-radius: 99px; padding: 10px 24px;
|
||||||
|
font-size: 14px; font-weight: 700; cursor: pointer;
|
||||||
|
text-decoration: none; transition: opacity 0.2s;
|
||||||
|
}
|
||||||
|
.pdf-btn:hover { opacity: 0.9; }
|
||||||
|
@media print { body { background: white; } .card { break-inside: avoid; } .pdf-btn { display: none; } }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="logo">🐱</div>
|
@if($profile->logo_path)
|
||||||
<div class="title">Rate Card</div>
|
<img src="{{ route('files.serve-profile-logo') }}" alt="{{ $profile->owner_name }}" class="logo-img">
|
||||||
<div class="subtitle">Services & Pricing · {{ now()->format('Y') }}</div>
|
@else
|
||||||
|
<div style="font-size:56px; margin-bottom:12px;">🐱</div>
|
||||||
|
@endif
|
||||||
|
<div class="title">{{ $profile->owner_name }}</div>
|
||||||
|
@if($profile->tagline)
|
||||||
|
<div class="tagline">{{ $profile->tagline }}</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="contacts" style="margin-top:14px">
|
||||||
|
@if($profile->whatsappUrl)
|
||||||
|
<a href="{{ $profile->whatsappUrl }}" target="_blank" class="contact-pill">📱 WhatsApp</a>
|
||||||
|
@endif
|
||||||
|
@if($profile->ig_handle)
|
||||||
|
<a href="https://instagram.com/{{ ltrim($profile->ig_handle, '@') }}" target="_blank" class="contact-pill">📸 @{{ $profile->ig_handle }}</a>
|
||||||
|
@endif
|
||||||
|
@if($profile->tiktok_handle)
|
||||||
|
<a href="https://tiktok.com/@{{ ltrim($profile->tiktok_handle, '@') }}" target="_blank" class="contact-pill">🎵 @{{ $profile->tiktok_handle }}</a>
|
||||||
|
@endif
|
||||||
|
@if($profile->youtube_handle)
|
||||||
|
<a href="https://youtube.com/{{ $profile->youtube_handle }}" target="_blank" class="contact-pill">▶️ {{ $profile->youtube_handle }}</a>
|
||||||
|
@endif
|
||||||
|
@if($profile->email)
|
||||||
|
<a href="mailto:{{ $profile->email }}" class="contact-pill">✉️ {{ $profile->email }}</a>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@forelse($rateCards as $platform => $cards)
|
@forelse($rateCards as $platform => $cards)
|
||||||
@@ -51,8 +91,12 @@
|
|||||||
@if($card->description)
|
@if($card->description)
|
||||||
<div class="desc">{{ $card->description }}</div>
|
<div class="desc">{{ $card->description }}</div>
|
||||||
@endif
|
@endif
|
||||||
|
@if($profile->show_prices)
|
||||||
<div class="price">{{ $card->formatted_price }}</div>
|
<div class="price">{{ $card->formatted_price }}</div>
|
||||||
<div class="price-meta">{{ str_replace('_', ' ', $card->price_unit) }}</div>
|
<div class="price-meta">{{ str_replace('_', ' ', $card->price_unit) }}</div>
|
||||||
|
@else
|
||||||
|
<div class="price" style="font-size:16px">On Request</div>
|
||||||
|
@endif
|
||||||
@if($card->is_negotiable)
|
@if($card->is_negotiable)
|
||||||
<div class="negotiable">✦ Negotiable</div>
|
<div class="negotiable">✦ Negotiable</div>
|
||||||
@endif
|
@endif
|
||||||
@@ -65,7 +109,8 @@
|
|||||||
@endforelse
|
@endforelse
|
||||||
|
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
Generated by KOL Manager · Prices may vary. Contact for custom packages. 🐾
|
{{ $profile->custom_footer ?: 'Prices may vary. Contact for custom packages. 🐾' }}
|
||||||
|
<br>Generated by KOL Manager · {{ now()->format('Y') }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
323
resources/views/schedule/create.blade.php
Normal file
323
resources/views/schedule/create.blade.php
Normal file
@@ -0,0 +1,323 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'Add Event')
|
||||||
|
@section('page-title', 'Add Event 📅')
|
||||||
|
@section('page-subtitle', 'Schedule a new task, meeting, or posting')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="max-w-2xl mx-auto">
|
||||||
|
<div class="flex items-center gap-3 mb-5">
|
||||||
|
<a href="{{ route('schedule.index') }}"
|
||||||
|
class="text-xs px-3 py-2 rounded-full border border-pink-200 text-gray-500 hover:bg-pink-50">
|
||||||
|
← Back to Schedule
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="cat-card p-4 lg:p-8">
|
||||||
|
<form action="{{ route('schedule.store') }}" method="POST" id="create-event-form"
|
||||||
|
x-data="contractCheck('{{ route('contracts.check') }}')"
|
||||||
|
class="space-y-5">
|
||||||
|
@csrf
|
||||||
|
<input type="hidden" name="start_time" id="start_time_hidden">
|
||||||
|
<input type="hidden" name="end_time" id="end_time_hidden">
|
||||||
|
|
||||||
|
{{-- Title --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">
|
||||||
|
Title <span class="text-pink-400">*</span>
|
||||||
|
</label>
|
||||||
|
<input type="text" name="title" value="{{ old('title') }}"
|
||||||
|
class="input-soft" placeholder="Event title" required>
|
||||||
|
@error('title') <p class="text-xs text-red-500 mt-1">{{ $message }}</p> @enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
|
{{-- Type --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Type</label>
|
||||||
|
<select name="event_type" class="input-soft">
|
||||||
|
@foreach(['task' => '📋 Task', 'meeting' => '🤝 Meeting', 'deadline' => '⏰ Deadline', 'posting' => '📸 Posting'] as $val => $label)
|
||||||
|
<option value="{{ $val }}" {{ old('event_type') === $val ? 'selected' : '' }}>
|
||||||
|
{{ $label }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Client --}}
|
||||||
|
<div x-data="{
|
||||||
|
isNew: false,
|
||||||
|
saving: false,
|
||||||
|
newName: '', newEmail: '', newPhone: '', newCompany: '',
|
||||||
|
errMsg: '',
|
||||||
|
onClientChange(e) {
|
||||||
|
this.isNew = (e.target.value === '__new__');
|
||||||
|
if (!this.isNew) {
|
||||||
|
clientId = e.target.value;
|
||||||
|
$dispatch('contract-check');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async saveNewClient() {
|
||||||
|
if (!this.newName.trim()) { this.errMsg = 'Name is required.'; return; }
|
||||||
|
this.saving = true; this.errMsg = '';
|
||||||
|
const fd = new FormData();
|
||||||
|
fd.append('name', this.newName);
|
||||||
|
fd.append('email', this.newEmail);
|
||||||
|
fd.append('phone', this.newPhone);
|
||||||
|
fd.append('company', this.newCompany);
|
||||||
|
fd.append('_token', document.querySelector('meta[name=csrf-token]').content);
|
||||||
|
const res = await fetch('{{ route('clients.quick-store') }}', { method:'POST', body: fd });
|
||||||
|
const data = await res.json();
|
||||||
|
if (res.ok) {
|
||||||
|
// Add new option & select it
|
||||||
|
const sel = document.getElementById('client-select');
|
||||||
|
const opt = new Option(data.name, data.id, true, true);
|
||||||
|
sel.add(opt, sel.options[1]);
|
||||||
|
sel.value = data.id;
|
||||||
|
sel.dispatchEvent(new Event('change'));
|
||||||
|
this.isNew = false;
|
||||||
|
this.newName = this.newEmail = this.newPhone = this.newCompany = '';
|
||||||
|
} else {
|
||||||
|
this.errMsg = data.message ?? 'Could not create client.';
|
||||||
|
}
|
||||||
|
this.saving = false;
|
||||||
|
}
|
||||||
|
}">
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Client</label>
|
||||||
|
<select name="client_id" id="client-select" class="input-soft"
|
||||||
|
x-model="clientId"
|
||||||
|
@change="onClientChange($event); if($event.target.value !== '__new__') checkContract()">
|
||||||
|
<option value="">— None —</option>
|
||||||
|
<option value="__new__" class="font-semibold text-pink-600">+ Create New Client…</option>
|
||||||
|
@foreach($clients as $client)
|
||||||
|
<option value="{{ $client->id }}" {{ old('client_id') == $client->id ? 'selected' : '' }}>
|
||||||
|
{{ $client->name }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
|
||||||
|
{{-- Quick New Client mini-form --}}
|
||||||
|
<div x-show="isNew" x-transition
|
||||||
|
class="mt-3 bg-purple-50 rounded-2xl p-4 space-y-3 border border-purple-100">
|
||||||
|
<p class="text-xs font-bold text-purple-700">🐱 New Client Basic Info</p>
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Name <span class="text-pink-400">*</span></label>
|
||||||
|
<input type="text" x-model="newName" class="input-soft text-sm" placeholder="Client / brand name">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Company</label>
|
||||||
|
<input type="text" x-model="newCompany" class="input-soft text-sm" placeholder="Company name">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Email</label>
|
||||||
|
<input type="email" x-model="newEmail" class="input-soft text-sm" placeholder="contact@brand.com">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Phone</label>
|
||||||
|
<input type="text" x-model="newPhone" class="input-soft text-sm" placeholder="+62 …">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p x-show="errMsg" x-text="errMsg" class="text-xs text-red-500"></p>
|
||||||
|
<div class="flex gap-2 pt-1">
|
||||||
|
<button type="button" @click="saveNewClient()" :disabled="saving"
|
||||||
|
class="btn-sakura text-sm px-4 py-2" x-text="saving ? 'Saving…' : '✓ Add & Select'"></button>
|
||||||
|
<button type="button" @click="isNew = false; $el.closest('div').querySelector('select').value = ''"
|
||||||
|
class="text-sm px-4 py-2 rounded-full border border-pink-200 text-gray-500 hover:bg-pink-50">
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<p class="text-xs text-purple-400">Status will be set to Active automatically.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Category --}}
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Category</label>
|
||||||
|
<select name="category_id" class="input-soft" x-model="categoryId" @change="checkContract()">
|
||||||
|
<option value="">— None —</option>
|
||||||
|
@foreach($categoryTree as $parent)
|
||||||
|
<option value="{{ $parent->id }}" {{ old('category_id') == $parent->id ? 'selected' : '' }}>
|
||||||
|
{{ $parent->icon }} {{ $parent->name }}
|
||||||
|
</option>
|
||||||
|
@foreach($parent->children as $child)
|
||||||
|
<option value="{{ $child->id }}" {{ old('category_id') == $child->id ? 'selected' : '' }}>
|
||||||
|
↳ {{ $child->name }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Contract warning --}}
|
||||||
|
<div x-show="contractWarning" x-transition
|
||||||
|
class="sm:col-span-2 rounded-2xl bg-amber-50 border border-amber-200 px-4 py-3 text-sm"
|
||||||
|
style="display:none">
|
||||||
|
<div class="font-semibold text-amber-700 mb-1">⚠️ Exclusive Contract Active</div>
|
||||||
|
<p class="text-amber-600 text-xs" x-text="contractMessage"></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Start Date --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">
|
||||||
|
Start Date <span class="text-pink-400">*</span>
|
||||||
|
</label>
|
||||||
|
<input type="date" id="start_date" class="input-soft"
|
||||||
|
value="{{ old('_start_date') }}" required>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Start Time</label>
|
||||||
|
<input type="time" id="start_time_input" class="input-soft" value="09:00">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- End Date --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">End Date</label>
|
||||||
|
<input type="date" id="end_date" class="input-soft" value="{{ old('_end_date') }}">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">End Time</label>
|
||||||
|
<input type="time" id="end_time_input" class="input-soft" value="18:00">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Location --}}
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Location</label>
|
||||||
|
<input type="text" name="location" value="{{ old('location') }}"
|
||||||
|
class="input-soft" placeholder="Online / venue address">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Description --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Description</label>
|
||||||
|
<textarea name="description" rows="2" class="input-soft resize-none"
|
||||||
|
placeholder="Brief description…">{{ old('description') }}</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Color --}}
|
||||||
|
<div x-data="{ color: '{{ old('color', '#FFB7C5') }}' }">
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-2">Color</label>
|
||||||
|
<input type="hidden" name="color" :value="color">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<input type="color" x-model="color"
|
||||||
|
class="w-10 h-10 rounded-xl cursor-pointer border-2 border-pink-100 p-0.5 shrink-0">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Priority --}}
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<input type="checkbox" name="is_priority" value="1" id="priority"
|
||||||
|
class="w-4 h-4 accent-pink-400" {{ old('is_priority') ? 'checked' : '' }}>
|
||||||
|
<label for="priority" class="text-sm text-gray-600 cursor-pointer">⭐ Mark as Priority</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Notes --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Notes</label>
|
||||||
|
<textarea name="notes" rows="3" class="input-soft resize-none"
|
||||||
|
placeholder="Additional notes…">{{ old('notes') }}</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- ── Add to Content Board ──────────────────────────────── --}}
|
||||||
|
<div x-data="{ addToBoard: {{ old('add_to_content_board') ? 'true' : 'false' }} }">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<input type="checkbox" name="add_to_content_board" value="1" id="add_to_content_board"
|
||||||
|
class="w-4 h-4 accent-pink-400" x-model="addToBoard">
|
||||||
|
<label for="add_to_content_board" class="text-sm text-gray-600 cursor-pointer">
|
||||||
|
🗂️ Also add to Content Board as a Drafting card
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div x-show="addToBoard" x-transition
|
||||||
|
class="mt-3 grid grid-cols-1 sm:grid-cols-2 gap-3 bg-purple-50 rounded-2xl p-4">
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Platform</label>
|
||||||
|
<select name="content_platform" class="input-soft text-sm">
|
||||||
|
<option value="instagram" {{ old('content_platform') === 'instagram' ? 'selected' : '' }}>📸 Instagram</option>
|
||||||
|
<option value="tiktok" {{ old('content_platform') === 'tiktok' ? 'selected' : '' }}>🎵 TikTok</option>
|
||||||
|
<option value="youtube" {{ old('content_platform') === 'youtube' ? 'selected' : '' }}>▶️ YouTube</option>
|
||||||
|
<option value="other" {{ old('content_platform') === 'other' ? 'selected' : '' }}>📱 Other</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Content Type</label>
|
||||||
|
<select name="content_type" class="input-soft text-sm">
|
||||||
|
<option value="post" {{ old('content_type') === 'post' ? 'selected' : '' }}>Post / Feed</option>
|
||||||
|
<option value="reel" {{ old('content_type') === 'reel' ? 'selected' : '' }}>Reel / Short</option>
|
||||||
|
<option value="story" {{ old('content_type') === 'story' ? 'selected' : '' }}>Story</option>
|
||||||
|
<option value="video" {{ old('content_type') === 'video' ? 'selected' : '' }}>Long Video</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<p class="sm:col-span-2 text-xs text-purple-500">
|
||||||
|
A Drafting card will be created in your Content Board with this event's title and date.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- ── Brand Contract ────────────────────────────────────── --}}
|
||||||
|
<div x-data="{ createContract: {{ old('create_brand_contract') ? 'true' : 'false' }} }">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<input type="checkbox" name="create_brand_contract" value="1" id="create_contract"
|
||||||
|
class="w-4 h-4 accent-pink-400" x-model="createContract">
|
||||||
|
<label for="create_contract" class="text-sm text-gray-600 cursor-pointer">
|
||||||
|
📄 Also create a Brand Contract for this event
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div x-show="createContract" x-transition
|
||||||
|
class="mt-3 grid grid-cols-1 sm:grid-cols-2 gap-3 bg-pink-50 rounded-2xl p-4">
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Contract Title</label>
|
||||||
|
<input type="text" name="contract_title" class="input-soft text-sm"
|
||||||
|
placeholder="e.g. Exclusive Posting Contract — BrandX"
|
||||||
|
value="{{ old('contract_title') }}">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Contract Start</label>
|
||||||
|
<input type="date" name="contract_start_date" class="input-soft text-sm"
|
||||||
|
value="{{ old('contract_start_date') }}">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Contract End</label>
|
||||||
|
<input type="date" name="contract_end_date" class="input-soft text-sm"
|
||||||
|
value="{{ old('contract_end_date') }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-col sm:flex-row gap-3 pt-1">
|
||||||
|
<button type="submit" class="btn-sakura flex-1 py-3"
|
||||||
|
:class="{ 'opacity-50 cursor-not-allowed': contractWarning }">
|
||||||
|
🐾 Schedule It!
|
||||||
|
</button>
|
||||||
|
<a href="{{ route('schedule.index') }}"
|
||||||
|
class="flex-1 py-3 text-center rounded-full border border-pink-200 text-gray-600 hover:bg-pink-50 font-semibold text-sm">
|
||||||
|
Cancel
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script>
|
||||||
|
document.getElementById('create-event-form').addEventListener('submit', function (e) {
|
||||||
|
const startDate = document.getElementById('start_date').value;
|
||||||
|
const startTime = document.getElementById('start_time_input').value || '00:00';
|
||||||
|
const endDate = document.getElementById('end_date').value;
|
||||||
|
const endTime = document.getElementById('end_time_input').value || '00:00';
|
||||||
|
|
||||||
|
if (!startDate) {
|
||||||
|
e.preventDefault();
|
||||||
|
alert('Please select a start date.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('start_time_hidden').value = startDate + 'T' + startTime;
|
||||||
|
if (endDate) {
|
||||||
|
document.getElementById('end_time_hidden').value = endDate + 'T' + endTime;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
@endsection
|
||||||
219
resources/views/schedule/edit.blade.php
Normal file
219
resources/views/schedule/edit.blade.php
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'Edit Event')
|
||||||
|
@section('page-title', 'Edit Event 📅')
|
||||||
|
@section('page-subtitle', $event->title)
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="max-w-2xl mx-auto">
|
||||||
|
<div class="cat-card p-4 lg:p-8">
|
||||||
|
<form action="{{ route('schedule.update', $event) }}" method="POST" id="edit-event-form"
|
||||||
|
class="space-y-5">
|
||||||
|
@csrf @method('PUT')
|
||||||
|
|
||||||
|
{{-- Hidden combined datetime fields --}}
|
||||||
|
<input type="hidden" name="start_time" id="start_time_hidden">
|
||||||
|
<input type="hidden" name="end_time" id="end_time_hidden">
|
||||||
|
|
||||||
|
{{-- Title --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">
|
||||||
|
Title <span class="text-pink-400">*</span>
|
||||||
|
</label>
|
||||||
|
<input type="text" name="title" value="{{ old('title', $event->title) }}"
|
||||||
|
class="input-soft" placeholder="Event title" required>
|
||||||
|
@error('title') <p class="text-xs text-red-500 mt-1">{{ $message }}</p> @enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
|
{{-- Type --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Type</label>
|
||||||
|
<select name="event_type" class="input-soft">
|
||||||
|
@foreach(['task' => '📋 Task', 'meeting' => '🤝 Meeting', 'deadline' => '⏰ Deadline', 'posting' => '📸 Posting'] as $val => $label)
|
||||||
|
<option value="{{ $val }}" {{ old('event_type', $event->event_type) === $val ? 'selected' : '' }}>
|
||||||
|
{{ $label }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Status --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Status</label>
|
||||||
|
<select name="status" class="input-soft">
|
||||||
|
@foreach($statuses as $s)
|
||||||
|
<option value="{{ $s->value }}"
|
||||||
|
{{ old('status', $event->status->value) === $s->value ? 'selected' : '' }}>
|
||||||
|
{{ $s->label() }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Client --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Client</label>
|
||||||
|
<select name="client_id" class="input-soft">
|
||||||
|
<option value="">— None —</option>
|
||||||
|
@foreach($clients as $client)
|
||||||
|
<option value="{{ $client->id }}"
|
||||||
|
{{ old('client_id', $event->client_id) == $client->id ? 'selected' : '' }}>
|
||||||
|
{{ $client->name }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Category --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Category</label>
|
||||||
|
<select name="category_id" class="input-soft">
|
||||||
|
<option value="">— None —</option>
|
||||||
|
@foreach($categoryTree as $parent)
|
||||||
|
<option value="{{ $parent->id }}"
|
||||||
|
{{ old('category_id', $event->category_id) == $parent->id ? 'selected' : '' }}>
|
||||||
|
{{ $parent->icon }} {{ $parent->name }}
|
||||||
|
</option>
|
||||||
|
@foreach($parent->children as $child)
|
||||||
|
<option value="{{ $child->id }}"
|
||||||
|
{{ old('category_id', $event->category_id) == $child->id ? 'selected' : '' }}>
|
||||||
|
↳ {{ $child->name }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Start Date --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">
|
||||||
|
Start Date <span class="text-pink-400">*</span>
|
||||||
|
</label>
|
||||||
|
<input type="date" id="start_date" class="input-soft"
|
||||||
|
value="{{ old('_start_date', $event->start_time->format('Y-m-d')) }}" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Start Time --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Start Time</label>
|
||||||
|
<input type="time" id="start_time_input" class="input-soft"
|
||||||
|
value="{{ old('_start_time', $event->is_all_day ? '00:00' : $event->start_time->format('H:i')) }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- End Date --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">End Date</label>
|
||||||
|
<input type="date" id="end_date" class="input-soft"
|
||||||
|
value="{{ old('_end_date', $event->end_time?->format('Y-m-d') ?? '') }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- End Time --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">End Time</label>
|
||||||
|
<input type="time" id="end_time_input" class="input-soft"
|
||||||
|
value="{{ old('_end_time', $event->end_time?->format('H:i') ?? '18:00') }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Location --}}
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Location</label>
|
||||||
|
<input type="text" name="location" value="{{ old('location', $event->location) }}"
|
||||||
|
class="input-soft" placeholder="Online / venue address">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Description --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Description</label>
|
||||||
|
<textarea name="description" rows="2" class="input-soft resize-none"
|
||||||
|
placeholder="Brief description…">{{ old('description', $event->description) }}</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Color --}}
|
||||||
|
<div x-data="{ color: '{{ old('color', $event->color ?? '#FFB7C5') }}' }">
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-2">Color</label>
|
||||||
|
<input type="hidden" name="color" :value="color">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<input type="color" x-model="color"
|
||||||
|
class="w-10 h-10 rounded-xl cursor-pointer border-2 border-pink-100 p-0.5 shrink-0">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Priority checkbox --}}
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<input type="checkbox" name="is_priority" value="1" id="priority" class="w-4 h-4 accent-pink-400"
|
||||||
|
{{ old('is_priority', $event->is_priority) ? 'checked' : '' }}>
|
||||||
|
<label for="priority" class="text-sm text-gray-600 cursor-pointer">⭐ Mark as Priority</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Notes --}}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-semibold text-gray-700 mb-1">Notes</label>
|
||||||
|
<textarea name="notes" rows="3" class="input-soft resize-none"
|
||||||
|
placeholder="Additional notes…">{{ old('notes', $event->notes) }}</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Active Contract checkbox --}}
|
||||||
|
<div x-data="{ createContract: false }">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<input type="checkbox" name="create_brand_contract" value="1" id="edit_create_contract"
|
||||||
|
class="w-4 h-4 accent-pink-400" x-model="createContract">
|
||||||
|
<label for="edit_create_contract" class="text-sm text-gray-600 cursor-pointer">
|
||||||
|
📄 Also create a Brand Contract for this event
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div x-show="createContract" x-transition class="mt-3 grid grid-cols-1 sm:grid-cols-2 gap-3 bg-pink-50 rounded-2xl p-4">
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Contract Title</label>
|
||||||
|
<input type="text" name="contract_title" class="input-soft text-sm"
|
||||||
|
placeholder="e.g. Exclusive Posting Contract — BrandX"
|
||||||
|
value="{{ old('contract_title', $event->title) }}">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Contract Start</label>
|
||||||
|
<input type="date" name="contract_start_date" class="input-soft text-sm"
|
||||||
|
value="{{ old('contract_start_date', $event->start_time->format('Y-m-d')) }}">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Contract End</label>
|
||||||
|
<input type="date" name="contract_end_date" class="input-soft text-sm"
|
||||||
|
value="{{ old('contract_end_date', $event->end_time?->format('Y-m-d') ?? '') }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-col sm:flex-row gap-3 pt-1">
|
||||||
|
<button type="submit" class="btn-sakura flex-1 py-3">💾 Save Changes</button>
|
||||||
|
<a href="{{ route('schedule.index') }}"
|
||||||
|
class="flex-1 py-3 text-center rounded-full border border-pink-200 text-gray-600 hover:bg-pink-50 font-semibold text-sm">
|
||||||
|
Cancel
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script>
|
||||||
|
document.getElementById('edit-event-form').addEventListener('submit', function (e) {
|
||||||
|
const startDate = document.getElementById('start_date').value;
|
||||||
|
const startTime = document.getElementById('start_time_input').value || '00:00';
|
||||||
|
const endDate = document.getElementById('end_date').value;
|
||||||
|
const endTime = document.getElementById('end_time_input').value || '00:00';
|
||||||
|
|
||||||
|
if (!startDate) {
|
||||||
|
e.preventDefault();
|
||||||
|
alert('Please select a start date.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('start_time_hidden').value = startDate + 'T' + startTime;
|
||||||
|
|
||||||
|
if (endDate) {
|
||||||
|
document.getElementById('end_time_hidden').value = endDate + 'T' + endTime;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
@endsection
|
||||||
@@ -6,89 +6,9 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
{{-- ── Add Event Form (always accessible, collapsible) ─────── --}}
|
{{-- ── Add Event Button ─────────────────────────────────────── --}}
|
||||||
<div class="cat-card p-4 mb-4" x-data="{ open: false }">
|
<div class="flex items-center justify-between mb-4">
|
||||||
<div class="flex items-center justify-between">
|
<a href="{{ route('schedule.create') }}" class="btn-sakura text-sm px-5 py-2">+ Add Event</a>
|
||||||
<h3 class="text-sm font-bold text-gray-700 flex items-center gap-2">➕ New Event</h3>
|
|
||||||
<button class="btn-sakura text-xs px-4 py-1.5" @click="open = !open"
|
|
||||||
x-text="open ? '✕ Close' : '+ Add Event'"></button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form x-show="open" x-transition action="{{ route('schedule.store') }}" method="POST"
|
|
||||||
class="mt-4 grid grid-cols-1 sm:grid-cols-2 gap-3"
|
|
||||||
id="new-event-form">
|
|
||||||
@csrf
|
|
||||||
{{-- Hidden combined datetime fields --}}
|
|
||||||
<input type="hidden" name="start_time" id="start_time_hidden">
|
|
||||||
<input type="hidden" name="end_time" id="end_time_hidden">
|
|
||||||
|
|
||||||
<div class="sm:col-span-2">
|
|
||||||
<label class="text-xs font-semibold text-gray-600">Title <span class="text-pink-400">*</span></label>
|
|
||||||
<input type="text" name="title" class="input-soft mt-1" placeholder="Event title" required>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-semibold text-gray-600">Type</label>
|
|
||||||
<select name="event_type" class="input-soft mt-1">
|
|
||||||
<option value="task">📋 Task</option>
|
|
||||||
<option value="meeting">🤝 Meeting</option>
|
|
||||||
<option value="deadline">⏰ Deadline</option>
|
|
||||||
<option value="posting">📸 Posting</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-semibold text-gray-600">Client</label>
|
|
||||||
<select name="client_id" class="input-soft mt-1">
|
|
||||||
<option value="">— None —</option>
|
|
||||||
@foreach($clients as $client)
|
|
||||||
<option value="{{ $client->id }}">{{ $client->name }}</option>
|
|
||||||
@endforeach
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{-- Start: date + time side by side --}}
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-semibold text-gray-600">Start Date <span class="text-pink-400">*</span></label>
|
|
||||||
<input type="date" id="start_date" class="input-soft mt-1" required>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-semibold text-gray-600">Start Time</label>
|
|
||||||
<input type="time" id="start_time_input" class="input-soft mt-1" value="09:00">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{-- End: date + time side by side --}}
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-semibold text-gray-600">End Date</label>
|
|
||||||
<input type="date" id="end_date" class="input-soft mt-1">
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-semibold text-gray-600">End Time</label>
|
|
||||||
<input type="time" id="end_time_input" class="input-soft mt-1" value="18:00">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-semibold text-gray-600">Color</label>
|
|
||||||
<div class="flex gap-2 mt-1 flex-wrap">
|
|
||||||
@foreach(['#FFB7C5','#B5EAD7','#FDFD96','#E8D5F5','#FFD5B8','#AEC6CF'] as $hex)
|
|
||||||
<label class="cursor-pointer">
|
|
||||||
<input type="radio" name="color" value="{{ $hex }}" class="sr-only peer" {{ $loop->first ? 'checked' : '' }}>
|
|
||||||
<span class="w-7 h-7 rounded-full block ring-2 ring-transparent peer-checked:ring-gray-500 peer-checked:ring-offset-1 transition-all"
|
|
||||||
style="background:{{ $hex }};"></span>
|
|
||||||
</label>
|
|
||||||
@endforeach
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-2 mt-1">
|
|
||||||
<input type="checkbox" name="is_priority" value="1" id="priority" class="w-4 h-4 accent-pink-400">
|
|
||||||
<label for="priority" class="text-xs text-gray-600 cursor-pointer">⭐ Priority</label>
|
|
||||||
</div>
|
|
||||||
<div class="sm:col-span-2">
|
|
||||||
<label class="text-xs font-semibold text-gray-600">Notes</label>
|
|
||||||
<textarea name="notes" rows="2" class="input-soft mt-1 resize-none text-sm"></textarea>
|
|
||||||
</div>
|
|
||||||
<div class="sm:col-span-2">
|
|
||||||
<button type="submit" class="btn-sakura w-full">🐾 Schedule It!</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- ── Upcoming Alert Strip ─────────────────────────────────── --}}
|
{{-- ── Upcoming Alert Strip ─────────────────────────────────── --}}
|
||||||
@@ -98,7 +18,8 @@
|
|||||||
@if($upcomingList->isNotEmpty())
|
@if($upcomingList->isNotEmpty())
|
||||||
<div class="flex gap-2 overflow-x-auto pb-2 mb-4 -mx-4 px-4 lg:mx-0 lg:px-0">
|
<div class="flex gap-2 overflow-x-auto pb-2 mb-4 -mx-4 px-4 lg:mx-0 lg:px-0">
|
||||||
@foreach($upcomingList->take(6) as $event)
|
@foreach($upcomingList->take(6) as $event)
|
||||||
<div class="shrink-0 flex items-center gap-2 bg-white rounded-2xl border border-pink-100 px-3 py-2 shadow-sm">
|
<div class="shrink-0 flex items-center gap-2 bg-white rounded-2xl border border-pink-100 px-3 py-2 shadow-sm cursor-pointer hover:border-pink-300 transition-colors"
|
||||||
|
onclick="openAlertEventModal({{ json_encode(['id' => $event->id, 'title' => $event->title, 'type' => $event->event_type, 'status' => $event->status->value, 'client' => $event->client?->name, 'start' => $event->start_time->toIso8601String(), 'end' => $event->end_time?->toIso8601String()]) }})">
|
||||||
<div class="w-1.5 h-8 rounded-full shrink-0" style="background:{{ $event->color }}"></div>
|
<div class="w-1.5 h-8 rounded-full shrink-0" style="background:{{ $event->color }}"></div>
|
||||||
<div>
|
<div>
|
||||||
<div class="text-xs font-semibold text-gray-700 whitespace-nowrap">{{ $event->title }}</div>
|
<div class="text-xs font-semibold text-gray-700 whitespace-nowrap">{{ $event->title }}</div>
|
||||||
@@ -209,8 +130,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
<div class="flex gap-2"><span class="text-gray-400 w-16 shrink-0">Start</span><span>${e.start?.toLocaleString()}</span></div>
|
<div class="flex gap-2"><span class="text-gray-400 w-16 shrink-0">Start</span><span>${e.start?.toLocaleString()}</span></div>
|
||||||
${e.end ? `<div class="flex gap-2"><span class="text-gray-400 w-16 shrink-0">End</span><span>${e.end.toLocaleString()}</span></div>` : ''}
|
${e.end ? `<div class="flex gap-2"><span class="text-gray-400 w-16 shrink-0">End</span><span>${e.end.toLocaleString()}</span></div>` : ''}
|
||||||
`;
|
`;
|
||||||
|
const editUrl = `/schedule/${e.id}/edit`;
|
||||||
document.getElementById('modal-actions').innerHTML = `
|
document.getElementById('modal-actions').innerHTML = `
|
||||||
<a href="/schedule/${e.id}/edit" class="btn-sakura text-sm flex-1 text-center py-2">Edit</a>
|
<a href="${editUrl}" class="btn-sakura text-sm flex-1 text-center py-2">Edit</a>
|
||||||
<form method="POST" action="/schedule/${e.id}" onsubmit="return confirm('Delete?')" class="flex-1">
|
<form method="POST" action="/schedule/${e.id}" onsubmit="return confirm('Delete?')" class="flex-1">
|
||||||
<input type="hidden" name="_method" value="DELETE">
|
<input type="hidden" name="_method" value="DELETE">
|
||||||
<input type="hidden" name="_token" value="${document.querySelector('meta[name=csrf-token]').content}">
|
<input type="hidden" name="_token" value="${document.querySelector('meta[name=csrf-token]').content}">
|
||||||
@@ -228,15 +150,67 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
if (e.target === this) this.classList.add('hidden');
|
if (e.target === this) this.classList.add('hidden');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Combine date + time inputs into hidden datetime fields before submit
|
// Note: datetime hidden fields are populated in contractCheck's submitIfClear()
|
||||||
document.getElementById('new-event-form').addEventListener('submit', function(e) {
|
// since @submit.prevent is used on the form (form.submit() bypasses native submit event)
|
||||||
|
});
|
||||||
|
|
||||||
|
function openAlertEventModal(e) {
|
||||||
|
document.getElementById('modal-title').textContent = e.title;
|
||||||
|
const startStr = e.start ? new Date(e.start).toLocaleString() : '—';
|
||||||
|
const endStr = e.end ? new Date(e.end).toLocaleString() : null;
|
||||||
|
document.getElementById('modal-body').innerHTML = `
|
||||||
|
<div class="flex gap-2"><span class="text-gray-400 w-16 shrink-0">Type</span><span>${e.type}</span></div>
|
||||||
|
<div class="flex gap-2"><span class="text-gray-400 w-16 shrink-0">Status</span><span>${e.status}</span></div>
|
||||||
|
${e.client ? `<div class="flex gap-2"><span class="text-gray-400 w-16 shrink-0">Client</span><span>${e.client}</span></div>` : ''}
|
||||||
|
<div class="flex gap-2"><span class="text-gray-400 w-16 shrink-0">Start</span><span>${startStr}</span></div>
|
||||||
|
${endStr ? `<div class="flex gap-2"><span class="text-gray-400 w-16 shrink-0">End</span><span>${endStr}</span></div>` : ''}
|
||||||
|
`;
|
||||||
|
document.getElementById('modal-actions').innerHTML = `
|
||||||
|
<a href="/schedule/${e.id}/edit" class="btn-sakura text-sm flex-1 text-center py-2">Edit</a>
|
||||||
|
<form method="POST" action="/schedule/${e.id}" onsubmit="return confirm('Delete?')" class="flex-1">
|
||||||
|
<input type="hidden" name="_method" value="DELETE">
|
||||||
|
<input type="hidden" name="_token" value="${document.querySelector('meta[name=csrf-token]').content}">
|
||||||
|
<button class="w-full py-2 rounded-full border border-red-200 text-red-400 text-sm hover:bg-red-50">Delete</button>
|
||||||
|
</form>
|
||||||
|
`;
|
||||||
|
document.getElementById('event-modal').classList.remove('hidden');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{{-- Share scripts disabled --}}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function contractCheck(checkUrl) {
|
||||||
|
return {
|
||||||
|
categoryId: '',
|
||||||
|
clientId: '',
|
||||||
|
contractWarning: false,
|
||||||
|
contractMessage: '',
|
||||||
|
async checkContract() {
|
||||||
|
if (!this.categoryId) { this.contractWarning = false; return; }
|
||||||
|
const params = new URLSearchParams({ category_id: this.categoryId, client_id: this.clientId || '' });
|
||||||
|
const res = await fetch(checkUrl + '?' + params);
|
||||||
|
const data = await res.json();
|
||||||
|
if (data) {
|
||||||
|
this.contractWarning = true;
|
||||||
|
this.contractMessage = `"${data.title}" — ${data.client_name} holds exclusive rights in the ${data.category} category until ${data.end_date} (${data.days_left} days left).`;
|
||||||
|
} else {
|
||||||
|
this.contractWarning = false;
|
||||||
|
this.contractMessage = '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
submitIfClear(form) {
|
||||||
|
if (this.contractWarning) {
|
||||||
|
if (!confirm('⚠️ An exclusive contract is active for this category.\n\nAre you sure you want to proceed?')) return;
|
||||||
|
}
|
||||||
|
// Combine date + time inputs into the hidden datetime fields
|
||||||
|
// (form.submit() bypasses native 'submit' event, so we do it here)
|
||||||
const startDate = document.getElementById('start_date').value;
|
const startDate = document.getElementById('start_date').value;
|
||||||
const startTime = document.getElementById('start_time_input').value || '00:00';
|
const startTime = document.getElementById('start_time_input').value || '00:00';
|
||||||
const endDate = document.getElementById('end_date').value;
|
const endDate = document.getElementById('end_date').value;
|
||||||
const endTime = document.getElementById('end_time_input').value || '00:00';
|
const endTime = document.getElementById('end_time_input').value || '00:00';
|
||||||
|
|
||||||
if (!startDate) {
|
if (!startDate) {
|
||||||
e.preventDefault();
|
|
||||||
alert('Please select a start date.');
|
alert('Please select a start date.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -245,8 +219,11 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
if (endDate) {
|
if (endDate) {
|
||||||
document.getElementById('end_time_hidden').value = endDate + 'T' + endTime;
|
document.getElementById('end_time_hidden').value = endDate + 'T' + endTime;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
form.submit();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
62
resources/views/search/index.blade.php
Normal file
62
resources/views/search/index.blade.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'Search')
|
||||||
|
@section('page-title', '🔍 Search Results')
|
||||||
|
@section('page-subtitle', $q ? "Results for \"" . e($q) . "\"" : 'Enter a search term')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<form method="GET" action="{{ route('search.index') }}" class="mb-6">
|
||||||
|
<div class="relative max-w-xl">
|
||||||
|
<span class="absolute left-4 top-1/2 -translate-y-1/2 text-gray-400">🔍</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="q"
|
||||||
|
value="{{ e($q) }}"
|
||||||
|
placeholder="Search clients, events, invoices, content…"
|
||||||
|
class="input-soft pl-11 py-3 text-base w-full"
|
||||||
|
autofocus
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@if(! $q)
|
||||||
|
<div class="text-center py-20 text-gray-400">
|
||||||
|
<span class="text-5xl block mb-3">🔍</span>
|
||||||
|
<p class="text-base font-medium">Start typing to search across everything</p>
|
||||||
|
<p class="text-sm mt-1">Clients, events, invoices, content briefs, rate cards</p>
|
||||||
|
</div>
|
||||||
|
@elseif(empty($results))
|
||||||
|
<div class="text-center py-20 text-gray-400">
|
||||||
|
<span class="text-5xl block mb-3">😿</span>
|
||||||
|
<p class="text-base font-medium">No results for "{{ e($q) }}"</p>
|
||||||
|
<p class="text-sm mt-1">Try a different keyword</p>
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<div class="space-y-6">
|
||||||
|
@foreach($results as $group)
|
||||||
|
<div class="cat-card overflow-hidden">
|
||||||
|
<div class="px-5 py-3 bg-pink-50/60 border-b border-pink-100">
|
||||||
|
<h2 class="text-sm font-bold text-gray-600">{{ $group['label'] }}</h2>
|
||||||
|
</div>
|
||||||
|
<div class="divide-y divide-pink-50">
|
||||||
|
@foreach($group['items'] as $item)
|
||||||
|
<a href="{{ $item['url'] }}"
|
||||||
|
class="flex items-center gap-4 px-5 py-3 hover:bg-pink-50/40 transition-colors">
|
||||||
|
<span class="text-2xl shrink-0">{{ $item['icon'] }}</span>
|
||||||
|
<div class="min-w-0">
|
||||||
|
<div class="font-semibold text-gray-800 text-sm truncate">{{ $item['title'] }}</div>
|
||||||
|
@if($item['subtitle'])
|
||||||
|
<div class="text-xs text-gray-400 truncate mt-0.5">{{ $item['subtitle'] }}</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<span class="ml-auto text-gray-300 text-sm shrink-0">→</span>
|
||||||
|
</a>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@endsection
|
||||||
283
resources/views/settings/notifications.blade.php
Normal file
283
resources/views/settings/notifications.blade.php
Normal file
@@ -0,0 +1,283 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'Notification Settings')
|
||||||
|
@section('page-title', '🔔 Notifications')
|
||||||
|
@section('page-subtitle', 'Configure Email, Telegram & WhatsApp alerts')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<div class="max-w-3xl mx-auto space-y-6">
|
||||||
|
|
||||||
|
{{-- ── How it works ─────────────────────────────────────── --}}
|
||||||
|
<div class="cat-card p-4 flex gap-3 items-start bg-blue-50/50 border-blue-100">
|
||||||
|
<span class="text-2xl shrink-0">💡</span>
|
||||||
|
<div class="text-sm text-gray-600 space-y-1">
|
||||||
|
<p class="font-semibold text-gray-700">How notifications work</p>
|
||||||
|
<p>Add one or more channels below. Notifications fire automatically every hour via the scheduler.</p>
|
||||||
|
<p class="text-xs text-gray-400">To enable the scheduler on your server: add <code class="bg-white px-1 rounded text-xs">* * * * * php /path/to/artisan schedule:run</code> to crontab.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- ── Existing channels ────────────────────────────────── --}}
|
||||||
|
@if($settings->isNotEmpty())
|
||||||
|
<div class="space-y-3">
|
||||||
|
@foreach($settings as $setting)
|
||||||
|
<div class="cat-card p-4" x-data="{ editing: false }">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<span class="text-2xl shrink-0">{{ $setting->channelIcon }}</span>
|
||||||
|
<div class="flex-1 min-w-0">
|
||||||
|
<div class="flex items-center gap-2 flex-wrap">
|
||||||
|
<span class="font-semibold text-gray-800 text-sm">{{ $setting->name }}</span>
|
||||||
|
<span class="badge badge-ghost text-xs">{{ $setting->channelLabel }}</span>
|
||||||
|
@if(! $setting->is_enabled)
|
||||||
|
<span class="badge badge-error text-xs">Disabled</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<div class="text-xs text-gray-400 mt-0.5 flex flex-wrap gap-2">
|
||||||
|
@foreach($setting->triggers ?? [] as $trigger)
|
||||||
|
<span>{{ \App\Models\NotificationSetting::$triggerMeta[$trigger]['icon'] ?? '🔔' }}
|
||||||
|
{{ \App\Models\NotificationSetting::$triggerMeta[$trigger]['label'] ?? $trigger }}</span>
|
||||||
|
@endforeach
|
||||||
|
<span>⏰ {{ $setting->notify_before_hours }}h before</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-1 shrink-0 flex-wrap justify-end">
|
||||||
|
{{-- Test --}}
|
||||||
|
<form action="{{ route('settings.notifications.test', $setting) }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
<button type="submit" class="text-xs px-3 py-1.5 rounded-full border border-blue-200 text-blue-500 hover:bg-blue-50">
|
||||||
|
Test
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
{{-- Toggle --}}
|
||||||
|
<form action="{{ route('settings.notifications.toggle', $setting) }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
<button type="submit"
|
||||||
|
class="text-xs px-3 py-1.5 rounded-full border {{ $setting->is_enabled ? 'border-amber-200 text-amber-500 hover:bg-amber-50' : 'border-green-200 text-green-500 hover:bg-green-50' }}">
|
||||||
|
{{ $setting->is_enabled ? 'Disable' : 'Enable' }}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
{{-- Edit --}}
|
||||||
|
<button @click="editing = !editing"
|
||||||
|
class="text-xs px-3 py-1.5 rounded-full border border-pink-200 text-pink-500 hover:bg-pink-50">
|
||||||
|
Edit
|
||||||
|
</button>
|
||||||
|
{{-- Delete --}}
|
||||||
|
<form action="{{ route('settings.notifications.destroy', $setting) }}" method="POST"
|
||||||
|
onsubmit="return confirm('Remove this channel?')">
|
||||||
|
@csrf @method('DELETE')
|
||||||
|
<button type="submit"
|
||||||
|
class="text-xs px-3 py-1.5 rounded-full border border-red-100 text-red-400 hover:bg-red-50">
|
||||||
|
Del
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Inline edit form --}}
|
||||||
|
<div x-show="editing" x-transition class="mt-4 pt-4 border-t border-pink-50">
|
||||||
|
<form action="{{ route('settings.notifications.update', $setting) }}" method="POST"
|
||||||
|
class="space-y-3">
|
||||||
|
@csrf @method('PUT')
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">Name</label>
|
||||||
|
<input type="text" name="name" value="{{ $setting->name }}"
|
||||||
|
class="input-soft text-sm" required>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">Notify before (hours)</label>
|
||||||
|
<input type="number" name="notify_before_hours"
|
||||||
|
value="{{ $setting->notify_before_hours }}"
|
||||||
|
min="1" max="720" class="input-soft text-sm">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Triggers --}}
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-2">Triggers</label>
|
||||||
|
<div class="flex flex-wrap gap-3">
|
||||||
|
@foreach(\App\Models\NotificationSetting::$triggerMeta as $key => $meta)
|
||||||
|
<label class="flex items-center gap-1.5 cursor-pointer text-sm">
|
||||||
|
<input type="checkbox" name="triggers[]" value="{{ $key }}"
|
||||||
|
class="accent-pink-400"
|
||||||
|
{{ in_array($key, $setting->triggers ?? []) ? 'checked' : '' }}>
|
||||||
|
{{ $meta['icon'] }} {{ $meta['label'] }}
|
||||||
|
</label>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Channel-specific config --}}
|
||||||
|
@if($setting->channel === 'email')
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">To Email</label>
|
||||||
|
<input type="email" name="config[to_email]"
|
||||||
|
value="{{ $setting->config['to_email'] ?? '' }}"
|
||||||
|
class="input-soft text-sm" placeholder="you@example.com">
|
||||||
|
</div>
|
||||||
|
@elseif($setting->channel === 'telegram')
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">Bot Token</label>
|
||||||
|
<input type="text" name="config[bot_token]"
|
||||||
|
value="{{ $setting->config['bot_token'] ?? '' }}"
|
||||||
|
class="input-soft text-sm" placeholder="123456:ABC-DEF...">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">Chat ID</label>
|
||||||
|
<input type="text" name="config[chat_id]"
|
||||||
|
value="{{ $setting->config['chat_id'] ?? '' }}"
|
||||||
|
class="input-soft text-sm" placeholder="-100123456789">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@elseif($setting->channel === 'whatsapp')
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">WAHA Endpoint</label>
|
||||||
|
<input type="url" name="config[waha_endpoint]"
|
||||||
|
value="{{ $setting->config['waha_endpoint'] ?? '' }}"
|
||||||
|
class="input-soft text-sm" placeholder="http://localhost:3000/api/sendText">
|
||||||
|
<p class="text-xs text-gray-400 mt-1">Full URL to the sendText endpoint</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">Session Name</label>
|
||||||
|
<input type="text" name="config[waha_session]"
|
||||||
|
value="{{ $setting->config['waha_session'] ?? 'default' }}"
|
||||||
|
class="input-soft text-sm" placeholder="default">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">API Key
|
||||||
|
<span class="font-normal text-gray-400">(if required)</span>
|
||||||
|
</label>
|
||||||
|
<input type="text" name="config[api_key]"
|
||||||
|
value="{{ $setting->config['api_key'] ?? '' }}"
|
||||||
|
class="input-soft text-sm" placeholder="your-waha-api-key">
|
||||||
|
<p class="text-xs text-gray-400 mt-1">Sent as <code>X-Api-Key</code> header. Leave blank if WAHA has no auth.</p>
|
||||||
|
</div>
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">Chat ID</label>
|
||||||
|
<input type="text" name="config[chat_id]"
|
||||||
|
value="{{ $setting->config['chat_id'] ?? '' }}"
|
||||||
|
class="input-soft text-sm" placeholder="628123456789@c.us or 120363xxx@g.us">
|
||||||
|
<p class="text-xs text-gray-400 mt-1">Individual: <code>628xxx@c.us</code> · Group: <code>120363xxx@g.us</code></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<button type="submit" class="btn-sakura text-sm px-6 py-2">💾 Save</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<div class="cat-card p-8 text-center text-gray-400">
|
||||||
|
<span class="text-4xl block mb-2">🔕</span>
|
||||||
|
<p class="text-sm font-medium">No notification channels yet</p>
|
||||||
|
<p class="text-xs mt-1">Add one below to get started</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
{{-- ── Add new channel ─────────────────────────────────── --}}
|
||||||
|
<div class="cat-card p-5" x-data="{ channel: 'email' }">
|
||||||
|
<h2 class="font-bold text-gray-700 mb-4 flex items-center gap-2">
|
||||||
|
<span>➕</span> Add Notification Channel
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<form action="{{ route('settings.notifications.store') }}" method="POST" class="space-y-4">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">Name <span class="text-pink-400">*</span></label>
|
||||||
|
<input type="text" name="name" class="input-soft text-sm"
|
||||||
|
placeholder="My Telegram Bot" required>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">Channel <span class="text-pink-400">*</span></label>
|
||||||
|
<select name="channel" class="input-soft text-sm" x-model="channel">
|
||||||
|
<option value="email">✉️ Email</option>
|
||||||
|
<option value="telegram">✈️ Telegram</option>
|
||||||
|
<option value="whatsapp">💬 WhatsApp (WAHA)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">Notify before (hours)</label>
|
||||||
|
<input type="number" name="notify_before_hours" value="24"
|
||||||
|
min="1" max="720" class="input-soft text-sm">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Triggers --}}
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-2">Send when…</label>
|
||||||
|
<div class="flex flex-wrap gap-4">
|
||||||
|
@foreach(\App\Models\NotificationSetting::$triggerMeta as $key => $meta)
|
||||||
|
<label class="flex items-center gap-1.5 cursor-pointer text-sm">
|
||||||
|
<input type="checkbox" name="triggers[]" value="{{ $key }}"
|
||||||
|
class="accent-pink-400" checked>
|
||||||
|
{{ $meta['icon'] }} {{ $meta['label'] }}
|
||||||
|
</label>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Email --}}
|
||||||
|
<div x-show="channel === 'email'" x-transition>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">To Email <span class="text-pink-400">*</span></label>
|
||||||
|
<input type="email" name="config[to_email]" class="input-soft text-sm"
|
||||||
|
placeholder="you@example.com">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Telegram --}}
|
||||||
|
<div x-show="channel === 'telegram'" x-transition class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">Bot Token <span class="text-pink-400">*</span></label>
|
||||||
|
<input type="text" name="config[bot_token]" class="input-soft text-sm"
|
||||||
|
placeholder="123456:ABC-DEF...">
|
||||||
|
<p class="text-xs text-gray-400 mt-1">Get from <a href="https://t.me/BotFather" target="_blank" class="text-pink-500">@BotFather</a></p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">Chat ID <span class="text-pink-400">*</span></label>
|
||||||
|
<input type="text" name="config[chat_id]" class="input-soft text-sm"
|
||||||
|
placeholder="-100123456789 or @username">
|
||||||
|
<p class="text-xs text-gray-400 mt-1">Use <a href="https://t.me/userinfobot" target="_blank" class="text-pink-500">@userinfobot</a> to find your ID</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- WhatsApp / WAHA --}}
|
||||||
|
<div x-show="channel === 'whatsapp'" x-transition class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">WAHA Endpoint <span class="text-pink-400">*</span></label>
|
||||||
|
<input type="url" name="config[waha_endpoint]" class="input-soft text-sm"
|
||||||
|
placeholder="http://localhost:3000/api/sendText">
|
||||||
|
<p class="text-xs text-gray-400 mt-1">Full URL to the sendText endpoint of your WAHA instance</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">Session Name</label>
|
||||||
|
<input type="text" name="config[waha_session]" value="default" class="input-soft text-sm">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">API Key
|
||||||
|
<span class="font-normal text-gray-400">(if required)</span>
|
||||||
|
</label>
|
||||||
|
<input type="text" name="config[api_key]" class="input-soft text-sm"
|
||||||
|
placeholder="your-waha-api-key">
|
||||||
|
<p class="text-xs text-gray-400 mt-1">Sent as <code class="bg-gray-100 px-1 rounded">X-Api-Key</code> header. Leave blank if WAHA has no auth.</p>
|
||||||
|
</div>
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="text-xs font-semibold text-gray-600 block mb-1">Chat ID <span class="text-pink-400">*</span></label>
|
||||||
|
<input type="text" name="config[chat_id]" class="input-soft text-sm"
|
||||||
|
placeholder="628123456789@c.us or 120363xxx@g.us">
|
||||||
|
<p class="text-xs text-gray-400 mt-1">Individual: <code class="bg-gray-100 px-1 rounded">628xxx@c.us</code> · Group: <code class="bg-gray-100 px-1 rounded">120363xxx@g.us</code></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn-sakura">🔔 Add Channel</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
@@ -1,8 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Services\NotificationDispatcher;
|
||||||
use Illuminate\Foundation\Inspiring;
|
use Illuminate\Foundation\Inspiring;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
use Illuminate\Support\Facades\Schedule;
|
||||||
|
|
||||||
Artisan::command('inspire', function () {
|
Artisan::command('inspire', function () {
|
||||||
$this->comment(Inspiring::quote());
|
$this->comment(Inspiring::quote());
|
||||||
})->purpose('Display an inspiring quote');
|
})->purpose('Display an inspiring quote');
|
||||||
|
|
||||||
|
Artisan::command('notifications:dispatch', function () {
|
||||||
|
/** @var NotificationDispatcher $dispatcher */
|
||||||
|
$dispatcher = app(NotificationDispatcher::class);
|
||||||
|
$dispatcher->dispatchAll();
|
||||||
|
$this->info('🔔 Notifications dispatched.');
|
||||||
|
})->purpose('Send all pending KOL Manager notifications');
|
||||||
|
|
||||||
|
// Run every hour automatically
|
||||||
|
Schedule::command('notifications:dispatch')->hourly();
|
||||||
|
|||||||
@@ -2,25 +2,60 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use App\Http\Controllers\BrandContractController;
|
||||||
|
use App\Http\Controllers\GateController;
|
||||||
|
use App\Http\Controllers\NoteController;
|
||||||
|
use App\Http\Controllers\ClientCategoryController;
|
||||||
use App\Http\Controllers\ClientController;
|
use App\Http\Controllers\ClientController;
|
||||||
use App\Http\Controllers\ContentBriefController;
|
use App\Http\Controllers\ContentBriefController;
|
||||||
use App\Http\Controllers\DashboardController;
|
use App\Http\Controllers\DashboardController;
|
||||||
use App\Http\Controllers\EventController;
|
use App\Http\Controllers\EventController;
|
||||||
use App\Http\Controllers\InvoiceController;
|
use App\Http\Controllers\InvoiceController;
|
||||||
|
use App\Http\Controllers\InvoiceSettingsController;
|
||||||
use App\Http\Controllers\MediaFileController;
|
use App\Http\Controllers\MediaFileController;
|
||||||
|
use App\Http\Controllers\NotificationSettingController;
|
||||||
use App\Http\Controllers\RateCardController;
|
use App\Http\Controllers\RateCardController;
|
||||||
|
use App\Http\Controllers\SearchController;
|
||||||
use App\Http\Controllers\SocialHubController;
|
use App\Http\Controllers\SocialHubController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
// ── Gate Authentication ───────────────────────────────────────────────────────
|
||||||
|
Route::get('/login', [GateController::class, 'login'])->name('gate.login');
|
||||||
|
Route::post('/login', [GateController::class, 'attempt'])->name('gate.attempt');
|
||||||
|
Route::post('/logout', [GateController::class, 'logout'])->name('gate.logout');
|
||||||
|
|
||||||
Route::get('/', [DashboardController::class, 'index'])->name('dashboard');
|
Route::get('/', [DashboardController::class, 'index'])->name('dashboard');
|
||||||
|
|
||||||
// CRM – Clients
|
// CRM – Clients
|
||||||
Route::resource('clients', ClientController::class);
|
Route::resource('clients', ClientController::class);
|
||||||
|
Route::post('/clients/quick', [ClientController::class, 'quickStore'])->name('clients.quick-store');
|
||||||
|
Route::post('/clients/{client}/avatar', [ClientController::class, 'uploadAvatar'])->name('clients.upload-avatar');
|
||||||
|
Route::delete('/clients/{client}/avatar', [ClientController::class, 'deleteAvatar'])->name('clients.delete-avatar');
|
||||||
|
|
||||||
|
// Client Categories
|
||||||
|
Route::prefix('client-categories')->name('client-categories.')->group(function (): void {
|
||||||
|
Route::get('/', [ClientCategoryController::class, 'index'])->name('index');
|
||||||
|
Route::post('/', [ClientCategoryController::class, 'store'])->name('store');
|
||||||
|
Route::put('/{category}', [ClientCategoryController::class, 'update'])->name('update');
|
||||||
|
Route::delete('/{category}', [ClientCategoryController::class, 'destroy'])->name('destroy');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Brand Contracts
|
||||||
|
Route::prefix('contracts')->name('contracts.')->group(function (): void {
|
||||||
|
Route::get('/', [BrandContractController::class, 'index'])->name('index');
|
||||||
|
Route::post('/', [BrandContractController::class, 'store'])->name('store');
|
||||||
|
Route::put('/{contract}', [BrandContractController::class, 'update'])->name('update');
|
||||||
|
Route::delete('/{contract}', [BrandContractController::class, 'destroy'])->name('destroy');
|
||||||
|
Route::patch('/{contract}/toggle', [BrandContractController::class, 'toggle'])->name('toggle');
|
||||||
|
Route::get('/check', [BrandContractController::class, 'check'])->name('check');
|
||||||
|
});
|
||||||
|
|
||||||
// Schedule & Calendar
|
// Schedule & Calendar
|
||||||
Route::prefix('schedule')->name('schedule.')->group(function (): void {
|
Route::prefix('schedule')->name('schedule.')->group(function (): void {
|
||||||
Route::get('/', [EventController::class, 'index'])->name('index');
|
Route::get('/', [EventController::class, 'index'])->name('index');
|
||||||
|
Route::get('/create', [EventController::class, 'create'])->name('create');
|
||||||
Route::post('/', [EventController::class, 'store'])->name('store');
|
Route::post('/', [EventController::class, 'store'])->name('store');
|
||||||
|
Route::get('/{event}/edit', [EventController::class, 'edit'])->name('edit');
|
||||||
Route::put('/{event}', [EventController::class, 'update'])->name('update');
|
Route::put('/{event}', [EventController::class, 'update'])->name('update');
|
||||||
Route::patch('/{event}/dates', [EventController::class, 'updateDates'])->name('update-dates');
|
Route::patch('/{event}/dates', [EventController::class, 'updateDates'])->name('update-dates');
|
||||||
Route::delete('/{event}', [EventController::class, 'destroy'])->name('destroy');
|
Route::delete('/{event}', [EventController::class, 'destroy'])->name('destroy');
|
||||||
@@ -36,9 +71,17 @@ Route::prefix('social-hub')->name('social-hub.')->group(function (): void {
|
|||||||
// Financial – Invoices
|
// Financial – Invoices
|
||||||
Route::resource('invoices', InvoiceController::class);
|
Route::resource('invoices', InvoiceController::class);
|
||||||
Route::get('/invoices/{invoice}/pdf', [InvoiceController::class, 'pdf'])->name('invoices.pdf');
|
Route::get('/invoices/{invoice}/pdf', [InvoiceController::class, 'pdf'])->name('invoices.pdf');
|
||||||
|
Route::get('/invoice-settings', [InvoiceSettingsController::class, 'edit'])->name('invoice-settings.edit');
|
||||||
|
Route::post('/invoice-settings', [InvoiceSettingsController::class, 'update'])->name('invoice-settings.update');
|
||||||
|
Route::post('/invoice-settings/logo', [InvoiceSettingsController::class, 'uploadLogo'])->name('invoice-settings.upload-logo');
|
||||||
|
Route::delete('/invoice-settings/logo', [InvoiceSettingsController::class, 'deleteLogo'])->name('invoice-settings.delete-logo');
|
||||||
|
|
||||||
// Financial – Rate Cards
|
// Financial – Rate Cards
|
||||||
Route::get('/rate-cards/public', [RateCardController::class, 'public'])->name('rate-cards.public');
|
Route::get('/rate-cards/public', [RateCardController::class, 'public'])->name('rate-cards.public');
|
||||||
|
Route::get('/rate-cards/pdf', [RateCardController::class, 'pdf'])->name('rate-cards.pdf');
|
||||||
|
Route::get('/rate-cards/profile', [RateCardController::class, 'profilePage'])->name('rate-cards.profile');
|
||||||
|
Route::post('/rate-cards/profile', [RateCardController::class, 'profileUpdate'])->name('rate-cards.profile.update');
|
||||||
|
Route::get('/files/profile-logo', [RateCardController::class, 'serveProfileLogo'])->name('files.serve-profile-logo');
|
||||||
Route::resource('rate-cards', RateCardController::class)->except(['show']);
|
Route::resource('rate-cards', RateCardController::class)->except(['show']);
|
||||||
|
|
||||||
// Content Strategy – Kanban
|
// Content Strategy – Kanban
|
||||||
@@ -60,3 +103,28 @@ Route::prefix('files')->name('files.')->group(function (): void {
|
|||||||
Route::get('/{mediaFile}/serve', [MediaFileController::class, 'serve'])->name('serve');
|
Route::get('/{mediaFile}/serve', [MediaFileController::class, 'serve'])->name('serve');
|
||||||
Route::delete('/{mediaFile}', [MediaFileController::class, 'destroy'])->name('destroy');
|
Route::delete('/{mediaFile}', [MediaFileController::class, 'destroy'])->name('destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Global Search
|
||||||
|
Route::prefix('search')->name('search.')->group(function (): void {
|
||||||
|
Route::get('/', [SearchController::class, 'index'])->name('index');
|
||||||
|
Route::get('/quick', [SearchController::class, 'quick'])->name('quick');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Notes
|
||||||
|
Route::prefix('notes')->name('notes.')->group(function (): void {
|
||||||
|
Route::get('/', [NoteController::class, 'index'])->name('index');
|
||||||
|
Route::post('/', [NoteController::class, 'store'])->name('store');
|
||||||
|
Route::put('/{note}', [NoteController::class, 'update'])->name('update');
|
||||||
|
Route::delete('/{note}', [NoteController::class, 'destroy'])->name('destroy');
|
||||||
|
Route::patch('/{note}/pin', [NoteController::class, 'togglePin'])->name('toggle-pin');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Settings
|
||||||
|
Route::prefix('settings')->name('settings.')->group(function (): void {
|
||||||
|
Route::get('/notifications', [NotificationSettingController::class, 'index'])->name('notifications');
|
||||||
|
Route::post('/notifications', [NotificationSettingController::class, 'store'])->name('notifications.store');
|
||||||
|
Route::put('/notifications/{setting}', [NotificationSettingController::class, 'update'])->name('notifications.update');
|
||||||
|
Route::delete('/notifications/{setting}', [NotificationSettingController::class, 'destroy'])->name('notifications.destroy');
|
||||||
|
Route::post('/notifications/{setting}/test', [NotificationSettingController::class, 'test'])->name('notifications.test');
|
||||||
|
Route::post('/notifications/{setting}/toggle', [NotificationSettingController::class, 'toggle'])->name('notifications.toggle');
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user