diff --git a/app/Http/Controllers/AttachmentController.php b/app/Http/Controllers/AttachmentController.php
index d1feea1..cbefd57 100644
--- a/app/Http/Controllers/AttachmentController.php
+++ b/app/Http/Controllers/AttachmentController.php
@@ -2,49 +2,96 @@
namespace App\Http\Controllers;
+use App\Models\Attachment;
+use App\Http\Controllers\Controller;
use App\Http\Requests\StoreAttachmentRequest;
use App\Http\Requests\UpdateAttachmentRequest;
-use App\Http\Resources\AttachmentResource;
-use App\Models\Attachment;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
-use Illuminate\Support\Str;
+use Inertia\Inertia;
+
class AttachmentController extends Controller
{
-
- public static function routeName()
- {
+ public static function routeName(){
return Str::snake("Attachment");
}
- public function __construct(Request $request)
+ public function __construct(Request $request)
{
parent::__construct($request);
}
+
+ /**
+ * Display a listing of the resource.
+ */
public function index(Request $request)
{
- return AttachmentResource::collection(Attachment::search($request)->sort($request)->paginate((request('per_page') ?? request('itemsPerPage')) ?? 15));
+
+ return Inertia::render(Str::studly("Attachment").'/Index', [
+ "headers" => Attachment::headers(),
+ "items" => Attachment::search($request)->sort($request)->paginate($this->pagination),
+
+ ]);
}
- public function store(StoreAttachmentRequest $request)
+
+ /**
+ * Show the form for creating a new resource.
+ */
+ public function create()
{
- $attachment = Attachment::create($request->validated());
+ return Inertia::render(Str::studly("Attachment").'/Create', [
+ // 'options' => $regions
+ ]);
+ }
- return new AttachmentResource($attachment);
+ /**
+ * Store a newly created resource in storage.
+ */
+ public function store(StoreAttachmentRequest $request)
+ {
+ $data = $request->validated();
+ Attachment::create($data);
+
+ return to_route($this->routeName() . '.index')->with('res', ['message' => __('Attachment Saved Seccessfully'), 'type' => 'success']);
}
- public function show(Request $request, Attachment $attachment)
+
+ /**
+ * Display the specified resource.
+ */
+ // public function show(Attachment $attachment)
+ // {
+ //
+ // }
+
+ /**
+ * Show the form for editing the specified resource.
+ */
+ public function edit(Attachment $attachment)
{
- return new AttachmentResource($attachment);
+ return Inertia::render(Str::studly("Attachment").'/Update', [
+ //'options' => $regions,
+ 'attachment' => $attachment->toArray()
+ ]);
}
+
+ /**
+ * Update the specified resource in storage.
+ */
public function update(UpdateAttachmentRequest $request, Attachment $attachment)
{
- $attachment->update($request->validated());
-
- return new AttachmentResource($attachment);
+ $validated = $request->validated();
+
+ $attachment->update($validated);
+ return back()->with('res', ['message' => __('Attachment Updated Seccessfully'), 'type' => 'success']);
}
- public function destroy(Request $request, Attachment $attachment)
+
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(Attachment $attachment)
{
$attachment->delete();
-
- return new AttachmentResource($attachment);
+ return back()->with('res', ['message' => __('Attachment Deleted Seccessfully'), 'type' => 'success']);
}
}
diff --git a/app/Http/Controllers/BeneficiaryController.php b/app/Http/Controllers/BeneficiaryController.php
index a0b348f..91f3822 100644
--- a/app/Http/Controllers/BeneficiaryController.php
+++ b/app/Http/Controllers/BeneficiaryController.php
@@ -2,102 +2,96 @@
namespace App\Http\Controllers;
+use App\Models\Beneficiary;
+use App\Http\Controllers\Controller;
use App\Http\Requests\StoreBeneficiaryRequest;
use App\Http\Requests\UpdateBeneficiaryRequest;
-use App\Http\Resources\BeneficiaryResource;
-use App\Models\Beneficiary;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
-use Illuminate\Support\Str;
+use Inertia\Inertia;
+
class BeneficiaryController extends Controller
{
-
- public static function routeName()
- {
+ public static function routeName(){
return Str::snake("Beneficiary");
}
-
- public function __construct(Request $request)
+ public function __construct(Request $request)
{
parent::__construct($request);
}
+ /**
+ * Display a listing of the resource.
+ */
public function index(Request $request)
{
- return view("dashboard." . $this->routeName() . ".index", [
- 'headers' => $this->getModelInstance()::headers(),
- ]);
- }
+
+ return Inertia::render(Str::studly("Beneficiary").'/Index', [
+ "headers" => Beneficiary::headers(),
+ "items" => Beneficiary::search($request)->sort($request)->paginate($this->pagination),
- public function indexApi(Request $request)
- {
- return BeneficiaryResource::collection(Beneficiary::search($request)->sort($request)->paginate((request('per_page') ?? request('itemsPerPage')) ?? 15));
+ ]);
}
+ /**
+ * Show the form for creating a new resource.
+ */
public function create()
{
- return view("dashboard." . $this->routeName() . ".create", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $this->getModelInstance()
+ return Inertia::render(Str::studly("Beneficiary").'/Create', [
+ // 'options' => $regions
]);
}
+ /**
+ * Store a newly created resource in storage.
+ */
public function store(StoreBeneficiaryRequest $request)
{
- // if (!$this->user->is_permitted_to('store', Beneficiary::class, $request))
- // return response()->json(['message' => 'not_permitted'], 422);
-
- // $validator = Validator::make($request->all(), Beneficiary::createRules($this->user));
- // if ($validator->fails()) {
- // return response()->json(['errors' => $validator->errors()], 422);
- // }
- $beneficiary = Beneficiary::create($request->validated());
- // if ($request->translations) {
- // foreach ($request->translations as $translation)
- // $beneficiary->setTranslation($translation['field'], $translation['locale'], $translation['value'])->save();
- // }
- return new BeneficiaryResource($beneficiary);
+ $data = $request->validated();
+ Beneficiary::create($data);
+
+ return to_route($this->routeName() . '.index')->with('res', ['message' => __('Beneficiary Saved Seccessfully'), 'type' => 'success']);
}
- public function show(Request $request, Beneficiary $beneficiary)
- {
- return view("dashboard." . $this->routeName() . ".show", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $beneficiary
- ]);
- }
+ /**
+ * Display the specified resource.
+ */
+ // public function show(Beneficiary $beneficiary)
+ // {
+ //
+ // }
+ /**
+ * Show the form for editing the specified resource.
+ */
public function edit(Beneficiary $beneficiary)
{
- return view("dashboard." . $this->routeName() . ".edit", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $beneficiary
+ return Inertia::render(Str::studly("Beneficiary").'/Update', [
+ //'options' => $regions,
+ 'beneficiary' => $beneficiary->toArray()
]);
}
+ /**
+ * Update the specified resource in storage.
+ */
public function update(UpdateBeneficiaryRequest $request, Beneficiary $beneficiary)
{
- // if (!$this->user->is_permitted_to('update', Beneficiary::class, $request))
- // return response()->json(['message' => 'not_permitted'], 422);
- // $validator = Validator::make($request->all(), Beneficiary::updateRules($this->user));
- // if ($validator->fails()) {
- // return response()->json(['errors' => $validator->errors()], 422);
- // }
- $beneficiary->update($request->validated());
- // if ($request->translations) {
- // foreach ($request->translations as $translation)
- // $beneficiary->setTranslation($translation['field'], $translation['locale'], $translation['value'])->save();
- // }
- return new BeneficiaryResource($beneficiary);
+ $validated = $request->validated();
+
+ $beneficiary->update($validated);
+ return back()->with('res', ['message' => __('Beneficiary Updated Seccessfully'), 'type' => 'success']);
}
- public function destroy(Request $request, Beneficiary $beneficiary)
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(Beneficiary $beneficiary)
{
- if (!$this->user->is_permitted_to('delete', Beneficiary::class, $request))
- return response()->json(['message' => 'not_permitted'], 422);
$beneficiary->delete();
-
- return new BeneficiaryResource($beneficiary);
+ return back()->with('res', ['message' => __('Beneficiary Deleted Seccessfully'), 'type' => 'success']);
}
}
diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php
deleted file mode 100644
index d3976e0..0000000
--- a/app/Http/Controllers/DashboardController.php
+++ /dev/null
@@ -1,13 +0,0 @@
- Item::headers(),
+ "items" => Item::search($request)->sort($request)->paginate($this->pagination),
+
+ ]);
+ }
+
+ /**
+ * Show the form for creating a new resource.
+ */
+ public function create()
+ {
+ return Inertia::render(Str::studly("Item").'/Create', [
+ // 'options' => $regions
+ ]);
+ }
+
+ /**
+ * Store a newly created resource in storage.
+ */
+ public function store(StoreItemRequest $request)
+ {
+ $data = $request->validated();
+ Item::create($data);
+
+ return to_route($this->routeName() . '.index')->with('res', ['message' => __('Item Saved Seccessfully'), 'type' => 'success']);
+ }
+
+ /**
+ * Display the specified resource.
+ */
+ // public function show(Item $item)
+ // {
+ //
+ // }
+
+ /**
+ * Show the form for editing the specified resource.
+ */
+ public function edit(Item $item)
+ {
+ return Inertia::render(Str::studly("Item").'/Update', [
+ //'options' => $regions,
+ 'item' => $item->toArray()
+ ]);
+ }
+
+ /**
+ * Update the specified resource in storage.
+ */
+ public function update(UpdateItemRequest $request, Item $item)
+ {
+ $validated = $request->validated();
+
+ $item->update($validated);
+ return back()->with('res', ['message' => __('Item Updated Seccessfully'), 'type' => 'success']);
+ }
+
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(Item $item)
+ {
+ $item->delete();
+ return back()->with('res', ['message' => __('Item Deleted Seccessfully'), 'type' => 'success']);
+ }
+}
diff --git a/app/Http/Controllers/LogController.php b/app/Http/Controllers/LogController.php
index fc4915e..bcdf2c4 100644
--- a/app/Http/Controllers/LogController.php
+++ b/app/Http/Controllers/LogController.php
@@ -2,49 +2,96 @@
namespace App\Http\Controllers;
+use App\Models\Log;
+use App\Http\Controllers\Controller;
use App\Http\Requests\StoreLogRequest;
use App\Http\Requests\UpdateLogRequest;
-use App\Http\Resources\LogResource;
-use App\Models\Log;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
-use Illuminate\Support\Str;
+use Inertia\Inertia;
+
class LogController extends Controller
{
-
- public static function routeName()
- {
+ public static function routeName(){
return Str::snake("Log");
}
- public function __construct(Request $request)
+ public function __construct(Request $request)
{
parent::__construct($request);
}
+
+ /**
+ * Display a listing of the resource.
+ */
public function index(Request $request)
{
- return LogResource::collection(Log::search($request)->sort($request)->paginate((request('per_page') ?? request('itemsPerPage')) ?? 15));
+
+ return Inertia::render(Str::studly("Log").'/Index', [
+ "headers" => Log::headers(),
+ "items" => Log::search($request)->sort($request)->paginate($this->pagination),
+
+ ]);
}
- public function store(StoreLogRequest $request)
+
+ /**
+ * Show the form for creating a new resource.
+ */
+ public function create()
{
- $log = Log::create($request->validated());
+ return Inertia::render(Str::studly("Log").'/Create', [
+ // 'options' => $regions
+ ]);
+ }
- return new LogResource($log);
+ /**
+ * Store a newly created resource in storage.
+ */
+ public function store(StoreLogRequest $request)
+ {
+ $data = $request->validated();
+ Log::create($data);
+
+ return to_route($this->routeName() . '.index')->with('res', ['message' => __('Log Saved Seccessfully'), 'type' => 'success']);
}
- public function show(Request $request, Log $log)
+
+ /**
+ * Display the specified resource.
+ */
+ // public function show(Log $log)
+ // {
+ //
+ // }
+
+ /**
+ * Show the form for editing the specified resource.
+ */
+ public function edit(Log $log)
{
- return new LogResource($log);
+ return Inertia::render(Str::studly("Log").'/Update', [
+ //'options' => $regions,
+ 'log' => $log->toArray()
+ ]);
}
+
+ /**
+ * Update the specified resource in storage.
+ */
public function update(UpdateLogRequest $request, Log $log)
{
- $log->update($request->validated());
-
- return new LogResource($log);
+ $validated = $request->validated();
+
+ $log->update($validated);
+ return back()->with('res', ['message' => __('Log Updated Seccessfully'), 'type' => 'success']);
}
- public function destroy(Request $request, Log $log)
+
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(Log $log)
{
$log->delete();
-
- return new LogResource($log);
+ return back()->with('res', ['message' => __('Log Deleted Seccessfully'), 'type' => 'success']);
}
}
diff --git a/app/Http/Controllers/PermissionController.php b/app/Http/Controllers/PermissionController.php
index 1f41105..59dc8d5 100644
--- a/app/Http/Controllers/PermissionController.php
+++ b/app/Http/Controllers/PermissionController.php
@@ -1,69 +1,97 @@
sort($request)->paginate((request('per_page')??request('itemsPerPage'))??15));
+
+ return Inertia::render(Str::studly("Permission").'/Index', [
+ "headers" => Permission::headers(),
+ "items" => Permission::search($request)->sort($request)->paginate($this->pagination),
+
+ ]);
}
- public function store(Request $request)
+
+ /**
+ * Show the form for creating a new resource.
+ */
+ public function create()
{
- if(!$this->user->is_permitted_to('store',Permission::class,$request))
- return response()->json(['message'=>'not_permitted'],422);
+ return Inertia::render(Str::studly("Permission").'/Create', [
+ // 'options' => $regions
+ ]);
+ }
- $validator = Validator::make($request->all(),Permission::createRules($this->user));
- if($validator->fails()){
- return response()->json(['errors'=>$validator->errors()],422);
- }
- $permission = Permission::create($validator->validated());
- if ($request->translations) {
- foreach ($request->translations as $translation)
- $permission->setTranslation($translation['field'], $translation['locale'], $translation['value'])->save();
- }
- return new PermissionResource($permission);
+ /**
+ * Store a newly created resource in storage.
+ */
+ public function store(StorePermissionRequest $request)
+ {
+ $data = $request->validated();
+ Permission::create($data);
+
+ return to_route($this->routeName() . '.index')->with('res', ['message' => __('Permission Saved Seccessfully'), 'type' => 'success']);
}
- public function show(Request $request,Permission $permission)
+
+ /**
+ * Display the specified resource.
+ */
+ // public function show(Permission $permission)
+ // {
+ //
+ // }
+
+ /**
+ * Show the form for editing the specified resource.
+ */
+ public function edit(Permission $permission)
{
- if(!$this->user->is_permitted_to('view',Permission::class,$request))
- return response()->json(['message'=>'not_permitted'],422);
- return new PermissionResource($permission);
+ return Inertia::render(Str::studly("Permission").'/Update', [
+ //'options' => $regions,
+ 'permission' => $permission->toArray()
+ ]);
}
- public function update(Request $request, Permission $permission)
+
+ /**
+ * Update the specified resource in storage.
+ */
+ public function update(UpdatePermissionRequest $request, Permission $permission)
{
- if(!$this->user->is_permitted_to('update',Permission::class,$request))
- return response()->json(['message'=>'not_permitted'],422);
- $validator = Validator::make($request->all(),Permission::updateRules($this->user));
- if($validator->fails()){
- return response()->json(['errors'=>$validator->errors()],422);
- }
- $permission->update($validator->validated());
- if ($request->translations) {
- foreach ($request->translations as $translation)
- $permission->setTranslation($translation['field'], $translation['locale'], $translation['value'])->save();
- }
- return new PermissionResource($permission);
+ $validated = $request->validated();
+
+ $permission->update($validated);
+ return back()->with('res', ['message' => __('Permission Updated Seccessfully'), 'type' => 'success']);
}
- public function destroy(Request $request,Permission $permission)
+
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(Permission $permission)
{
- if(!$this->user->is_permitted_to('delete',Permission::class,$request))
- return response()->json(['message'=>'not_permitted'],422);
$permission->delete();
-
- return new PermissionResource($permission);
+ return back()->with('res', ['message' => __('Permission Deleted Seccessfully'), 'type' => 'success']);
}
}
diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php
index 873b4f7..75a4f5f 100644
--- a/app/Http/Controllers/ProfileController.php
+++ b/app/Http/Controllers/ProfileController.php
@@ -2,62 +2,96 @@
namespace App\Http\Controllers;
-use App\Http\Requests\ProfileUpdateRequest;
-use Illuminate\Contracts\Auth\MustVerifyEmail;
-use Illuminate\Http\RedirectResponse;
+use App\Models\ProposalBeneficiary;
+use App\Http\Controllers\Controller;
+use App\Http\Requests\StoreProposalBeneficiaryRequest;
+use App\Http\Requests\UpdateProposalBeneficiaryRequest;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Auth;
-use Illuminate\Support\Facades\Redirect;
+use Illuminate\Support\Facades\Validator;
use Inertia\Inertia;
-use Inertia\Response;
+
class ProfileController extends Controller
{
- /**
- * Display the user's profile form.
- */
- public function edit(Request $request): Response
+ public static function routeName(){
+ return Str::snake("ProposalBeneficiary");
+ }
+ public function __construct(Request $request)
{
- return Inertia::render('Profile/Edit', [
- 'mustVerifyEmail' => $request->user() instanceof MustVerifyEmail,
- 'status' => session('status'),
- ]);
+ parent::__construct($request);
}
/**
- * Update the user's profile information.
+ * Display a listing of the resource.
*/
- public function update(ProfileUpdateRequest $request): RedirectResponse
+ public function index(Request $request)
{
- $request->user()->fill($request->validated());
-
- if ($request->user()->isDirty('email')) {
- $request->user()->email_verified_at = null;
- }
-
- $request->user()->save();
+
+ return Inertia::render(Str::studly("ProposalBeneficiary").'/Index', [
+ "headers" => ProposalBeneficiary::headers(),
+ "items" => ProposalBeneficiary::search($request)->sort($request)->paginate($this->pagination),
- return Redirect::route('profile.edit');
+ ]);
}
/**
- * Delete the user's account.
+ * Show the form for creating a new resource.
*/
- public function destroy(Request $request): RedirectResponse
+ public function create()
{
- $request->validate([
- 'password' => ['required', 'current_password'],
+ return Inertia::render(Str::studly("ProposalBeneficiary").'/Create', [
+ // 'options' => $regions
]);
+ }
- $user = $request->user();
+ /**
+ * Store a newly created resource in storage.
+ */
+ public function store(StoreProposalBeneficiaryRequest $request)
+ {
+ $data = $request->validated();
+ ProposalBeneficiary::create($data);
+
+ return to_route($this->routeName() . '.index')->with('res', ['message' => __('ProposalBeneficiary Saved Seccessfully'), 'type' => 'success']);
+ }
- Auth::logout();
+ /**
+ * Display the specified resource.
+ */
+ // public function show(ProposalBeneficiary $proposalBeneficiary)
+ // {
+ //
+ // }
- $user->delete();
+ /**
+ * Show the form for editing the specified resource.
+ */
+ public function edit(ProposalBeneficiary $proposalBeneficiary)
+ {
+ return Inertia::render(Str::studly("ProposalBeneficiary").'/Update', [
+ //'options' => $regions,
+ 'proposalBeneficiary' => $proposalBeneficiary->toArray()
+ ]);
+ }
- $request->session()->invalidate();
- $request->session()->regenerateToken();
+ /**
+ * Update the specified resource in storage.
+ */
+ public function update(UpdateProposalBeneficiaryRequest $request, ProposalBeneficiary $proposalBeneficiary)
+ {
+ $validated = $request->validated();
+
+ $proposalBeneficiary->update($validated);
+ return back()->with('res', ['message' => __('ProposalBeneficiary Updated Seccessfully'), 'type' => 'success']);
+ }
- return Redirect::to('/');
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(ProposalBeneficiary $proposalBeneficiary)
+ {
+ $proposalBeneficiary->delete();
+ return back()->with('res', ['message' => __('ProposalBeneficiary Deleted Seccessfully'), 'type' => 'success']);
}
}
diff --git a/app/Http/Controllers/ProposalBeneficiaryController.php b/app/Http/Controllers/ProposalBeneficiaryController.php
index a5f491a..e92b506 100644
--- a/app/Http/Controllers/ProposalBeneficiaryController.php
+++ b/app/Http/Controllers/ProposalBeneficiaryController.php
@@ -2,49 +2,96 @@
namespace App\Http\Controllers;
+use App\Models\ProposalBeneficiary;
+use App\Http\Controllers\Controller;
use App\Http\Requests\StoreProposalBeneficiaryRequest;
use App\Http\Requests\UpdateProposalBeneficiaryRequest;
-use App\Http\Resources\ProposalBeneficiaryResource;
-use App\Models\ProposalBeneficiary;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
-use Illuminate\Support\Str;
+use Inertia\Inertia;
+
class ProposalBeneficiaryController extends Controller
{
-
- public static function routeName()
- {
+ public static function routeName(){
return Str::snake("ProposalBeneficiary");
}
- public function __construct(Request $request)
+ public function __construct(Request $request)
{
parent::__construct($request);
}
+
+ /**
+ * Display a listing of the resource.
+ */
public function index(Request $request)
{
- return ProposalBeneficiaryResource::collection(ProposalBeneficiary::search($request)->sort($request)->paginate((request('per_page') ?? request('itemsPerPage')) ?? 15));
+
+ return Inertia::render(Str::studly("ProposalBeneficiary").'/Index', [
+ "headers" => ProposalBeneficiary::headers(),
+ "items" => ProposalBeneficiary::search($request)->sort($request)->paginate($this->pagination),
+
+ ]);
}
- public function store(StoreProposalBeneficiaryRequest $request)
+
+ /**
+ * Show the form for creating a new resource.
+ */
+ public function create()
{
- $proposalBeneficiary = ProposalBeneficiary::create($request->validated());
+ return Inertia::render(Str::studly("ProposalBeneficiary").'/Create', [
+ // 'options' => $regions
+ ]);
+ }
- return new ProposalBeneficiaryResource($proposalBeneficiary);
+ /**
+ * Store a newly created resource in storage.
+ */
+ public function store(StoreProposalBeneficiaryRequest $request)
+ {
+ $data = $request->validated();
+ ProposalBeneficiary::create($data);
+
+ return to_route($this->routeName() . '.index')->with('res', ['message' => __('ProposalBeneficiary Saved Seccessfully'), 'type' => 'success']);
}
- public function show(Request $request, ProposalBeneficiary $proposalBeneficiary)
+
+ /**
+ * Display the specified resource.
+ */
+ // public function show(ProposalBeneficiary $proposalBeneficiary)
+ // {
+ //
+ // }
+
+ /**
+ * Show the form for editing the specified resource.
+ */
+ public function edit(ProposalBeneficiary $proposalBeneficiary)
{
- return new ProposalBeneficiaryResource($proposalBeneficiary);
+ return Inertia::render(Str::studly("ProposalBeneficiary").'/Update', [
+ //'options' => $regions,
+ 'proposalBeneficiary' => $proposalBeneficiary->toArray()
+ ]);
}
+
+ /**
+ * Update the specified resource in storage.
+ */
public function update(UpdateProposalBeneficiaryRequest $request, ProposalBeneficiary $proposalBeneficiary)
{
- $proposalBeneficiary->update($request->validated());
-
- return new ProposalBeneficiaryResource($proposalBeneficiary);
+ $validated = $request->validated();
+
+ $proposalBeneficiary->update($validated);
+ return back()->with('res', ['message' => __('ProposalBeneficiary Updated Seccessfully'), 'type' => 'success']);
}
- public function destroy(Request $request, ProposalBeneficiary $proposalBeneficiary)
+
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(ProposalBeneficiary $proposalBeneficiary)
{
$proposalBeneficiary->delete();
-
- return new ProposalBeneficiaryResource($proposalBeneficiary);
+ return back()->with('res', ['message' => __('ProposalBeneficiary Deleted Seccessfully'), 'type' => 'success']);
}
}
diff --git a/app/Http/Controllers/ProposalController.php b/app/Http/Controllers/ProposalController.php
index c7787d9..a9a6e02 100644
--- a/app/Http/Controllers/ProposalController.php
+++ b/app/Http/Controllers/ProposalController.php
@@ -2,81 +2,96 @@
namespace App\Http\Controllers;
+use App\Models\Proposal;
+use App\Http\Controllers\Controller;
use App\Http\Requests\StoreProposalRequest;
use App\Http\Requests\UpdateProposalRequest;
-use App\Http\Resources\ProposalResource;
-use App\Models\Proposal;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
-use Illuminate\Support\Str;
+use Inertia\Inertia;
+
class ProposalController extends Controller
{
-
- public static function routeName()
- {
+ public static function routeName(){
return Str::snake("Proposal");
}
-
- public function __construct(Request $request)
+ public function __construct(Request $request)
{
parent::__construct($request);
}
+ /**
+ * Display a listing of the resource.
+ */
public function index(Request $request)
{
- return view("dashboard." . $this->routeName() . ".index", [
- 'headers' => $this->getModelInstance()::headers(),
- ]);
- }
+
+ return Inertia::render(Str::studly("Proposal").'/Index', [
+ "headers" => Proposal::headers(),
+ "items" => Proposal::search($request)->sort($request)->paginate((request('per_page')??request('itemsPerPage'))??15),
- public function indexApi(Request $request)
- {
- return ProposalResource::collection(Proposal::search($request)->sort($request)->paginate((request('per_page') ?? request('itemsPerPage')) ?? 15));
+ ]);
}
+ /**
+ * Show the form for creating a new resource.
+ */
public function create()
{
- return view("dashboard." . $this->routeName() . ".create", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $this->getModelInstance()
+ return Inertia::render(Str::studly("Proposal").'/Create', [
+ // 'options' => $regions
]);
}
+ /**
+ * Store a newly created resource in storage.
+ */
public function store(StoreProposalRequest $request)
{
- $proposal = Proposal::create($request->validated());
-
- return new ProposalResource($proposal);
- }
-
- public function show(Request $request, Proposal $proposal)
- {
- return view("dashboard." . $this->routeName() . ".show", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $proposal
- ]);
+ $data = $request->validated();
+ Proposal::create($data);
+
+ return to_route($this->routeName() . '.index')->with('res', ['message' => __('Proposal Saved Seccessfully'), 'type' => 'success']);
}
+ /**
+ * Display the specified resource.
+ */
+ // public function show(Proposal $proposal)
+ // {
+ //
+ // }
+
+ /**
+ * Show the form for editing the specified resource.
+ */
public function edit(Proposal $proposal)
{
- return view("dashboard." . $this->routeName() . ".edit", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $proposal
+ return Inertia::render(Str::studly("Proposal").'/Update', [
+ //'options' => $regions,
+ 'proposal' => $proposal->toArray()
]);
}
+ /**
+ * Update the specified resource in storage.
+ */
public function update(UpdateProposalRequest $request, Proposal $proposal)
{
- $proposal->update($request->validated());
-
- return new ProposalResource($proposal);
+ $validated = $request->validated();
+
+ $proposal->update($validated);
+ return back()->with('res', ['message' => __('Proposal Updated Seccessfully'), 'type' => 'success']);
}
- public function destroy(Request $request, Proposal $proposal)
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(Proposal $proposal)
{
$proposal->delete();
-
- return new ProposalResource($proposal);
+ return back()->with('res', ['message' => __('Proposal Deleted Seccessfully'), 'type' => 'success']);
}
}
diff --git a/app/Http/Controllers/ProposalDetailController.php b/app/Http/Controllers/ProposalDetailController.php
index 8362512..f934ade 100644
--- a/app/Http/Controllers/ProposalDetailController.php
+++ b/app/Http/Controllers/ProposalDetailController.php
@@ -2,81 +2,96 @@
namespace App\Http\Controllers;
+use App\Models\ProposalDetail;
+use App\Http\Controllers\Controller;
use App\Http\Requests\StoreProposalDetailRequest;
use App\Http\Requests\UpdateProposalDetailRequest;
-use App\Http\Resources\ProposalDetailResource;
-use App\Models\ProposalDetail;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
-use Illuminate\Support\Str;
+use Inertia\Inertia;
+
class ProposalDetailController extends Controller
{
-
- public static function routeName()
- {
+ public static function routeName(){
return Str::snake("ProposalDetail");
}
-
- public function __construct(Request $request)
+ public function __construct(Request $request)
{
parent::__construct($request);
}
+ /**
+ * Display a listing of the resource.
+ */
public function index(Request $request)
{
- return view("dashboard." . $this->routeName() . ".index", [
- 'headers' => $this->getModelInstance()::headers(),
- ]);
- }
+
+ return Inertia::render(Str::studly("ProposalDetail").'/Index', [
+ "headers" => ProposalDetail::headers(),
+ "items" => ProposalDetail::search($request)->sort($request)->paginate($this->pagination),
- public function indexApi(Request $request)
- {
- return ProposalDetailResource::collection(ProposalDetail::search($request)->sort($request)->paginate((request('per_page') ?? request('itemsPerPage')) ?? 15));
+ ]);
}
+ /**
+ * Show the form for creating a new resource.
+ */
public function create()
{
- return view("dashboard." . $this->routeName() . ".create", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $this->getModelInstance()
+ return Inertia::render(Str::studly("ProposalDetail").'/Create', [
+ // 'options' => $regions
]);
}
+ /**
+ * Store a newly created resource in storage.
+ */
public function store(StoreProposalDetailRequest $request)
{
- $proposalDetail = ProposalDetail::create($request->validated());
-
- return new ProposalDetailResource($proposalDetail);
- }
-
- public function show(Request $request, ProposalDetail $proposalDetail)
- {
- return view("dashboard." . $this->routeName() . ".show", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $proposalDetail
- ]);
+ $data = $request->validated();
+ ProposalDetail::create($data);
+
+ return to_route($this->routeName() . '.index')->with('res', ['message' => __('ProposalDetail Saved Seccessfully'), 'type' => 'success']);
}
+ /**
+ * Display the specified resource.
+ */
+ // public function show(ProposalDetail $proposalDetail)
+ // {
+ //
+ // }
+
+ /**
+ * Show the form for editing the specified resource.
+ */
public function edit(ProposalDetail $proposalDetail)
{
- return view("dashboard." . $this->routeName() . ".edit", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $proposalDetail
+ return Inertia::render(Str::studly("ProposalDetail").'/Update', [
+ //'options' => $regions,
+ 'proposalDetail' => $proposalDetail->toArray()
]);
}
+ /**
+ * Update the specified resource in storage.
+ */
public function update(UpdateProposalDetailRequest $request, ProposalDetail $proposalDetail)
{
- $proposalDetail->update($request->validated());
-
- return new ProposalDetailResource($proposalDetail);
+ $validated = $request->validated();
+
+ $proposalDetail->update($validated);
+ return back()->with('res', ['message' => __('ProposalDetail Updated Seccessfully'), 'type' => 'success']);
}
- public function destroy(Request $request, ProposalDetail $proposalDetail)
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(ProposalDetail $proposalDetail)
{
$proposalDetail->delete();
-
- return new ProposalDetailResource($proposalDetail);
+ return back()->with('res', ['message' => __('ProposalDetail Deleted Seccessfully'), 'type' => 'success']);
}
}
diff --git a/app/Http/Controllers/RoleController.php b/app/Http/Controllers/RoleController.php
index e7d3650..6ed9ba3 100644
--- a/app/Http/Controllers/RoleController.php
+++ b/app/Http/Controllers/RoleController.php
@@ -1,69 +1,97 @@
sort($request)->paginate((request('per_page')??request('itemsPerPage'))??15));
+
+ return Inertia::render(Str::studly("Role").'/Index', [
+ "headers" => Role::headers(),
+ "items" => Role::search($request)->sort($request)->paginate($this->pagination),
+
+ ]);
}
- public function store(Request $request)
+
+ /**
+ * Show the form for creating a new resource.
+ */
+ public function create()
{
- if(!$this->user->is_permitted_to('store',Role::class,$request))
- return response()->json(['message'=>'not_permitted'],422);
+ return Inertia::render(Str::studly("Role").'/Create', [
+ // 'options' => $regions
+ ]);
+ }
- $validator = Validator::make($request->all(),Role::createRules($this->user));
- if($validator->fails()){
- return response()->json(['errors'=>$validator->errors()],422);
- }
- $role = Role::create($validator->validated());
- if ($request->translations) {
- foreach ($request->translations as $translation)
- $role->setTranslation($translation['field'], $translation['locale'], $translation['value'])->save();
- }
- return new RoleResource($role);
+ /**
+ * Store a newly created resource in storage.
+ */
+ public function store(StoreRoleRequest $request)
+ {
+ $data = $request->validated();
+ Role::create($data);
+
+ return to_route($this->routeName() . '.index')->with('res', ['message' => __('Role Saved Seccessfully'), 'type' => 'success']);
}
- public function show(Request $request,Role $role)
+
+ /**
+ * Display the specified resource.
+ */
+ // public function show(Role $role)
+ // {
+ //
+ // }
+
+ /**
+ * Show the form for editing the specified resource.
+ */
+ public function edit(Role $role)
{
- if(!$this->user->is_permitted_to('view',Role::class,$request))
- return response()->json(['message'=>'not_permitted'],422);
- return new RoleResource($role);
+ return Inertia::render(Str::studly("Role").'/Update', [
+ //'options' => $regions,
+ 'role' => $role->toArray()
+ ]);
}
- public function update(Request $request, Role $role)
+
+ /**
+ * Update the specified resource in storage.
+ */
+ public function update(UpdateRoleRequest $request, Role $role)
{
- if(!$this->user->is_permitted_to('update',Role::class,$request))
- return response()->json(['message'=>'not_permitted'],422);
- $validator = Validator::make($request->all(),Role::updateRules($this->user));
- if($validator->fails()){
- return response()->json(['errors'=>$validator->errors()],422);
- }
- $role->update($validator->validated());
- if ($request->translations) {
- foreach ($request->translations as $translation)
- $role->setTranslation($translation['field'], $translation['locale'], $translation['value'])->save();
- }
- return new RoleResource($role);
+ $validated = $request->validated();
+
+ $role->update($validated);
+ return back()->with('res', ['message' => __('Role Updated Seccessfully'), 'type' => 'success']);
}
- public function destroy(Request $request,Role $role)
+
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(Role $role)
{
- if(!$this->user->is_permitted_to('delete',Role::class,$request))
- return response()->json(['message'=>'not_permitted'],422);
$role->delete();
-
- return new RoleResource($role);
+ return back()->with('res', ['message' => __('Role Deleted Seccessfully'), 'type' => 'success']);
}
}
diff --git a/app/Http/Controllers/RolePermissionController.php b/app/Http/Controllers/RolePermissionController.php
index 1282eac..8325e86 100644
--- a/app/Http/Controllers/RolePermissionController.php
+++ b/app/Http/Controllers/RolePermissionController.php
@@ -1,69 +1,97 @@
sort($request)->paginate((request('per_page')??request('itemsPerPage'))??15));
+
+ return Inertia::render(Str::studly("RolePermission").'/Index', [
+ "headers" => RolePermission::headers(),
+ "items" => RolePermission::search($request)->sort($request)->paginate($this->pagination),
+
+ ]);
}
- public function store(Request $request)
+
+ /**
+ * Show the form for creating a new resource.
+ */
+ public function create()
{
- if(!$this->user->is_permitted_to('store',RolePermission::class,$request))
- return response()->json(['message'=>'not_permitted'],422);
+ return Inertia::render(Str::studly("RolePermission").'/Create', [
+ // 'options' => $regions
+ ]);
+ }
- $validator = Validator::make($request->all(),RolePermission::createRules($this->user));
- if($validator->fails()){
- return response()->json(['errors'=>$validator->errors()],422);
- }
- $rolePermission = RolePermission::create($validator->validated());
- if ($request->translations) {
- foreach ($request->translations as $translation)
- $rolePermission->setTranslation($translation['field'], $translation['locale'], $translation['value'])->save();
- }
- return new RolePermissionResource($rolePermission);
+ /**
+ * Store a newly created resource in storage.
+ */
+ public function store(StoreRolePermissionRequest $request)
+ {
+ $data = $request->validated();
+ RolePermission::create($data);
+
+ return to_route($this->routeName() . '.index')->with('res', ['message' => __('RolePermission Saved Seccessfully'), 'type' => 'success']);
}
- public function show(Request $request,RolePermission $rolePermission)
+
+ /**
+ * Display the specified resource.
+ */
+ // public function show(RolePermission $rolePermission)
+ // {
+ //
+ // }
+
+ /**
+ * Show the form for editing the specified resource.
+ */
+ public function edit(RolePermission $rolePermission)
{
- if(!$this->user->is_permitted_to('view',RolePermission::class,$request))
- return response()->json(['message'=>'not_permitted'],422);
- return new RolePermissionResource($rolePermission);
+ return Inertia::render(Str::studly("RolePermission").'/Update', [
+ //'options' => $regions,
+ 'rolePermission' => $rolePermission->toArray()
+ ]);
}
- public function update(Request $request, RolePermission $rolePermission)
+
+ /**
+ * Update the specified resource in storage.
+ */
+ public function update(UpdateRolePermissionRequest $request, RolePermission $rolePermission)
{
- if(!$this->user->is_permitted_to('update',RolePermission::class,$request))
- return response()->json(['message'=>'not_permitted'],422);
- $validator = Validator::make($request->all(),RolePermission::updateRules($this->user));
- if($validator->fails()){
- return response()->json(['errors'=>$validator->errors()],422);
- }
- $rolePermission->update($validator->validated());
- if ($request->translations) {
- foreach ($request->translations as $translation)
- $rolePermission->setTranslation($translation['field'], $translation['locale'], $translation['value'])->save();
- }
- return new RolePermissionResource($rolePermission);
+ $validated = $request->validated();
+
+ $rolePermission->update($validated);
+ return back()->with('res', ['message' => __('RolePermission Updated Seccessfully'), 'type' => 'success']);
}
- public function destroy(Request $request,RolePermission $rolePermission)
+
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(RolePermission $rolePermission)
{
- if(!$this->user->is_permitted_to('delete',RolePermission::class,$request))
- return response()->json(['message'=>'not_permitted'],422);
$rolePermission->delete();
-
- return new RolePermissionResource($rolePermission);
+ return back()->with('res', ['message' => __('RolePermission Deleted Seccessfully'), 'type' => 'success']);
}
}
diff --git a/app/Http/Controllers/UnitController.php b/app/Http/Controllers/UnitController.php
index 925b4d1..f308508 100644
--- a/app/Http/Controllers/UnitController.php
+++ b/app/Http/Controllers/UnitController.php
@@ -2,81 +2,96 @@
namespace App\Http\Controllers;
+use App\Models\Unit;
+use App\Http\Controllers\Controller;
use App\Http\Requests\StoreUnitRequest;
use App\Http\Requests\UpdateUnitRequest;
-use App\Http\Resources\UnitResource;
-use App\Models\Unit;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
-use Illuminate\Support\Str;
+use Inertia\Inertia;
+
class UnitController extends Controller
{
-
- public static function routeName()
- {
+ public static function routeName(){
return Str::snake("Unit");
}
-
- public function __construct(Request $request)
+ public function __construct(Request $request)
{
parent::__construct($request);
}
+ /**
+ * Display a listing of the resource.
+ */
public function index(Request $request)
{
- return view("dashboard." . $this->routeName() . ".index", [
- 'headers' => $this->getModelInstance()::headers(),
- ]);
- }
+
+ return Inertia::render(Str::studly("Unit").'/Index', [
+ "headers" => Unit::headers(),
+ "items" => Unit::search($request)->sort($request)->paginate($this->pagination),
- public function indexApi(Request $request)
- {
- return UnitResource::collection(Unit::search($request)->sort($request)->paginate((request('per_page') ?? request('itemsPerPage')) ?? 15));
+ ]);
}
+ /**
+ * Show the form for creating a new resource.
+ */
public function create()
{
- return view("dashboard." . $this->routeName() . ".create", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $this->getModelInstance()
+ return Inertia::render(Str::studly("Unit").'/Create', [
+ // 'options' => $regions
]);
}
+ /**
+ * Store a newly created resource in storage.
+ */
public function store(StoreUnitRequest $request)
{
- $unit = Unit::create($request->validated());
-
- return new UnitResource($unit);
- }
-
- public function show(Request $request, Unit $unit)
- {
- return view("dashboard." . $this->routeName() . ".show", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $unit
- ]);
+ $data = $request->validated();
+ Unit::create($data);
+
+ return to_route($this->routeName() . '.index')->with('res', ['message' => __('Unit Saved Seccessfully'), 'type' => 'success']);
}
+ /**
+ * Display the specified resource.
+ */
+ // public function show(Unit $unit)
+ // {
+ //
+ // }
+
+ /**
+ * Show the form for editing the specified resource.
+ */
public function edit(Unit $unit)
{
- return view("dashboard." . $this->routeName() . ".edit", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $unit
+ return Inertia::render(Str::studly("Unit").'/Update', [
+ //'options' => $regions,
+ 'unit' => $unit->toArray()
]);
}
+ /**
+ * Update the specified resource in storage.
+ */
public function update(UpdateUnitRequest $request, Unit $unit)
{
- $unit->update($request->validated());
-
- return new UnitResource($unit);
+ $validated = $request->validated();
+
+ $unit->update($validated);
+ return back()->with('res', ['message' => __('Unit Updated Seccessfully'), 'type' => 'success']);
}
- public function destroy(Request $request, Unit $unit)
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(Unit $unit)
{
$unit->delete();
-
- return new UnitResource($unit);
+ return back()->with('res', ['message' => __('Unit Deleted Seccessfully'), 'type' => 'success']);
}
}
diff --git a/app/Http/Controllers/UserRoleController.php b/app/Http/Controllers/UserRoleController.php
index 096a744..af326d4 100644
--- a/app/Http/Controllers/UserRoleController.php
+++ b/app/Http/Controllers/UserRoleController.php
@@ -1,69 +1,97 @@
sort($request)->paginate((request('per_page')??request('itemsPerPage'))??15));
+
+ return Inertia::render(Str::studly("UserRole").'/Index', [
+ "headers" => UserRole::headers(),
+ "items" => UserRole::search($request)->sort($request)->paginate($this->pagination),
+
+ ]);
}
- public function store(Request $request)
+
+ /**
+ * Show the form for creating a new resource.
+ */
+ public function create()
{
- if(!$this->user->is_permitted_to('store',UserRole::class,$request))
- return response()->json(['message'=>'not_permitted'],422);
+ return Inertia::render(Str::studly("UserRole").'/Create', [
+ // 'options' => $regions
+ ]);
+ }
- $validator = Validator::make($request->all(),UserRole::createRules($this->user));
- if($validator->fails()){
- return response()->json(['errors'=>$validator->errors()],422);
- }
- $userRole = UserRole::create($validator->validated());
- if ($request->translations) {
- foreach ($request->translations as $translation)
- $userRole->setTranslation($translation['field'], $translation['locale'], $translation['value'])->save();
- }
- return new UserRoleResource($userRole);
+ /**
+ * Store a newly created resource in storage.
+ */
+ public function store(StoreUserRoleRequest $request)
+ {
+ $data = $request->validated();
+ UserRole::create($data);
+
+ return to_route($this->routeName() . '.index')->with('res', ['message' => __('UserRole Saved Seccessfully'), 'type' => 'success']);
}
- public function show(Request $request,UserRole $userRole)
+
+ /**
+ * Display the specified resource.
+ */
+ // public function show(UserRole $userRole)
+ // {
+ //
+ // }
+
+ /**
+ * Show the form for editing the specified resource.
+ */
+ public function edit(UserRole $userRole)
{
- if(!$this->user->is_permitted_to('view',UserRole::class,$request))
- return response()->json(['message'=>'not_permitted'],422);
- return new UserRoleResource($userRole);
+ return Inertia::render(Str::studly("UserRole").'/Update', [
+ //'options' => $regions,
+ 'userRole' => $userRole->toArray()
+ ]);
}
- public function update(Request $request, UserRole $userRole)
+
+ /**
+ * Update the specified resource in storage.
+ */
+ public function update(UpdateUserRoleRequest $request, UserRole $userRole)
{
- if(!$this->user->is_permitted_to('update',UserRole::class,$request))
- return response()->json(['message'=>'not_permitted'],422);
- $validator = Validator::make($request->all(),UserRole::updateRules($this->user));
- if($validator->fails()){
- return response()->json(['errors'=>$validator->errors()],422);
- }
- $userRole->update($validator->validated());
- if ($request->translations) {
- foreach ($request->translations as $translation)
- $userRole->setTranslation($translation['field'], $translation['locale'], $translation['value'])->save();
- }
- return new UserRoleResource($userRole);
+ $validated = $request->validated();
+
+ $userRole->update($validated);
+ return back()->with('res', ['message' => __('UserRole Updated Seccessfully'), 'type' => 'success']);
}
- public function destroy(Request $request,UserRole $userRole)
+
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(UserRole $userRole)
{
- if(!$this->user->is_permitted_to('delete',UserRole::class,$request))
- return response()->json(['message'=>'not_permitted'],422);
$userRole->delete();
-
- return new UserRoleResource($userRole);
+ return back()->with('res', ['message' => __('UserRole Deleted Seccessfully'), 'type' => 'success']);
}
}
diff --git a/app/Http/Controllers/WarehouseController.php b/app/Http/Controllers/WarehouseController.php
index 7e7f89e..ff10813 100644
--- a/app/Http/Controllers/WarehouseController.php
+++ b/app/Http/Controllers/WarehouseController.php
@@ -2,81 +2,96 @@
namespace App\Http\Controllers;
+use App\Models\Warehouse;
+use App\Http\Controllers\Controller;
use App\Http\Requests\StoreWarehouseRequest;
use App\Http\Requests\UpdateWarehouseRequest;
-use App\Http\Resources\WarehouseResource;
-use App\Models\Warehouse;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
-use Illuminate\Support\Str;
+use Inertia\Inertia;
+
class WarehouseController extends Controller
{
-
- public static function routeName()
- {
+ public static function routeName(){
return Str::snake("Warehouse");
}
-
- public function __construct(Request $request)
+ public function __construct(Request $request)
{
parent::__construct($request);
}
+ /**
+ * Display a listing of the resource.
+ */
public function index(Request $request)
{
- return view("dashboard." . $this->routeName() . ".index", [
- 'headers' => $this->getModelInstance()::headers(),
- ]);
- }
+
+ return Inertia::render(Str::studly("Warehouse").'/Index', [
+ "headers" => Warehouse::headers(),
+ "items" => Warehouse::search($request)->sort($request)->paginate($this->pagination),
- public function indexApi(Request $request)
- {
- return WarehouseResource::collection(Warehouse::search($request)->sort($request)->paginate((request('per_page') ?? request('itemsPerPage')) ?? 15));
+ ]);
}
+ /**
+ * Show the form for creating a new resource.
+ */
public function create()
{
- return view("dashboard." . $this->routeName() . ".create", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $this->getModelInstance()
+ return Inertia::render(Str::studly("Warehouse").'/Create', [
+ // 'options' => $regions
]);
}
+ /**
+ * Store a newly created resource in storage.
+ */
public function store(StoreWarehouseRequest $request)
{
- $warehouse = Warehouse::create($request->validated());
-
- return new WarehouseResource($warehouse);
- }
-
- public function show(Request $request, Warehouse $warehouse)
- {
- return view("dashboard." . $this->routeName() . ".show", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $warehouse
- ]);
+ $data = $request->validated();
+ Warehouse::create($data);
+
+ return to_route($this->routeName() . '.index')->with('res', ['message' => __('Warehouse Saved Seccessfully'), 'type' => 'success']);
}
+ /**
+ * Display the specified resource.
+ */
+ // public function show(Warehouse $warehouse)
+ // {
+ //
+ // }
+
+ /**
+ * Show the form for editing the specified resource.
+ */
public function edit(Warehouse $warehouse)
{
- return view("dashboard." . $this->routeName() . ".edit", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $warehouse
+ return Inertia::render(Str::studly("Warehouse").'/Update', [
+ //'options' => $regions,
+ 'warehouse' => $warehouse->toArray()
]);
}
+ /**
+ * Update the specified resource in storage.
+ */
public function update(UpdateWarehouseRequest $request, Warehouse $warehouse)
{
- $warehouse->update($request->validated());
-
- return new WarehouseResource($warehouse);
+ $validated = $request->validated();
+
+ $warehouse->update($validated);
+ return back()->with('res', ['message' => __('Warehouse Updated Seccessfully'), 'type' => 'success']);
}
- public function destroy(Request $request, Warehouse $warehouse)
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(Warehouse $warehouse)
{
$warehouse->delete();
-
- return new WarehouseResource($warehouse);
+ return back()->with('res', ['message' => __('Warehouse Deleted Seccessfully'), 'type' => 'success']);
}
}
diff --git a/app/Http/Controllers/WarehouseDetailController.php b/app/Http/Controllers/WarehouseDetailController.php
index 3ab83db..4877459 100644
--- a/app/Http/Controllers/WarehouseDetailController.php
+++ b/app/Http/Controllers/WarehouseDetailController.php
@@ -2,81 +2,96 @@
namespace App\Http\Controllers;
+use App\Models\WarehouseDetail;
+use App\Http\Controllers\Controller;
use App\Http\Requests\StoreWarehouseDetailRequest;
use App\Http\Requests\UpdateWarehouseDetailRequest;
-use App\Http\Resources\WarehouseDetailResource;
-use App\Models\WarehouseDetail;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
-use Illuminate\Support\Str;
+use Inertia\Inertia;
+
class WarehouseDetailController extends Controller
{
-
- public static function routeName()
- {
+ public static function routeName(){
return Str::snake("WarehouseDetail");
}
-
- public function __construct(Request $request)
+ public function __construct(Request $request)
{
parent::__construct($request);
}
+ /**
+ * Display a listing of the resource.
+ */
public function index(Request $request)
{
- return view("dashboard." . $this->routeName() . ".index", [
- 'headers' => $this->getModelInstance()::headers(),
- ]);
- }
+
+ return Inertia::render(Str::studly("WarehouseDetail").'/Index', [
+ "headers" => WarehouseDetail::headers(),
+ "items" => WarehouseDetail::search($request)->sort($request)->paginate($this->pagination),
- public function indexApi(Request $request)
- {
- return WarehouseDetailResource::collection(WarehouseDetail::search($request)->sort($request)->paginate((request('per_page') ?? request('itemsPerPage')) ?? 15));
+ ]);
}
+ /**
+ * Show the form for creating a new resource.
+ */
public function create()
{
- return view("dashboard." . $this->routeName() . ".create", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $this->getModelInstance()
+ return Inertia::render(Str::studly("WarehouseDetail").'/Create', [
+ // 'options' => $regions
]);
}
+ /**
+ * Store a newly created resource in storage.
+ */
public function store(StoreWarehouseDetailRequest $request)
{
- $warehouseDetail = WarehouseDetail::create($request->validated());
-
- return new WarehouseDetailResource($warehouseDetail);
- }
-
- public function show(Request $request, WarehouseDetail $warehouseDetail)
- {
- return view("dashboard." . $this->routeName() . ".show", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $warehouseDetail
- ]);
+ $data = $request->validated();
+ WarehouseDetail::create($data);
+
+ return to_route($this->routeName() . '.index')->with('res', ['message' => __('WarehouseDetail Saved Seccessfully'), 'type' => 'success']);
}
+ /**
+ * Display the specified resource.
+ */
+ // public function show(WarehouseDetail $warehouseDetail)
+ // {
+ //
+ // }
+
+ /**
+ * Show the form for editing the specified resource.
+ */
public function edit(WarehouseDetail $warehouseDetail)
{
- return view("dashboard." . $this->routeName() . ".edit", [
- 'data_to_send' => 'Hello, World!',
- $this->routeName() => $warehouseDetail
+ return Inertia::render(Str::studly("WarehouseDetail").'/Update', [
+ //'options' => $regions,
+ 'warehouseDetail' => $warehouseDetail->toArray()
]);
}
+ /**
+ * Update the specified resource in storage.
+ */
public function update(UpdateWarehouseDetailRequest $request, WarehouseDetail $warehouseDetail)
{
- $warehouseDetail->update($request->validated());
-
- return new WarehouseDetailResource($warehouseDetail);
+ $validated = $request->validated();
+
+ $warehouseDetail->update($validated);
+ return back()->with('res', ['message' => __('WarehouseDetail Updated Seccessfully'), 'type' => 'success']);
}
- public function destroy(Request $request, WarehouseDetail $warehouseDetail)
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(WarehouseDetail $warehouseDetail)
{
$warehouseDetail->delete();
-
- return new WarehouseDetailResource($warehouseDetail);
+ return back()->with('res', ['message' => __('WarehouseDetail Deleted Seccessfully'), 'type' => 'success']);
}
}
diff --git a/app/Http/Requests/StoreItemRequest.php b/app/Http/Requests/StoreItemRequest.php
new file mode 100644
index 0000000..10aa256
--- /dev/null
+++ b/app/Http/Requests/StoreItemRequest.php
@@ -0,0 +1,28 @@
+|string>
+ */
+ public function rules(): array
+ {
+ return [
+ //
+ ];
+ }
+}
diff --git a/app/Http/Requests/UpdateItemRequest.php b/app/Http/Requests/UpdateItemRequest.php
new file mode 100644
index 0000000..f7fdaf8
--- /dev/null
+++ b/app/Http/Requests/UpdateItemRequest.php
@@ -0,0 +1,28 @@
+|string>
+ */
+ public function rules(): array
+ {
+ return [
+ //
+ ];
+ }
+}
diff --git a/app/Models/Beneficiary.php b/app/Models/Beneficiary.php
index e8ebd1e..7e2c78b 100644
--- a/app/Models/Beneficiary.php
+++ b/app/Models/Beneficiary.php
@@ -9,20 +9,10 @@ class Beneficiary extends BaseModel
{
use HasFactory;
- protected $appends = ['father_name', 'headers'];
+ protected $appends = ['father_name'];
public static $controllable = true;
- public function getHeadersAttribute()
- {
- return [
- ['sortable' => true, 'value' => 'name', 'key' => 'name'],
- ['sortable' => true, 'value' => 'national id', 'key' => 'national_id'],
- ['sortable' => true, 'value' => 'phone', 'key' => 'phone'],
- ['sortable' => true, 'value' => 'email', 'key' => 'email'],
- ['sortable' => true, 'value' => 'father name', 'key' => 'father_name'],
- ['sortable' => true, 'value' => 'actions', 'key' => 'actions', 'actions' => ['show', 'update', 'delete']],
- ];
- }
+
public function getFatherNameAttribute()
{
return $this->belongsTo(Beneficiary::class, 'father_id')->first()->name ?? '';
diff --git a/app/Models/Item.php b/app/Models/Item.php
new file mode 100644
index 0000000..b7cb897
--- /dev/null
+++ b/app/Models/Item.php
@@ -0,0 +1,30 @@
+belongsTo(Unit::class, 'unit_id');
+ }
+
+
+
+ public static function headers($user = null)
+ {
+ return [
+ ['sortable' => true, 'value' => 'name', 'key' => 'name'],
+ ['sortable' => true, 'value' => 'price', 'key' => 'estimated_price'],
+ ['sortable' => true, 'value' => 'description', 'key' => 'description'],
+ ['sortable' => true, 'value' => 'actions', 'key' => 'actions', 'actions' => ['show', 'update', 'delete']],
+ ];
+ }
+}
diff --git a/app/Models/Proposal.php b/app/Models/Proposal.php
index 3f6fe29..0da4a79 100644
--- a/app/Models/Proposal.php
+++ b/app/Models/Proposal.php
@@ -9,21 +9,9 @@ class Proposal extends BaseModel
{
use HasFactory;
- protected $appends = ['donor_name', 'donor', 'status_str', 'beneficiaries', 'propsal_details', 'total', 'headers'];
+ protected $appends = ['donor_name', 'donor', 'status_str', 'beneficiaries', 'propsal_details', 'total'];
public static $controllable = true;
- public function getHeadersAttribute()
- {
- return [
- ['sortable' => true, 'value' => 'name', 'key' => 'name'],
- ['sortable' => true, 'value' => 'national id', 'key' => 'national_id'],
- ['sortable' => true, 'value' => 'phone', 'key' => 'phone'],
- ['sortable' => true, 'value' => 'email', 'key' => 'email'],
- ['sortable' => true, 'value' => 'father name', 'key' => 'father_name'],
- ['sortable' => true, 'value' => 'actions', 'key' => 'actions', 'actions' => ['show', 'update', 'delete']],
- ];
- }
-
public function getDonorNameAttribute()
{
return $this->donor?->name;
diff --git a/app/Models/ProposalDetail.php b/app/Models/ProposalDetail.php
index c29d272..e109cab 100644
--- a/app/Models/ProposalDetail.php
+++ b/app/Models/ProposalDetail.php
@@ -8,20 +8,9 @@
class ProposalDetail extends BaseModel
{
use HasFactory;
- protected $appends = ['unit', 'unit_name', 'total', 'headers'];
+ protected $appends = ['unit', 'unit_name', 'total'];
public static $controllable = true;
- public function getHeadersAttribute()
- {
- return [
- ['sortable' => true, 'value' => 'name', 'key' => 'name'],
- ['sortable' => true, 'value' => 'national id', 'key' => 'national_id'],
- ['sortable' => true, 'value' => 'phone', 'key' => 'phone'],
- ['sortable' => true, 'value' => 'email', 'key' => 'email'],
- ['sortable' => true, 'value' => 'father name', 'key' => 'father_name'],
- ['sortable' => true, 'value' => 'actions', 'key' => 'actions', 'actions' => ['show', 'update', 'delete']],
- ];
- }
public function getUnitAttribute()
{
return $this->belongsTo(Unit::class, 'unit_id');
diff --git a/app/Models/Unit.php b/app/Models/Unit.php
index e560de6..3aa786b 100644
--- a/app/Models/Unit.php
+++ b/app/Models/Unit.php
@@ -8,27 +8,12 @@
class Unit extends BaseModel
{
use HasFactory;
-
- protected $appends = ['headers'];
public static $controllable = true;
- public function getHeadersAttribute()
- {
- return [
- ['sortable' => true, 'value' => 'name', 'key' => 'name'],
- ['sortable' => true, 'value' => 'national id', 'key' => 'national_id'],
- ['sortable' => true, 'value' => 'phone', 'key' => 'phone'],
- ['sortable' => true, 'value' => 'email', 'key' => 'email'],
- ['sortable' => true, 'value' => 'father name', 'key' => 'father_name'],
- ['sortable' => true, 'value' => 'actions', 'key' => 'actions', 'actions' => ['show', 'update', 'delete']],
- ];
- }
public static function headers($user = null)
{
return [
['sortable' => true, 'value' => 'name', 'key' => 'name'],
- ['sortable' => true, 'value' => 'price', 'key' => 'estimated_price'],
- ['sortable' => true, 'value' => 'description', 'key' => 'description'],
['sortable' => true, 'value' => 'actions', 'key' => 'actions', 'actions' => ['show', 'update', 'delete']],
];
}
diff --git a/app/Models/User.php b/app/Models/User.php
index 09a9aa4..de7dd90 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -12,7 +12,7 @@ class User extends Authenticatable
{
use HasApiTokens, HasFactory;
- protected $appends = ['type_str', 'status_str', 'headers'];
+ protected $appends = ['type_str', 'status_str'];
public static $controllable = true;
public const DEFAULTPASSWD = '123456';
protected $hidden = [
@@ -27,17 +27,6 @@ class User extends Authenticatable
protected $guarded = [];
- public function getHeadersAttribute()
- {
- return [
- ['sortable' => true, 'value' => 'name', 'key' => 'name'],
- ['sortable' => true, 'value' => 'national id', 'key' => 'national_id'],
- ['sortable' => true, 'value' => 'phone', 'key' => 'phone'],
- ['sortable' => true, 'value' => 'email', 'key' => 'email'],
- ['sortable' => true, 'value' => 'father name', 'key' => 'father_name'],
- ['sortable' => true, 'value' => 'actions', 'key' => 'actions', 'actions' => ['show', 'update', 'delete']],
- ];
- }
public static $datatableHeaders = ['id', 'name', 'type', 'actions'];
public function scopeSearch($query, $request)
{
diff --git a/app/Models/Warehouse.php b/app/Models/Warehouse.php
index 3085dc0..6db8454 100644
--- a/app/Models/Warehouse.php
+++ b/app/Models/Warehouse.php
@@ -10,21 +10,9 @@ class Warehouse extends BaseModel
use HasFactory;
// protected $appends = ['status_str'];
- protected $appends = ['warehouse_details', 'total', 'headers'];
+ protected $appends = ['warehouse_details', 'total'];
public static $controllable = true;
- public function getHeadersAttribute()
- {
- return [
- ['sortable' => true, 'value' => 'name', 'key' => 'name'],
- ['sortable' => true, 'value' => 'national id', 'key' => 'national_id'],
- ['sortable' => true, 'value' => 'phone', 'key' => 'phone'],
- ['sortable' => true, 'value' => 'email', 'key' => 'email'],
- ['sortable' => true, 'value' => 'father name', 'key' => 'father_name'],
- ['sortable' => true, 'value' => 'actions', 'key' => 'actions', 'actions' => ['show', 'update', 'delete']],
- ];
- }
-
public function getStatusStrAttribute()
{
return [1 => 'accepted', 2 => 'unaccepted', 3 => 'pending', 4 => 'preparing', 8 => 'done'][$this->status] ?? '';
diff --git a/app/Models/WarehouseDetail.php b/app/Models/WarehouseDetail.php
index 292b1df..ee6e414 100644
--- a/app/Models/WarehouseDetail.php
+++ b/app/Models/WarehouseDetail.php
@@ -9,39 +9,32 @@ class WarehouseDetail extends BaseModel
{
use HasFactory;
- protected $appends = ['unit', 'total', 'unit_name', 'headers'];
+ protected $appends = ['item', 'total', 'item_name', 'unit_name'];
public static $controllable = true;
- public function getHeadersAttribute()
+ public function getItemAttribute()
{
- return [
- ['sortable' => true, 'value' => 'name', 'key' => 'name'],
- ['sortable' => true, 'value' => 'national id', 'key' => 'national_id'],
- ['sortable' => true, 'value' => 'phone', 'key' => 'phone'],
- ['sortable' => true, 'value' => 'email', 'key' => 'email'],
- ['sortable' => true, 'value' => 'father name', 'key' => 'father_name'],
- ['sortable' => true, 'value' => 'actions', 'key' => 'actions', 'actions' => ['show', 'update', 'delete']],
- ];
- }
-
- public function getUnitAttribute()
- {
- return $this->belongsTo(Unit::class, 'unit_id');
+ return $this->belongsTo(Item::class, 'item_id');
}
public function getTotalAttribute()
{
- return $this->amount * $this->unit->estimated_price;
+ return $this->amount * $this->item->estimated_price;
}
public function getUnitNameAttribute()
{
- return $this->unit->name;
+ return $this->item->unit->name;
+ }
+ public function getItemNameAttribute()
+ {
+ return $this->item->name;
}
public static function headers($user = null)
{
return [
+ ['sortable' => true, 'value' => 'item name', 'key' => 'item_name'],
['sortable' => true, 'value' => 'unit name', 'key' => 'unit_name'],
['sortable' => true, 'value' => 'amount', 'key' => 'amount'],
['sortable' => true, 'value' => 'actions', 'key' => 'actions', 'actions' => ['show', 'update', 'delete']],
diff --git a/app/Models_old/Attachment.php b/app/Models_old/Attachment.php
new file mode 100644
index 0000000..dc04c23
--- /dev/null
+++ b/app/Models_old/Attachment.php
@@ -0,0 +1,11 @@
+getTable();
+ }
+ public function scopeSearch($query, $request)
+ {
+ }
+ public function scopeSort($query, $request)
+ {
+ }
+
+ public function files()
+ {
+ return $this->morphMany(Attachment::class, 'entity_id')->where('user_id', '=', auth('web')->user()->id);
+ }
+}
diff --git a/app/Models_old/Beneficiary.php b/app/Models_old/Beneficiary.php
new file mode 100644
index 0000000..12274bf
--- /dev/null
+++ b/app/Models_old/Beneficiary.php
@@ -0,0 +1,11 @@
+ 'datetime',
+ 'is_active' => 'boolean',
+ ];
+
+ protected $guarded = [];
+
+ public function getHeadersAttribute()
+ {
+ return [
+ ['sortable' => true, 'value' => 'name', 'key' => 'name'],
+ ['sortable' => true, 'value' => 'national id', 'key' => 'national_id'],
+ ['sortable' => true, 'value' => 'phone', 'key' => 'phone'],
+ ['sortable' => true, 'value' => 'email', 'key' => 'email'],
+ ['sortable' => true, 'value' => 'father name', 'key' => 'father_name'],
+ ['sortable' => true, 'value' => 'actions', 'key' => 'actions', 'actions' => ['show', 'update', 'delete']],
+ ];
+ }
+ public static $datatableHeaders = ['id', 'name', 'type', 'actions'];
+ public function scopeSearch($query, $request)
+ {
+ }
+ public function scopeSort($query, $request)
+ {
+ }
+ public function is_permitted_to($name, $class_name, $request)
+ {
+ $permitted = true;
+ if (!$this->current_role)
+ return true;
+ if (isset($class_name::$controllable)) {
+ if (isset($class_name::$field_to_check)) {
+ $model = null;
+ $field = $class_name::$field_to_check;
+ $params = Route::current()->parameters();
+ $model = reset($params);
+ if ($request->id) {
+ $model = $class_name::find($request->id);
+ }
+ if (!$model) {
+ if (!$request->$field)
+ return false;
+ $p_name = $class_name::getSubName($request->$field);
+ } else {
+ $p_name = $class_name::getSubName($model->$field);
+ }
+ } else {
+ return true;
+ }
+
+ $permission = $this->current_role->permissions()->where('code', '=', $p_name)->first();
+ if (!$permission)
+ return true;
+ $p = $name;
+ return $permission->$p;
+ }
+ return true;
+ }
+
+ public function getTypeStrAttribute()
+ {
+ return [1 => 'individual', 2 => 'organisation'][$this->type] ?? "";
+ }
+
+ public function getStatusStrAttribute()
+ {
+ return [1 => 'Open', 2 => 'Closed', 3 => 'Blocked'][$this->status];
+ }
+ public static function headers()
+ {
+ return [
+ ['sortable' => true, 'value' => 'name', 'key' => 'name'],
+ ['sortable' => true, 'value' => 'email', 'key' => 'email'],
+ ['sortable' => true, 'value' => 'phone', 'key' => 'phone'],
+ ['sortable' => true, 'value' => 'status', 'key' => 'status_str'],
+ ['sortable' => true, 'value' => 'type', 'key' => 'type_str'],
+ ['sortable' => true, 'value' => 'job title', 'key' => 'job_title'],
+ ['sortable' => true, 'value' => 'is active', 'key' => 'is_active'],
+ ['sortable' => true, 'value' => 'actions', 'key' => 'actions', 'actions' => ['show', 'update', 'delete']],
+ ];
+ }
+}
diff --git a/app/Models_old/UserRole.php b/app/Models_old/UserRole.php
new file mode 100644
index 0000000..f067f50
--- /dev/null
+++ b/app/Models_old/UserRole.php
@@ -0,0 +1,11 @@
+id();
$table->string('name');
- $table->text('description')->nullable();
- $table->decimal('estimated_price', 10, 2)->default(0);
+
$table->timestamps();
});
}
diff --git a/database/migrations/2024_11_26_185510_create_items_table.php b/database/migrations/2024_11_26_185510_create_items_table.php
new file mode 100644
index 0000000..46f06c1
--- /dev/null
+++ b/database/migrations/2024_11_26_185510_create_items_table.php
@@ -0,0 +1,32 @@
+id();
+ $table->string('name');
+ $table->unsignedBigInteger('unit_id');
+ $table->foreign('unit_id')->references('id')->on('units');
+ $table->text('description')->nullable();
+ $table->decimal('estimated_price', 10, 2)->default(0);
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('items');
+ }
+};
diff --git a/database/migrations/2024_11_26_185519_create_warehouse_details_table.php b/database/migrations/2024_11_26_185519_create_warehouse_details_table.php
index 05b6257..5519681 100644
--- a/database/migrations/2024_11_26_185519_create_warehouse_details_table.php
+++ b/database/migrations/2024_11_26_185519_create_warehouse_details_table.php
@@ -15,12 +15,12 @@ public function up()
Schema::create('warehouse_details', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('warehouse_id');
- $table->unsignedBigInteger('unit_id');
+ $table->unsignedBigInteger('item_id');
$table->decimal('amount')->default(0);
$table->timestamps();
-
+ $table->foreign('item_id')->references('id')->on('items');
$table->foreign('warehouse_id')->references('id')->on('warehouses');
- $table->foreign('unit_id')->references('id')->on('units');
+
});
}
diff --git a/database/migrations/2024_11_26_185525_create_beneficiaries_table.php b/database/migrations/2024_11_26_185525_create_beneficiaries_table.php
index d1601bc..55337d0 100644
--- a/database/migrations/2024_11_26_185525_create_beneficiaries_table.php
+++ b/database/migrations/2024_11_26_185525_create_beneficiaries_table.php
@@ -20,6 +20,8 @@ public function up()
$table->string('email')->nullable();
$table->date('dob')->nullable();
$table->unsignedBigInteger('father_id')->nullable();
+ $table->unsignedBigInteger('warehouse_id');
+ $table->foreign('warehouse_id')->references('id')->on('warehouses');
$table->timestamps();
diff --git a/database/seeders/ItemSeeder.php b/database/seeders/ItemSeeder.php
new file mode 100644
index 0000000..480643d
--- /dev/null
+++ b/database/seeders/ItemSeeder.php
@@ -0,0 +1,17 @@
+
+import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue';
+import { Head } from '@inertiajs/vue3';
+
+
+
+
+
+
+ Proposal
+
+
+
+