196 lines
5.6 KiB
PHP
196 lines
5.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\Backend;
|
||
|
|
|
||
|
|
use App\Constant\Constant;
|
||
|
|
use App\Models\ChaturmasDate;
|
||
|
|
use App\Http\Controllers\BaseController;
|
||
|
|
use App\Http\Requests\ChaturmasDate\StoreChaturmasDateRequest;
|
||
|
|
use App\Http\Requests\ChaturmasDate\UpdateChaturmasDateRequest;
|
||
|
|
use App\Repositories\Backend\ChaturmasDate\ChaturmasDateService;
|
||
|
|
use Exception;
|
||
|
|
use Illuminate\Http\Request;
|
||
|
|
use Illuminate\Support\Facades\Log;
|
||
|
|
|
||
|
|
class ChaturmasDateController extends BaseController
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* @var ChaturmasDateService
|
||
|
|
*/
|
||
|
|
protected $chaturmasDateService;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* ChaturmasDateController constructor.
|
||
|
|
* @param ChaturmasDateService $chaturmasDateService
|
||
|
|
*/
|
||
|
|
public function __construct(ChaturmasDateService $chaturmasDateService)
|
||
|
|
{
|
||
|
|
$this->chaturmasDateService = $chaturmasDateService;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* This function is returning the Datatable columns response
|
||
|
|
*
|
||
|
|
* @param Request $request
|
||
|
|
* @return array|object
|
||
|
|
*/
|
||
|
|
public function getChaturmasDateListing(Request $request)
|
||
|
|
{
|
||
|
|
$response = [];
|
||
|
|
try {
|
||
|
|
$response = $this->chaturmasDateService->getForDataTable($request->all());
|
||
|
|
} catch (Exception $ex) {
|
||
|
|
Log::error($ex->getMessage());
|
||
|
|
}
|
||
|
|
|
||
|
|
return $response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Display a listing of the resource.
|
||
|
|
*
|
||
|
|
* @return \Illuminate\Http\Response
|
||
|
|
*/
|
||
|
|
public function index()
|
||
|
|
{
|
||
|
|
try {
|
||
|
|
|
||
|
|
} catch (Exception $ex) {
|
||
|
|
Log::error($ex->getMessage());
|
||
|
|
}
|
||
|
|
|
||
|
|
return view('backend.chaturmas-date.list');
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Show the form for creating a new resource.
|
||
|
|
*
|
||
|
|
* @return \Illuminate\Http\Response
|
||
|
|
*/
|
||
|
|
public function create()
|
||
|
|
{
|
||
|
|
try {
|
||
|
|
//
|
||
|
|
} catch (Exception $ex) {
|
||
|
|
Log::error($ex->getMessage());
|
||
|
|
}
|
||
|
|
return view('backend.chaturmas-date.create');
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Store a newly created resource in storage.
|
||
|
|
*
|
||
|
|
* @param \App\Http\Requests\StoreChaturmasDateRequest $request
|
||
|
|
* @return \Illuminate\Http\Response
|
||
|
|
*/
|
||
|
|
public function store(StoreChaturmasDateRequest $request)
|
||
|
|
{
|
||
|
|
try {
|
||
|
|
$response = $this->chaturmasDateService->create($request->all());
|
||
|
|
if ($response) {
|
||
|
|
return redirect(route('admin.chaturmas-date.index'))
|
||
|
|
->with('flash_success', __('message.create_chaturmas_date_success'));
|
||
|
|
}
|
||
|
|
} catch (Exception $ex) {
|
||
|
|
Log::error($ex->getMessage());
|
||
|
|
}
|
||
|
|
|
||
|
|
return redirect()->back()->with('flash_error', __('message.create_chaturmas_date_error'));
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Display the specified resource.
|
||
|
|
*
|
||
|
|
* @param \App\Models\ChaturmasDate $chaturmas_date
|
||
|
|
* @return \Illuminate\Http\Response
|
||
|
|
*/
|
||
|
|
public function show(ChaturmasDate $chaturmas_date)
|
||
|
|
{
|
||
|
|
//
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Show the form for editing the specified resource.
|
||
|
|
*
|
||
|
|
* @param \App\Models\ChaturmasDate $chaturmas_date
|
||
|
|
* @return \Illuminate\Http\Response
|
||
|
|
*/
|
||
|
|
public function edit(ChaturmasDate $chaturmas_date)
|
||
|
|
{
|
||
|
|
try {
|
||
|
|
//
|
||
|
|
} catch (Exception $ex) {
|
||
|
|
Log::error($ex->getMessage());
|
||
|
|
}
|
||
|
|
|
||
|
|
return view('backend.chaturmas-date.edit', compact('chaturmas_date'));
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Update the specified resource in storage.
|
||
|
|
*
|
||
|
|
* @param \App\Http\Requests\UpdateChaturmasDateRequest $request
|
||
|
|
* @param \App\Models\ChaturmasDate $chaturmas_date
|
||
|
|
* @return \Illuminate\Http\Response
|
||
|
|
*/
|
||
|
|
public function update(UpdateChaturmasDateRequest $request, ChaturmasDate $chaturmas_date)
|
||
|
|
{
|
||
|
|
try {
|
||
|
|
$response = $this->chaturmasDateService->update($chaturmas_date, $request->all());
|
||
|
|
|
||
|
|
if ($response) {
|
||
|
|
return redirect(route('admin.chaturmas-date.index'))
|
||
|
|
->with('flash_success', __('message.update_chaturmas_date_success'));
|
||
|
|
}
|
||
|
|
} catch (Exception $ex) {
|
||
|
|
Log::error($ex->getMessage());
|
||
|
|
}
|
||
|
|
|
||
|
|
return redirect()->back()->with('flash_error', __('message.update_chaturmas_date_error'));
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Remove the specified resource from storage.
|
||
|
|
*
|
||
|
|
* @param \App\Models\ChaturmasDate $chaturmas_date
|
||
|
|
* @return \Illuminate\Http\Response
|
||
|
|
*/
|
||
|
|
public function destroy(ChaturmasDate $chaturmas_date)
|
||
|
|
{
|
||
|
|
try {
|
||
|
|
|
||
|
|
$response = $chaturmas_date->delete();
|
||
|
|
if ($response) {
|
||
|
|
return response()->json(['success' => Constant::STATUS_TRUE, 'message' => __('message.delete_chaturmas_date_success')]);
|
||
|
|
}
|
||
|
|
} catch (Exception $ex) {
|
||
|
|
Log::error($ex->getMessage());
|
||
|
|
}
|
||
|
|
|
||
|
|
return response()->json(['error' => Constant::STATUS_TRUE, 'message' => __('message.delete_chaturmas_date_error')]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* This function is for the grid checkbox multiple records actions
|
||
|
|
*
|
||
|
|
* @param Request $request
|
||
|
|
* @return JsonResponse
|
||
|
|
*/
|
||
|
|
public function gridRecordsAction(Request $request): JsonResponse
|
||
|
|
{
|
||
|
|
try {
|
||
|
|
$actionType = $request->action_type ?? Constant::NULL;
|
||
|
|
$checkedRecords = $request->checked_records ?? [];
|
||
|
|
$updateStatus = $this->chaturmasDateService->gridActions($actionType, $checkedRecords);
|
||
|
|
|
||
|
|
if ($updateStatus) {
|
||
|
|
return response()->json(['success' => Constant::STATUS_TRUE, 'message' => __('message.update_chaturmas_date_success')]);
|
||
|
|
}
|
||
|
|
} catch (Exception $ex) {
|
||
|
|
Log::error($ex->getMessage());
|
||
|
|
}
|
||
|
|
|
||
|
|
return response()->json(['error' => Constant::STATUS_TRUE, 'message' => __('message.something_went_wrong')]);
|
||
|
|
}
|
||
|
|
}
|