first change
This commit is contained in:
0
Modules/Admin/app/Http/Controllers/.gitkeep
Normal file
0
Modules/Admin/app/Http/Controllers/.gitkeep
Normal file
141
Modules/Admin/app/Http/Controllers/CalendarController.php
Normal file
141
Modules/Admin/app/Http/Controllers/CalendarController.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Client\Repositories\ClientInterface;
|
||||
use Modules\Content\Interfaces\ContentInterface;
|
||||
use Modules\Content\Models\Content;
|
||||
use Modules\Meeting\Models\Event;
|
||||
use Modules\Meeting\Models\Meeting;
|
||||
use Modules\Meeting\Repositories\EventInterface;
|
||||
use Modules\Meeting\Repositories\MeetingInterface;
|
||||
use Modules\Product\Interfaces\ProductInterface;
|
||||
|
||||
class CalendarController extends Controller
|
||||
{
|
||||
private $event;
|
||||
private $content;
|
||||
private $meeting;
|
||||
private $employee;
|
||||
private $client;
|
||||
private $product;
|
||||
|
||||
public function __construct(
|
||||
EventInterface $event,
|
||||
MeetingInterface $meeting,
|
||||
ContentInterface $content,
|
||||
ProductInterface $product,
|
||||
ClientInterface $client
|
||||
) {
|
||||
$this->event = $event;
|
||||
$this->meeting = $meeting;
|
||||
$this->content = $content;
|
||||
$this->client = $client;
|
||||
$this->product = $product;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = 'Calendar';
|
||||
$data['events'] = $this->event->findAll();
|
||||
$data['meetings'] = $this->meeting->findAll();
|
||||
$data['contents'] = $this->content->findAllUpcomingScheduledContent();
|
||||
$data['productOptions'] = $this->product->pluck();
|
||||
$data['clientList'] = $this->client->pluck();
|
||||
|
||||
return view('admin::calendar.index', $data);
|
||||
}
|
||||
public function calendarByAjax(Request $request)
|
||||
{
|
||||
$filters['start_date'] = $request->start;
|
||||
$filters['end_date'] = $request->end;
|
||||
$filters['product_id'] = $request->product_id;
|
||||
$list = [];
|
||||
$events = Event::when($filters, function ($query) use ($filters) {
|
||||
if (isset($filters["start_date"])) {
|
||||
$query->whereDate("start_date", ">=", $filters["start_date"]);
|
||||
}
|
||||
|
||||
if (isset($filters["end_date"])) {
|
||||
$query->whereDate("end_date", "<=", $filters["end_date"]);
|
||||
$query->orWhereNull("end_date");
|
||||
}
|
||||
})->get();
|
||||
|
||||
foreach ($events as $event) {
|
||||
$list[] = [
|
||||
"id" => $event->id,
|
||||
"title" => $event->title,
|
||||
"type" => 'event',
|
||||
"start" => $event->start_date,
|
||||
"end" => $event->end_date,
|
||||
"className" => "bg-primary",
|
||||
"desc" => $event->description,
|
||||
"location" => $event->location,
|
||||
'allDay' => true,
|
||||
];
|
||||
}
|
||||
|
||||
$contents = Content::where('status', '!=', 11)
|
||||
->when($filters, function ($query) use ($filters) {
|
||||
if (isset($filters["start_date"])) {
|
||||
$query->whereDate("release_date", ">=", $filters["start_date"]);
|
||||
}
|
||||
|
||||
if (isset($filters["end_date"])) {
|
||||
$query->where(function ($q) use ($filters) {
|
||||
$q->whereDate("release_date", "<=", $filters["end_date"])
|
||||
->orWhereNull("release_date");
|
||||
});
|
||||
}
|
||||
|
||||
if (isset($filters["product_id"])) {
|
||||
$query->where("product_id", $filters["product_id"]);
|
||||
}
|
||||
})
|
||||
->with(['product.client'])
|
||||
->get();
|
||||
|
||||
foreach ($contents as $content) {
|
||||
$list[] = [
|
||||
"id" => $content->id,
|
||||
"title" => $content->title,
|
||||
"type" => 'content schedule',
|
||||
"start" => Carbon::parse($content->getRawOriginal('release_date') . ' ' . $content->getRawOriginal('release_time')),
|
||||
"end" => null,
|
||||
"className" => "bg-success",
|
||||
"location" => null,
|
||||
"desc" => $content->product?->client?->name,
|
||||
'allDay' => false,
|
||||
];
|
||||
}
|
||||
|
||||
$meetings = Meeting::when($filters, function ($query) use ($filters) {
|
||||
if (isset($filters["start_date"])) {
|
||||
$query->whereDate("date", ">=", $filters["start_date"]);
|
||||
}
|
||||
|
||||
})->get();
|
||||
|
||||
foreach ($meetings as $meeting) {
|
||||
$list[] = [
|
||||
"id" => $meeting->id,
|
||||
"title" => $meeting->title,
|
||||
"type" => 'meeting',
|
||||
"start" => Carbon::parse($meeting->getRawOriginal('date') . ' ' . $meeting->getRawOriginal('start_time')),
|
||||
"location" => $meeting->location,
|
||||
"desc" => $meeting->description,
|
||||
"className" => "bg-warning",
|
||||
'allDay' => false,
|
||||
];
|
||||
}
|
||||
|
||||
return $list;
|
||||
|
||||
}
|
||||
}
|
83
Modules/Admin/app/Http/Controllers/CityController.php
Normal file
83
Modules/Admin/app/Http/Controllers/CityController.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Admin\Repositories\CityRepository;
|
||||
|
||||
class CityController extends Controller
|
||||
{
|
||||
private $cityRepository;
|
||||
|
||||
public function __construct(CityRepository $cityRepository)
|
||||
{
|
||||
$this->cityRepository = $cityRepository;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = 'City List';
|
||||
$data['cityLists'] = $this->cityRepository->findAll();
|
||||
return view('admin::cities.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create City';
|
||||
$data['editable'] = false;
|
||||
return view('admin::cities.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->cityRepository->create($request->all());
|
||||
return redirect()->route('city.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('admin::cities.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Edit City';
|
||||
$data['editable'] = true;
|
||||
$data['city'] = $this->cityRepository->getCityById($id);
|
||||
return view('admin::cities.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$this->cityRepository->update($id, $request->all());
|
||||
return redirect()->route('city.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
102
Modules/Admin/app/Http/Controllers/CountryController.php
Normal file
102
Modules/Admin/app/Http/Controllers/CountryController.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Admin\Models\Country;
|
||||
use Modules\Admin\Repositories\CountryInterface;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class CountryController extends Controller
|
||||
{
|
||||
private $country;
|
||||
|
||||
public function __construct(CountryInterface $country)
|
||||
{
|
||||
$this->country = $country;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$data['title'] = 'Country List';
|
||||
$data['countries'] = $this->country->findAll();
|
||||
|
||||
if ($request->ajax()) {
|
||||
$model = Country::query();
|
||||
|
||||
return DataTables::eloquent($model)
|
||||
->setRowId('{{$id}}')
|
||||
->setRowClass('{{"text-center align-middle"}}')
|
||||
->addColumn('action', 'admin::countries.datatables.action-btn')
|
||||
->rawColumns(['action'])
|
||||
->toJson();
|
||||
}
|
||||
|
||||
return view('admin::countries.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create Country';
|
||||
$data['editable'] = false;
|
||||
return view('admin::countries.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->country->create($request->all());
|
||||
return redirect()->route('country.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('admin::countries.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Edit Country';
|
||||
$data['editable'] = true;
|
||||
$data['country'] = $this->country->getCountryById($id);
|
||||
return view('admin::countries.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$this->country->update($id, $request->except(['_method', '_token']));
|
||||
return redirect()->route('country.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$this->country->delete($id);
|
||||
return response()->json(['status' => 200, 'message' => 'Country has been deleted!'], 200);
|
||||
} catch (\Throwable $th) {
|
||||
return response()->json(['status' => 500, 'message' => 'Country to delete!', 'error' => $th->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
}
|
112
Modules/Admin/app/Http/Controllers/DepartmentController.php
Normal file
112
Modules/Admin/app/Http/Controllers/DepartmentController.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Admin\Models\Department;
|
||||
use Modules\Admin\Repositories\DepartmentRepository;
|
||||
use Modules\Employee\Repositories\EmployeeRepository;
|
||||
|
||||
class DepartmentController extends Controller
|
||||
{
|
||||
private $departmentRepository;
|
||||
private $employeeRepository;
|
||||
|
||||
public function __construct(DepartmentRepository $departmentRepository,
|
||||
EmployeeRepository $employeeRepository) {
|
||||
$this->departmentRepository = $departmentRepository;
|
||||
$this->employeeRepository = $employeeRepository;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// toastr()
|
||||
// ->info('Welcome back')
|
||||
// ->success('Data has been saved successfully!')
|
||||
// ->warning('Are you sure you want to proceed ?');
|
||||
$data['title'] = 'Department List';
|
||||
$data['departmentLists'] = $this->departmentRepository->findAll();
|
||||
return view('admin::departments.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
// toastr('Department has been created!', 'success');
|
||||
$data['title'] = 'Create Department';
|
||||
$data['editable'] = false;
|
||||
$data['employeeLists'] = $this->employeeRepository->pluck();
|
||||
return view('admin::departments.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
// try {
|
||||
$this->departmentRepository->create($request->all());
|
||||
// toastr()->success('Department has been created!');
|
||||
// } catch (\Throwable $th) {
|
||||
// toastr()->error($th->getMessage());
|
||||
// }
|
||||
// toastr('Department has been created!', 'success');
|
||||
// return back();
|
||||
return redirect()->route('department.index')->with('sucess', 'adw');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show(Department $department)
|
||||
{
|
||||
$data['department'] = $department;
|
||||
|
||||
return view('admin::departments.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Edit Department';
|
||||
$data['editable'] = true;
|
||||
$data['employeeLists'] = $this->employeeRepository->pluck();
|
||||
$data['department'] = $this->departmentRepository->getDepartmentById($id);
|
||||
return view('admin::departments.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request,Department $department): RedirectResponse
|
||||
{
|
||||
// dd($request->all())
|
||||
try {
|
||||
$department->update($request->except(['_token', '_method']));
|
||||
// $this->departmentRepository->update($id, $request->except(['_token', '_method']));
|
||||
toastr()->success('Department has been updated!');
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
return redirect()->route('department.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->departmentRepository->delete($id);
|
||||
toastr()->success('Department Deleted Succesfully');
|
||||
|
||||
return response()->json(['status' => true, 'message' => 'Department Delete Succesfully']);
|
||||
}
|
||||
}
|
100
Modules/Admin/app/Http/Controllers/DesignationController.php
Normal file
100
Modules/Admin/app/Http/Controllers/DesignationController.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Admin\Repositories\DesignationRepository;
|
||||
use Modules\Admin\Services\AdminService;
|
||||
|
||||
class DesignationController extends Controller
|
||||
{
|
||||
private $designationRepository;
|
||||
private $adminService;
|
||||
|
||||
public function __construct(DesignationRepository $designationRepository, AdminService $adminService)
|
||||
{
|
||||
$this->designationRepository = $designationRepository;
|
||||
$this->adminService = $adminService;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = 'Designation List';
|
||||
$data['designationLists'] = $this->designationRepository->findAll();
|
||||
return view('admin::designations.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create Designation';
|
||||
$data['editable'] = false;
|
||||
$data['departmentList'] = $this->adminService->pluckDepartments();
|
||||
|
||||
return view('admin::designations.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$data = $request->except(['_method', '_token']);
|
||||
|
||||
$this->designationRepository->create($data);
|
||||
|
||||
flash()->addSuccess('Department Data Created!');
|
||||
return redirect()->route('designation.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('admin::designations.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Edit Designation';
|
||||
$data['editable'] = true;
|
||||
$data['designation'] = $this->designationRepository->getDesignationById($id);
|
||||
$data['departmentList'] = $this->adminService->pluckDepartments();
|
||||
|
||||
return view('admin::designations.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$data = $request->except(['_method', '_token']);
|
||||
$desgination = $this->designationRepository->getDesignationById($id);
|
||||
$desgination->update($data);
|
||||
|
||||
flash()->addSuccess('Department Data Updated!');
|
||||
return redirect()->route('designation.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->designationRepository->delete($id);
|
||||
flash()->addSuccess('Designation Deleted Succesfully');
|
||||
|
||||
return response()->json(['status' => true, 'message' => 'Designation Delete Succesfully']);
|
||||
}
|
||||
}
|
120
Modules/Admin/app/Http/Controllers/DistrictController.php
Normal file
120
Modules/Admin/app/Http/Controllers/DistrictController.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Admin\Models\District;
|
||||
use Modules\Admin\Repositories\ProvinceInterface;
|
||||
use Modules\Admin\Repositories\DistrictInterface;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class DistrictController extends Controller
|
||||
{
|
||||
private $district;
|
||||
private $province;
|
||||
|
||||
public function __construct(DistrictInterface $district, ProvinceInterface $province)
|
||||
{
|
||||
$this->district = $district;
|
||||
$this->province = $province;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$data['title'] = 'District List';
|
||||
|
||||
if ($request->ajax()) {
|
||||
$model = District::query();
|
||||
|
||||
return DataTables::eloquent($model)
|
||||
->setRowId('{{$id}}')
|
||||
->setRowClass('{{"text-center align-middle"}}')
|
||||
->addColumn('province', function(District $district){
|
||||
return $district->province?->name;
|
||||
})
|
||||
->addColumn('action', 'admin::districts.datatables.action-btn')
|
||||
->rawColumns(['province','action'])
|
||||
->toJson();
|
||||
}
|
||||
|
||||
return view('admin::districts.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create District';
|
||||
$data['editable'] = false;
|
||||
$data['provinceLists'] = $this->province->pluck();
|
||||
return view('admin::districts.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$this->district->create($request->all());
|
||||
return redirect()->route('district.index')->with('sucess', 'District has been created!');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return redirect()->back()->withError($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('admin::districts.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Edit District';
|
||||
$data['editable'] = true;
|
||||
$data['district'] = $this->district->getDistrictById($id);
|
||||
$data['provinceLists'] = $this->province->pluck();
|
||||
return view('admin::districts.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
try {
|
||||
$this->district->update($id, $request->except(['_method', '_token']) );
|
||||
return redirect()->route('district.index')->with('success','District has been updated!');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return redirect()->back()->withError($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$this->district->delete($id);
|
||||
return response()->json(['status' => 200, 'message' => 'District has been deleted!'], 200);
|
||||
} catch (\Throwable $th) {
|
||||
return response()->json(['status' => 500, 'message' => 'District to delete!', 'error' => $th->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
}
|
113
Modules/Admin/app/Http/Controllers/DropdownController.php
Normal file
113
Modules/Admin/app/Http/Controllers/DropdownController.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Admin\Repositories\DropdownInterface;
|
||||
use Modules\Admin\Repositories\FieldInterface;
|
||||
|
||||
class DropdownController extends Controller
|
||||
{
|
||||
private $fieldRepository;
|
||||
private $dropdownRepository;
|
||||
|
||||
public function __construct(FieldInterface $fieldRepository,
|
||||
DropdownInterface $dropdownRepository) {
|
||||
$this->fieldRepository = $fieldRepository;
|
||||
$this->dropdownRepository = $dropdownRepository;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['editable'] = false;
|
||||
$data['title'] = 'Dropdown List';
|
||||
$data['fields'] = $this->fieldRepository->findAll();
|
||||
$data['fieldLists'] = $data['fields']->pluck('title', 'id');
|
||||
|
||||
return view('admin::dropdown.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('admin::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$inputData = $request->all();
|
||||
try {
|
||||
// $inputData['status'] = $request->status ?? 10;
|
||||
$this->dropdownRepository->create($inputData);
|
||||
toastr()->success('Dropdown Created Succesfully');
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
return redirect()->route('dropdown.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('admin::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$editable = true;
|
||||
$dropdownModel = $this->dropdownRepository->getDropdownById($id);
|
||||
$fieldLists = $this->fieldRepository->getList();
|
||||
|
||||
return response()->json([
|
||||
'view' => view('admin::dropdown.edit', compact('dropdownModel', 'fieldLists', 'editable'))->render(),
|
||||
'status' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$inputData = $request->except(['_method', '_token']);
|
||||
|
||||
try {
|
||||
$inputData['status'] = $request->status ?? 10;
|
||||
$this->dropdownRepository->update($id, $inputData);
|
||||
toastr()->success('Dropdown Update Succesfully');
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
return redirect()->route('dropdown.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$this->dropdownRepository->delete($id);
|
||||
toastr()->success('Dropdown Deleted Succesfully');
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
]);
|
||||
}
|
||||
}
|
83
Modules/Admin/app/Http/Controllers/FieldController.php
Normal file
83
Modules/Admin/app/Http/Controllers/FieldController.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Admin\Repositories\DropdownInterface;
|
||||
use Modules\Admin\Repositories\FieldInterface;
|
||||
|
||||
class FieldController extends Controller
|
||||
{
|
||||
private $fieldRepository;
|
||||
private $dropdownRepository;
|
||||
|
||||
public function __construct(FieldInterface $fieldRepository,
|
||||
DropdownInterface $dropdownRepository) {
|
||||
$this->fieldRepository = $fieldRepository;
|
||||
$this->dropdownRepository = $dropdownRepository;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('admin::index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('admin::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$inputData = $request->all();
|
||||
try {
|
||||
$this->fieldRepository->create($inputData);
|
||||
toastr()->success('Field Created Succesfully');
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
return redirect()->route('dropdown.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('admin::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('admin::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
27
Modules/Admin/app/Http/Controllers/FileController.php
Normal file
27
Modules/Admin/app/Http/Controllers/FileController.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class FileController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function upload()
|
||||
{
|
||||
if (request()->hasFile('upload')) {
|
||||
$file = request()->file('upload');
|
||||
$path = 'uploads/ckeditor';
|
||||
$imagePath = uploadImage($file, $path);
|
||||
$CKEditorFuncNum = request()->input('CKEditorFuncNum');
|
||||
$url = asset('storage/' . $imagePath);
|
||||
$response = "<script>window.parent.CKEDITOR.tools.callFunction($CKEditorFuncNum, '$url')</script>";
|
||||
echo $response;
|
||||
}
|
||||
}
|
||||
}
|
119
Modules/Admin/app/Http/Controllers/MunicipalityController.php
Normal file
119
Modules/Admin/app/Http/Controllers/MunicipalityController.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Admin\Models\Municipality;
|
||||
use Modules\Admin\Repositories\DistrictInterface;
|
||||
use Modules\Admin\Repositories\MunicipalityInterface;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class MunicipalityController extends Controller
|
||||
{
|
||||
private $municipality;
|
||||
private $district;
|
||||
|
||||
public function __construct(MunicipalityInterface $municipality, DistrictInterface $district)
|
||||
{
|
||||
$this->municipality = $municipality;
|
||||
$this->district = $district;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$data['title'] = 'Municipality List';
|
||||
|
||||
if ($request->ajax()) {
|
||||
$model = Municipality::query();
|
||||
|
||||
return DataTables::eloquent($model)
|
||||
->setRowId('{{$id}}')
|
||||
->setRowClass('{{"text-center align-middle"}}')
|
||||
->addColumn('district', function (Municipality $municipality) {
|
||||
return $municipality->district?->name;
|
||||
})
|
||||
->addColumn('action', 'admin::municipalities.datatables.action-btn')
|
||||
->rawColumns(['district', 'action'])
|
||||
->toJson();
|
||||
}
|
||||
return view('admin::municipalities.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create Municipality';
|
||||
$data['editable'] = false;
|
||||
$data['districtLists'] = $this->district->pluck();
|
||||
return view('admin::municipalities.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$this->municipality->create($request->all());
|
||||
return redirect()->route('municipality.index')->with('sucess', 'Municipality has been created!');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return redirect()->back()->withError($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('admin::municipalities.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Edit Municipality';
|
||||
$data['editable'] = true;
|
||||
$data['municipality'] = $this->municipality->getMunicipalityById($id);
|
||||
$data['districtLists'] = $this->district->pluck();
|
||||
return view('admin::municipalities.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$this->municipality->update($id, $request->except(['_method', '_token']));
|
||||
return redirect()->route('municipality.index')->with('success', 'Municipality has been updated!');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return redirect()->back()->withError($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$this->municipality->delete($id);
|
||||
return response()->json(['status' => 200, 'message' => 'Municipality has been deleted!'], 200);
|
||||
} catch (\Throwable $th) {
|
||||
return response()->json(['status' => 500, 'message' => 'Municipality to delete!', 'error' => $th->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class NotificationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$data['notifications'] = auth()->user()->notifications;
|
||||
return view('notification.index', $data);
|
||||
}
|
||||
|
||||
public function markAsRead(Request $request)
|
||||
{
|
||||
$filterData = $request->all();
|
||||
try {
|
||||
$notification = auth()->user()->notifications()->where('id', $filterData['id'])->first();
|
||||
if ($notification) {
|
||||
$notification->markAsRead();
|
||||
}
|
||||
return redirect()->back()->withSuccess('Mark As Read');
|
||||
} catch (\Throwable $th) {
|
||||
return redirect()->back()->withError('Something Went Wrong!');
|
||||
}
|
||||
}
|
||||
|
||||
public function markAllAsRead(Request $request)
|
||||
{
|
||||
try {
|
||||
foreach (auth()->user()->unreadNotifications as $notification) {
|
||||
$notification->markAsRead();
|
||||
}
|
||||
return redirect()->back()->withSuccess('Mark All As Read');
|
||||
} catch (\Throwable $th) {
|
||||
//throw $th;
|
||||
return redirect()->back()->withError('Something Went Wrong!');
|
||||
}
|
||||
}
|
||||
}
|
120
Modules/Admin/app/Http/Controllers/ProvinceController.php
Normal file
120
Modules/Admin/app/Http/Controllers/ProvinceController.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Admin\Models\Province;
|
||||
use Modules\Admin\Repositories\CountryInterface;
|
||||
use Modules\Admin\Repositories\ProvinceInterface;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class ProvinceController extends Controller
|
||||
{
|
||||
private $province;
|
||||
private $country;
|
||||
|
||||
public function __construct(ProvinceInterface $province, CountryInterface $country)
|
||||
{
|
||||
$this->province = $province;
|
||||
$this->country = $country;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$data['title'] = 'Province List';
|
||||
|
||||
if ($request->ajax()) {
|
||||
$model = Province::query();
|
||||
|
||||
return DataTables::eloquent($model)
|
||||
->setRowId('{{$id}}')
|
||||
->setRowClass('{{"text-center align-middle"}}')
|
||||
->addColumn('country', function(Province $province){
|
||||
return $province?->country?->name;
|
||||
})
|
||||
->addColumn('action', 'admin::provinces.datatables.action-btn')
|
||||
->rawColumns(['country','action'])
|
||||
->toJson();
|
||||
}
|
||||
|
||||
return view('admin::provinces.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create Province';
|
||||
$data['editable'] = false;
|
||||
$data['countryLists'] = $this->country->pluck();
|
||||
return view('admin::provinces.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$this->province->create($request->all());
|
||||
return redirect()->route('province.index')->with('sucess', 'Province has been created!');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return redirect()->back()->withError($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('admin::provinces.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Edit Province';
|
||||
$data['editable'] = true;
|
||||
$data['province'] = $this->province->getProvinceById($id);
|
||||
$data['countryLists'] = $this->country->pluck();
|
||||
return view('admin::provinces.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$this->province->update($id, $request->except(['_method', '_token']) );
|
||||
return redirect()->route('province.index')->with('success','Province has been updated!');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return redirect()->back()->withError($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$this->province->delete($id);
|
||||
return response()->json(['status' => 200, 'message' => 'Province has been deleted!'], 200);
|
||||
} catch (\Throwable $th) {
|
||||
return response()->json(['status' => 500, 'message' => 'Province to delete!', 'error' => $th->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
}
|
63
Modules/Admin/app/Http/Controllers/SettingController.php
Normal file
63
Modules/Admin/app/Http/Controllers/SettingController.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
use Cache;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Admin\Models\Setting;
|
||||
use Modules\Admin\Repositories\SettingInterface;
|
||||
|
||||
class SettingController extends Controller
|
||||
{
|
||||
private $setting;
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
|
||||
public function __construct(SettingInterface $setting)
|
||||
{
|
||||
$this->setting = $setting;
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = "Edit Setting";
|
||||
$data['editable'] = true;
|
||||
$data['setting'] = $this->setting->findAll();
|
||||
|
||||
return view('admin::settings.edit', $data);
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$input = $request->except([
|
||||
'_method',
|
||||
'_token',
|
||||
]);
|
||||
if ($request->hasFile('logo_pic')) {
|
||||
$input['logo_pic'] = uploadImage($request->logo_pic);
|
||||
}
|
||||
|
||||
foreach ($input as $key => $item) {
|
||||
$finalInput = [
|
||||
'key' => $key,
|
||||
'value' => $item,
|
||||
];
|
||||
Setting::updateOrInsert(['key' => $key], $finalInput);
|
||||
|
||||
}
|
||||
Cache::has('setting') ? Cache::forget('setting') : '';
|
||||
return redirect()->route('setting.index')->with('success', 'Setting Updated');
|
||||
} catch (\Throwable $th) {
|
||||
return redirect()->back()->withError($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->setting->delete($id);
|
||||
return response()->json(['status' => true]);
|
||||
}
|
||||
}
|
0
Modules/Admin/app/Http/Requests/.gitkeep
Normal file
0
Modules/Admin/app/Http/Requests/.gitkeep
Normal file
0
Modules/Admin/app/Models/.gitkeep
Normal file
0
Modules/Admin/app/Models/.gitkeep
Normal file
25
Modules/Admin/app/Models/City.php
Normal file
25
Modules/Admin/app/Models/City.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Admin\Database\factories\CityFactory;
|
||||
|
||||
class City extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'district_id',
|
||||
'status',
|
||||
'description',
|
||||
'remarks',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
];
|
||||
}
|
31
Modules/Admin/app/Models/District.php
Normal file
31
Modules/Admin/app/Models/District.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class District extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'province_id',
|
||||
'status',
|
||||
'description',
|
||||
'remarks',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
];
|
||||
|
||||
protected function province()
|
||||
{
|
||||
|
||||
return $this->belongsTo(Province::class, 'province_id');
|
||||
}
|
||||
|
||||
}
|
29
Modules/Admin/app/Models/Dropdown.php
Normal file
29
Modules/Admin/app/Models/Dropdown.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Models;
|
||||
|
||||
use App\Traits\StatusTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Str;
|
||||
|
||||
class Dropdown extends Model
|
||||
{
|
||||
use StatusTrait;
|
||||
|
||||
protected $fillable = ['fid', 'title', 'alias', 'status'];
|
||||
protected $appends = ['status_name'];
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function ($field) {
|
||||
$field->alias = Str::slug($field->title);
|
||||
});
|
||||
|
||||
static::updating(function ($field) {
|
||||
$field->alias = Str::slug($field->title);
|
||||
});
|
||||
}
|
||||
public function field()
|
||||
{
|
||||
return $this->belongsTo(Field::class, 'fid');
|
||||
}
|
||||
}
|
28
Modules/Admin/app/Models/Field.php
Normal file
28
Modules/Admin/app/Models/Field.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Str;
|
||||
|
||||
class Field extends Model
|
||||
{
|
||||
protected $fillable = ['title', 'alias', 'status'];
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
|
||||
static::creating(function ($field) {
|
||||
$field->alias = Str::slug($field->title);
|
||||
});
|
||||
|
||||
static::updating(function ($field) {
|
||||
$field->alias = Str::slug($field->title);
|
||||
});
|
||||
}
|
||||
|
||||
public function dropdown()
|
||||
{
|
||||
return $this->hasMany(Dropdown::class, 'fid');
|
||||
}
|
||||
}
|
33
Modules/Admin/app/Models/Holiday.php
Normal file
33
Modules/Admin/app/Models/Holiday.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Models;
|
||||
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use App\Traits\StatusTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Holiday extends Model
|
||||
{
|
||||
use CreatedUpdatedBy, StatusTrait;
|
||||
|
||||
protected $table = 'holidays';
|
||||
protected $primaryKey = "holiday_id";
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'status',
|
||||
'description',
|
||||
'remarks',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'start_date' => 'datetime',
|
||||
'end_date' => 'datetime',
|
||||
];
|
||||
|
||||
public $appends = ['status_name'];
|
||||
}
|
31
Modules/Admin/app/Models/Municipality.php
Normal file
31
Modules/Admin/app/Models/Municipality.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Admin\Database\factories\MunicipalityFactory;
|
||||
|
||||
class Municipality extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'distict_id',
|
||||
'status',
|
||||
'description',
|
||||
'remarks',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
];
|
||||
|
||||
protected function district()
|
||||
{
|
||||
return $this->belongsTo(District::class, 'district_id');
|
||||
}
|
||||
|
||||
}
|
32
Modules/Admin/app/Models/Province.php
Normal file
32
Modules/Admin/app/Models/Province.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Modules\Admin\Database\factories\ProvinceFactory;
|
||||
|
||||
class Province extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'country_id',
|
||||
'status',
|
||||
'description',
|
||||
'remarks',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
];
|
||||
|
||||
protected function country()
|
||||
{
|
||||
return $this->belongsTo(Country::class, 'country_id');
|
||||
}
|
||||
|
||||
}
|
0
Modules/Admin/app/Providers/.gitkeep
Normal file
0
Modules/Admin/app/Providers/.gitkeep
Normal file
143
Modules/Admin/app/Providers/AdminServiceProvider.php
Normal file
143
Modules/Admin/app/Providers/AdminServiceProvider.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Admin\Repositories\CalendarRepository;
|
||||
use Modules\Admin\Repositories\CountryInterface;
|
||||
use Modules\Admin\Repositories\CountryRepository;
|
||||
use Modules\Admin\Repositories\DepartmentInterface;
|
||||
use Modules\Admin\Repositories\DepartmentRepository;
|
||||
use Modules\Admin\Repositories\DesignationInterface;
|
||||
use Modules\Admin\Repositories\DesignationRepository;
|
||||
use Modules\Admin\Repositories\DistrictInterface;
|
||||
use Modules\Admin\Repositories\DistrictRepository;
|
||||
use Modules\Admin\Repositories\DropdownInterface;
|
||||
use Modules\Admin\Repositories\DropdownRepository;
|
||||
use Modules\Admin\Repositories\FieldInterface;
|
||||
use Modules\Admin\Repositories\FieldRepository;
|
||||
use Modules\Admin\Repositories\MunicipalityInterface;
|
||||
use Modules\Admin\Repositories\MunicipalityRepository;
|
||||
use Modules\Admin\Repositories\ProvinceInterface;
|
||||
use Modules\Admin\Repositories\ProvinceRepository;
|
||||
use Modules\Admin\Repositories\SettingInterface;
|
||||
use Modules\Admin\Repositories\SettingRepository;
|
||||
|
||||
class AdminServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $moduleName = 'Admin';
|
||||
|
||||
protected string $moduleNameLower = 'admin';
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerCommands();
|
||||
$this->registerCommandSchedules();
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->bind(SettingInterface::class, SettingRepository::class);
|
||||
$this->app->bind(FieldInterface::class, FieldRepository::class);
|
||||
$this->app->bind(DropdownInterface::class, DropdownRepository::class);
|
||||
$this->app->bind(CountryInterface::class, CountryRepository::class);
|
||||
$this->app->bind(ProvinceInterface::class, ProvinceRepository::class);
|
||||
$this->app->bind(DistrictInterface::class, DistrictRepository::class);
|
||||
$this->app->bind(MunicipalityInterface::class, MunicipalityRepository::class);
|
||||
$this->app->bind(DepartmentInterface::class, DepartmentRepository::class);
|
||||
$this->app->bind(DesignationInterface::class, DesignationRepository::class);
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register commands in the format of Command::class
|
||||
*/
|
||||
protected function registerCommands(): void
|
||||
{
|
||||
// $this->commands([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register command Schedules.
|
||||
*/
|
||||
protected function registerCommandSchedules(): void
|
||||
{
|
||||
// $this->app->booted(function () {
|
||||
// $schedule = $this->app->make(Schedule::class);
|
||||
// $schedule->command('inspire')->hourly();
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*/
|
||||
public function registerTranslations(): void
|
||||
{
|
||||
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom($langPath);
|
||||
} else {
|
||||
$this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*/
|
||||
protected function registerConfig(): void
|
||||
{
|
||||
$this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower . '.php')], 'config');
|
||||
$this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*/
|
||||
public function registerViews(): void
|
||||
{
|
||||
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
|
||||
$sourcePath = module_path($this->moduleName, 'resources/views');
|
||||
|
||||
$this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower . '-module-views']);
|
||||
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
|
||||
|
||||
$componentNamespace = str_replace('/', '\\', config('modules.namespace') . '\\' . $this->moduleName . '\\' . ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', '')));
|
||||
Blade::componentNamespace($componentNamespace, $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function getPublishableViewPaths(): array
|
||||
{
|
||||
$paths = [];
|
||||
foreach (config('view.paths') as $path) {
|
||||
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
|
||||
$paths[] = $path . '/modules/' . $this->moduleNameLower;
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
}
|
49
Modules/Admin/app/Providers/RouteServiceProvider.php
Normal file
49
Modules/Admin/app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Called before routes are registered.
|
||||
*
|
||||
* Register any model bindings or pattern based filters.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*/
|
||||
public function map(): void
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*/
|
||||
protected function mapWebRoutes(): void
|
||||
{
|
||||
Route::middleware('web')->group(module_path('Admin', '/routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*/
|
||||
protected function mapApiRoutes(): void
|
||||
{
|
||||
Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Admin', '/routes/api.php'));
|
||||
}
|
||||
}
|
0
Modules/Admin/app/Repositories/.gitkeep
Normal file
0
Modules/Admin/app/Repositories/.gitkeep
Normal file
35
Modules/Admin/app/Repositories/CalendarRepository.php
Normal file
35
Modules/Admin/app/Repositories/CalendarRepository.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
use Modules\Admin\Models\Calendar;
|
||||
|
||||
|
||||
class CalendarRepository implements CalendarInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Calendar::get();
|
||||
}
|
||||
|
||||
public function getCalendarById($CalendarId)
|
||||
{
|
||||
return Calendar::findOrFail($CalendarId);
|
||||
}
|
||||
|
||||
public function delete($CalendarId)
|
||||
{
|
||||
Calendar::destroy($CalendarId);
|
||||
}
|
||||
|
||||
public function create(array $CalendarDetails)
|
||||
{
|
||||
return Calendar::create($CalendarDetails);
|
||||
}
|
||||
|
||||
public function update($CalendarId, array $newDetails)
|
||||
{
|
||||
return Calendar::where('id', $CalendarId)->update($newDetails);
|
||||
}
|
||||
|
||||
}
|
12
Modules/Admin/app/Repositories/CityInterface.php
Normal file
12
Modules/Admin/app/Repositories/CityInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
interface CityInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getCityById($cityId);
|
||||
public function delete($cityId);
|
||||
public function create(array $cityDetails);
|
||||
public function update($cityId, array $newDetails);
|
||||
}
|
35
Modules/Admin/app/Repositories/CityRepository.php
Normal file
35
Modules/Admin/app/Repositories/CityRepository.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
use Modules\Admin\Models\City;
|
||||
|
||||
|
||||
class CityRepository implements CityInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return City::get();
|
||||
}
|
||||
|
||||
public function getCityById($cityId)
|
||||
{
|
||||
return City::findOrFail($cityId);
|
||||
}
|
||||
|
||||
public function delete($cityId)
|
||||
{
|
||||
City::destroy($cityId);
|
||||
}
|
||||
|
||||
public function create(array $cityDetails)
|
||||
{
|
||||
return City::create($cityDetails);
|
||||
}
|
||||
|
||||
public function update($cityId, array $newDetails)
|
||||
{
|
||||
return City::where('id', $cityId)->update($newDetails);
|
||||
}
|
||||
|
||||
}
|
13
Modules/Admin/app/Repositories/CountryInterface.php
Normal file
13
Modules/Admin/app/Repositories/CountryInterface.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
interface CountryInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getCountryById($countryId);
|
||||
public function delete($countryId);
|
||||
public function create(array $countryDetails);
|
||||
public function update($countryId, array $newDetails);
|
||||
public function pluck();
|
||||
}
|
39
Modules/Admin/app/Repositories/CountryRepository.php
Normal file
39
Modules/Admin/app/Repositories/CountryRepository.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
use Modules\Admin\Models\Country;
|
||||
|
||||
|
||||
class CountryRepository implements CountryInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Country::get();
|
||||
}
|
||||
|
||||
public function getCountryById($countryId)
|
||||
{
|
||||
return Country::findOrFail($countryId);
|
||||
}
|
||||
|
||||
public function delete($countryId)
|
||||
{
|
||||
Country::destroy($countryId);
|
||||
}
|
||||
|
||||
public function create(array $countryDetails)
|
||||
{
|
||||
return Country::create($countryDetails);
|
||||
}
|
||||
|
||||
public function update($countryId, array $newDetails)
|
||||
{
|
||||
return Country::where('id', $countryId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function pluck(){
|
||||
return Country::pluck('name','id');
|
||||
}
|
||||
|
||||
}
|
13
Modules/Admin/app/Repositories/DepartmentInterface.php
Normal file
13
Modules/Admin/app/Repositories/DepartmentInterface.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
interface DepartmentInterface
|
||||
{
|
||||
public function pluck();
|
||||
public function findAll();
|
||||
public function getDepartmentById($departmentId);
|
||||
public function delete($departmentId);
|
||||
public function create(array $departmentDetails);
|
||||
public function update($departmentId, array $newDetails);
|
||||
}
|
46
Modules/Admin/app/Repositories/DepartmentRepository.php
Normal file
46
Modules/Admin/app/Repositories/DepartmentRepository.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
use Modules\Admin\Models\Department;
|
||||
|
||||
|
||||
class DepartmentRepository implements DepartmentInterface
|
||||
{
|
||||
protected $model;
|
||||
|
||||
public function __construct(Department $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function findAll()
|
||||
{
|
||||
return Department::get();
|
||||
}
|
||||
|
||||
public function getDepartmentById($departmentId)
|
||||
{
|
||||
return Department::findOrFail($departmentId);
|
||||
}
|
||||
|
||||
public function delete($departmentId)
|
||||
{
|
||||
Department::destroy($departmentId);
|
||||
}
|
||||
|
||||
public function create(array $departmentDetails)
|
||||
{
|
||||
return Department::create($departmentDetails);
|
||||
}
|
||||
|
||||
public function update($departmentId, array $newDetails)
|
||||
{
|
||||
return Department::where('department_id', $departmentId)->update($newDetails);
|
||||
}
|
||||
|
||||
|
||||
public function pluck(){
|
||||
return Department::pluck('name','id');
|
||||
}
|
||||
}
|
14
Modules/Admin/app/Repositories/DesignationInterface.php
Normal file
14
Modules/Admin/app/Repositories/DesignationInterface.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
interface DesignationInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getDesignationById($designationId);
|
||||
public function delete($designationId);
|
||||
public function create(array $designationDetails);
|
||||
public function update($designationId, array $newDetails);
|
||||
|
||||
public function pluck();
|
||||
}
|
39
Modules/Admin/app/Repositories/DesignationRepository.php
Normal file
39
Modules/Admin/app/Repositories/DesignationRepository.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
use Modules\Admin\Models\Designation;
|
||||
|
||||
|
||||
class DesignationRepository implements DesignationInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Designation::get();
|
||||
}
|
||||
|
||||
public function getDesignationById($designationId)
|
||||
{
|
||||
return Designation::findOrFail($designationId);
|
||||
}
|
||||
|
||||
public function delete($designationId)
|
||||
{
|
||||
Designation::destroy($designationId);
|
||||
}
|
||||
|
||||
public function create(array $designationDetails)
|
||||
{
|
||||
return Designation::create($designationDetails);
|
||||
}
|
||||
|
||||
public function update($designationId, array $newDetails)
|
||||
{
|
||||
return Designation::where('designation_id', $designationId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function pluck(){
|
||||
return Designation::pluck('name','id');
|
||||
}
|
||||
|
||||
}
|
13
Modules/Admin/app/Repositories/DistrictInterface.php
Normal file
13
Modules/Admin/app/Repositories/DistrictInterface.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
interface DistrictInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getDistrictById($districtId);
|
||||
public function delete($districtId);
|
||||
public function create(array $districtDetails);
|
||||
public function update($districtId, array $newDetails);
|
||||
public function pluck();
|
||||
}
|
37
Modules/Admin/app/Repositories/DistrictRepository.php
Normal file
37
Modules/Admin/app/Repositories/DistrictRepository.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
use Modules\Admin\Models\District;
|
||||
|
||||
|
||||
class DistrictRepository implements DistrictInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return District::get();
|
||||
}
|
||||
|
||||
public function getDistrictById($districtId)
|
||||
{
|
||||
return District::findOrFail($districtId);
|
||||
}
|
||||
|
||||
public function delete($districtId)
|
||||
{
|
||||
District::destroy($districtId);
|
||||
}
|
||||
|
||||
public function create(array $districtDetails)
|
||||
{
|
||||
return District::create($districtDetails);
|
||||
}
|
||||
|
||||
public function update($districtId, array $newDetails)
|
||||
{
|
||||
return District::where('id', $districtId)->update($newDetails);
|
||||
}
|
||||
public function pluck(){
|
||||
return District::pluck('name');
|
||||
}
|
||||
}
|
12
Modules/Admin/app/Repositories/DropdownInterface.php
Normal file
12
Modules/Admin/app/Repositories/DropdownInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
interface DropdownInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getDropdownById($DropdownId);
|
||||
public function delete($DropdownId);
|
||||
public function create(array $DropdownDetails);
|
||||
public function update($DropdownId, array $newDetails);
|
||||
}
|
34
Modules/Admin/app/Repositories/DropdownRepository.php
Normal file
34
Modules/Admin/app/Repositories/DropdownRepository.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
use Modules\Admin\Models\Dropdown;
|
||||
|
||||
class DropdownRepository implements DropdownInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Dropdown::get();
|
||||
}
|
||||
|
||||
public function getDropdownById($DropdownId)
|
||||
{
|
||||
return Dropdown::findOrFail($DropdownId);
|
||||
}
|
||||
|
||||
public function delete($DropdownId)
|
||||
{
|
||||
Dropdown::destroy($DropdownId);
|
||||
}
|
||||
|
||||
public function create(array $DropdownDetails)
|
||||
{
|
||||
return Dropdown::create($DropdownDetails);
|
||||
}
|
||||
|
||||
public function update($DropdownId, array $newDetails)
|
||||
{
|
||||
return Dropdown::where('id', $DropdownId)->update($newDetails);
|
||||
}
|
||||
|
||||
}
|
12
Modules/Admin/app/Repositories/EventInterface.php
Normal file
12
Modules/Admin/app/Repositories/EventInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
interface EventInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getEventById($eventId);
|
||||
public function delete($eventId);
|
||||
public function create(array $eventDetails);
|
||||
public function update($eventId, array $newDetails);
|
||||
}
|
35
Modules/Admin/app/Repositories/EventRepository.php
Normal file
35
Modules/Admin/app/Repositories/EventRepository.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
use Modules\Admin\Models\Event;
|
||||
|
||||
|
||||
class EventRepository implements EventInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Event::get();
|
||||
}
|
||||
|
||||
public function getEventById($EventId)
|
||||
{
|
||||
return Event::findOrFail($EventId);
|
||||
}
|
||||
|
||||
public function delete($EventId)
|
||||
{
|
||||
Event::destroy($EventId);
|
||||
}
|
||||
|
||||
public function create(array $EventDetails)
|
||||
{
|
||||
return Event::create($EventDetails);
|
||||
}
|
||||
|
||||
public function update($EventId, array $newDetails)
|
||||
{
|
||||
return Event::where('id', $EventId)->update($newDetails);
|
||||
}
|
||||
|
||||
}
|
14
Modules/Admin/app/Repositories/FieldInterface.php
Normal file
14
Modules/Admin/app/Repositories/FieldInterface.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
interface FieldInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getFieldById($FieldId);
|
||||
public function getList();
|
||||
public function getDropdownByAlias($alias);
|
||||
public function delete($FieldId);
|
||||
public function create(array $FieldDetails);
|
||||
public function update($FieldId, array $newDetails);
|
||||
}
|
48
Modules/Admin/app/Repositories/FieldRepository.php
Normal file
48
Modules/Admin/app/Repositories/FieldRepository.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
use Modules\Admin\Models\Field;
|
||||
|
||||
class FieldRepository implements FieldInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Field::get();
|
||||
}
|
||||
|
||||
public function getFieldById($FieldId)
|
||||
{
|
||||
return Field::findOrFail($FieldId);
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return Field::pluck('title', 'id');
|
||||
}
|
||||
|
||||
public function getDropdownByAlias($alias)
|
||||
{
|
||||
$fieldModel = Field::where("alias", $alias)->first();
|
||||
if ($fieldModel) {
|
||||
return $fieldModel->dropdown()->pluck('title', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function delete($FieldId)
|
||||
{
|
||||
Field::destroy($FieldId);
|
||||
}
|
||||
|
||||
public function create(array $FieldDetails)
|
||||
{
|
||||
return Field::create($FieldDetails);
|
||||
}
|
||||
|
||||
public function update($FieldId, array $newDetails)
|
||||
{
|
||||
return Field::where('id', $FieldId)->update($newDetails);
|
||||
}
|
||||
|
||||
}
|
12
Modules/Admin/app/Repositories/MunicipalityInterface.php
Normal file
12
Modules/Admin/app/Repositories/MunicipalityInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
interface MunicipalityInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getMunicipalityById($municipalityId);
|
||||
public function delete($municipalityId);
|
||||
public function create(array $municipalityDetails);
|
||||
public function update($municipalityId, array $newDetails);
|
||||
}
|
35
Modules/Admin/app/Repositories/MunicipalityRepository.php
Normal file
35
Modules/Admin/app/Repositories/MunicipalityRepository.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
use Modules\Admin\Models\Municipality;
|
||||
|
||||
|
||||
class MunicipalityRepository implements MunicipalityInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Municipality::get();
|
||||
}
|
||||
|
||||
public function getMunicipalityById($municipalityId)
|
||||
{
|
||||
return Municipality::findOrFail($municipalityId);
|
||||
}
|
||||
|
||||
public function delete($municipalityId)
|
||||
{
|
||||
Municipality::destroy($municipalityId);
|
||||
}
|
||||
|
||||
public function create(array $municipalityDetails)
|
||||
{
|
||||
return Municipality::create($municipalityDetails);
|
||||
}
|
||||
|
||||
public function update($municipalityId, array $newDetails)
|
||||
{
|
||||
return Municipality::where('id', $municipalityId)->update($newDetails);
|
||||
}
|
||||
|
||||
}
|
13
Modules/Admin/app/Repositories/ProvinceInterface.php
Normal file
13
Modules/Admin/app/Repositories/ProvinceInterface.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
interface ProvinceInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getProvinceById($provinceId);
|
||||
public function delete($provinceId);
|
||||
public function create(array $provinceDetails);
|
||||
public function update($provinceId, array $newDetails);
|
||||
public function pluck();
|
||||
}
|
39
Modules/Admin/app/Repositories/ProvinceRepository.php
Normal file
39
Modules/Admin/app/Repositories/ProvinceRepository.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
use Modules\Admin\Models\Province;
|
||||
|
||||
|
||||
class ProvinceRepository implements ProvinceInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Province::get();
|
||||
}
|
||||
|
||||
public function getProvinceById($provinceId)
|
||||
{
|
||||
return Province::findOrFail($provinceId);
|
||||
}
|
||||
|
||||
public function delete($provinceId)
|
||||
{
|
||||
Province::destroy($provinceId);
|
||||
}
|
||||
|
||||
public function create(array $provinceDetails)
|
||||
{
|
||||
return Province::create($provinceDetails);
|
||||
}
|
||||
|
||||
public function update($provinceId, array $newDetails)
|
||||
{
|
||||
return Province::where('id', $provinceId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function pluck(){
|
||||
return Province::pluck('name', 'id');
|
||||
}
|
||||
|
||||
}
|
15
Modules/Admin/app/Repositories/SettingInterface.php
Normal file
15
Modules/Admin/app/Repositories/SettingInterface.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface SettingInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getSettingById($SettingId);
|
||||
public function getList();
|
||||
public function delete($SettingId);
|
||||
public function create(array $SettingDetails, Request $request);
|
||||
public function update($SettingId, array $newDetails);
|
||||
}
|
53
Modules/Admin/app/Repositories/SettingRepository.php
Normal file
53
Modules/Admin/app/Repositories/SettingRepository.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Admin\Models\Setting;
|
||||
|
||||
class SettingRepository implements SettingInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Setting::get()->mapWithKeys(function ($setting) {
|
||||
return [$setting->key => $setting->value];
|
||||
});
|
||||
}
|
||||
|
||||
public function getSettingById($SettingId)
|
||||
{
|
||||
return Setting::findOrFail($SettingId);
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return Setting::pluck('title', 'id');
|
||||
}
|
||||
|
||||
public function delete($SettingId)
|
||||
{
|
||||
Setting::destroy($SettingId);
|
||||
}
|
||||
public function create(array $settingDetails, Request $request)
|
||||
{
|
||||
$thumbName = time() . '.' . $request->file('thumb')->extension();
|
||||
$logoName = uniqid() . '.' . $request->file('logo')->extension();
|
||||
|
||||
$request->thumb->move(public_path('images/setting'), $thumbName);
|
||||
$request->logo->move(public_path('images/setting'), $logoName);
|
||||
|
||||
$path = 'images/setting/';
|
||||
$settingDetails['logo'] = $path . $logoName;
|
||||
$settingDetails['thumb'] = $path . $thumbName;
|
||||
|
||||
// dd($settingDetails);
|
||||
return Setting::create($settingDetails);
|
||||
}
|
||||
|
||||
public function update($SettingId, $newDetails)
|
||||
{
|
||||
$setting = Setting::where('id', $SettingId);
|
||||
|
||||
$setting->update($newDetails);
|
||||
}
|
||||
}
|
26
Modules/Admin/app/View/Components/MenuComponent.php
Normal file
26
Modules/Admin/app/View/Components/MenuComponent.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class MenuComponent extends Component
|
||||
{
|
||||
private $menu;
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->menu = config('menu');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view/contents that represent the component.
|
||||
*/
|
||||
public function render(): View | string
|
||||
{
|
||||
return view('admin::components.menucomponent');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user