53 lines
1.8 KiB
PHP
53 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\Admin\Customer\Concerns;
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
trait ManagesCustomerNotes
|
|
{
|
|
public function getCustomerNotes(string $uuid): JsonResponse
|
|
{
|
|
return response()->json(['error' => false, 'data' => $this->noteService->getCustomerNotes($uuid)]);
|
|
}
|
|
|
|
public function storeCustomerNote(string $uuid, Request $request): JsonResponse
|
|
{
|
|
$data = $request->validate(['note' => 'required|string']);
|
|
|
|
$note = $this->noteService->storeCustomerNote($uuid, $data['note'], Auth::id());
|
|
|
|
return response()->json(['error' => false, 'message' => 'Đã thêm ghi chú', 'data' => $note]);
|
|
}
|
|
|
|
public function destroyCustomerNote(string $uuid, int $noteId): JsonResponse
|
|
{
|
|
$this->noteService->destroyNote($uuid, $noteId);
|
|
|
|
return response()->json(['error' => false, 'message' => 'Đã xoá ghi chú']);
|
|
}
|
|
|
|
public function getServiceNotes(string $uuid, int $serviceId): JsonResponse
|
|
{
|
|
return response()->json(['error' => false, 'data' => $this->noteService->getServiceNotes($uuid, $serviceId)]);
|
|
}
|
|
|
|
public function storeServiceNote(string $uuid, int $serviceId, Request $request): JsonResponse
|
|
{
|
|
$data = $request->validate(['note' => 'required|string']);
|
|
|
|
$note = $this->noteService->storeServiceNote($uuid, $serviceId, $data['note'], Auth::id());
|
|
|
|
return response()->json(['error' => false, 'message' => 'Đã thêm ghi chú', 'data' => $note]);
|
|
}
|
|
|
|
public function destroyServiceNote(string $uuid, int $serviceId, int $noteId): JsonResponse
|
|
{
|
|
$this->noteService->destroyNote($uuid, $noteId);
|
|
|
|
return response()->json(['error' => false, 'message' => 'Đã xoá ghi chú']);
|
|
}
|
|
}
|