mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
Rename controller namespaces: drop V1 prefix, clarify roles
V1/Admin -> Company (company-scoped controllers) V1/SuperAdmin -> Admin (platform-wide admin controllers) V1/Customer -> CustomerPortal (customer-facing portal) V1/Installation -> Setup (installation wizard) V1/PDF -> Pdf (consistent casing) V1/Modules -> Modules (drop V1 prefix) V1/Webhook -> Webhook (drop V1 prefix) The V1 prefix served no purpose - API versioning is in the route prefix (/api/v1/), not the controller namespace. "Admin" was misleading for company-scoped controllers. "SuperAdmin" is now simply "Admin" for platform administration.
This commit is contained in:
108
app/Http/Controllers/Company/General/NotesController.php
Normal file
108
app/Http/Controllers/Company/General/NotesController.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Company\General;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\NotesRequest;
|
||||
use App\Http\Resources\NoteResource;
|
||||
use App\Models\Note;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class NotesController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->authorize('view notes');
|
||||
|
||||
$limit = $request->limit ?? 10;
|
||||
|
||||
$notes = Note::latest()
|
||||
->whereCompany()
|
||||
->applyFilters($request->all())
|
||||
->paginate($limit);
|
||||
|
||||
return NoteResource::collection($notes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function store(NotesRequest $request)
|
||||
{
|
||||
$this->authorize('manage notes');
|
||||
|
||||
$note = Note::create($request->getNotesPayload());
|
||||
|
||||
if ($note->is_default) {
|
||||
Note::where('id', '!=', $note->id)
|
||||
->where('type', $note->type)
|
||||
->where('is_default', true)
|
||||
->update([
|
||||
'is_default' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
return new NoteResource($note);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function show(Note $note)
|
||||
{
|
||||
$this->authorize('view notes');
|
||||
|
||||
return new NoteResource($note);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function update(NotesRequest $request, Note $note)
|
||||
{
|
||||
$this->authorize('manage notes');
|
||||
|
||||
$note->update($request->getNotesPayload());
|
||||
|
||||
if ($note->is_default) {
|
||||
Note::where('id', '!=', $note->id)
|
||||
->where('type', $note->type)
|
||||
->where('is_default', true)
|
||||
->update([
|
||||
'is_default' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
return new NoteResource($note);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy(Note $note)
|
||||
{
|
||||
$this->authorize('manage notes');
|
||||
|
||||
$note->delete();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user