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:
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user