feat: add notes management feature with CRUD operations

- Created Note model and controller for handling notes.
- Added routes for notes CRUD operations.
- Implemented notes index view with search and pinning functionality.
- Created migration for notes table with necessary fields.
- Developed event creation form with client and contract options.
This commit is contained in:
I-Fun
2026-04-02 23:24:38 +07:00
parent 5748b163b6
commit 1b90f730a6
25 changed files with 1524 additions and 390 deletions

View File

@@ -7,8 +7,10 @@ namespace App\Http\Controllers;
use App\Enums\ClientStatus;
use App\Models\Client;
use App\Models\ClientCategory;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\View\View;
class ClientController extends Controller
@@ -146,4 +148,42 @@ class ClientController extends Controller
return redirect()->route('clients.index')
->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]);
}
}