146 lines
3.8 KiB
PHP
146 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Backend;
|
|
|
|
use App\Jobs\Notifications\Sangh\SendApproveSangh;
|
|
use App\Jobs\Notifications\Sangh\SendCreateSanghUser;
|
|
use App\Jobs\Notifications\Sangh\SendRejectSangh;
|
|
use App\Models\Dharma;
|
|
use App\Models\Sampraday;
|
|
use App\Models\Sangh;
|
|
use App\Http\Controllers\BaseController;
|
|
use App\Http\Requests\Sangh\StoreSanghRequest;
|
|
use App\Http\Requests\Sangh\UpdateSanghRequest;
|
|
use App\Models\User;
|
|
use App\Models\UserDetail;
|
|
use App\Repositories\Backend\Sangh\SanghService;
|
|
use Illuminate\Contracts\Foundation\Application;
|
|
use Illuminate\Contracts\View\Factory;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Response;
|
|
|
|
class SanghController extends BaseController
|
|
{
|
|
public function __construct(protected SanghService $sanghService)
|
|
{}
|
|
|
|
/**
|
|
* @return Application|Factory|View
|
|
*/
|
|
public function index()
|
|
{
|
|
return view('backend.sangh.list');
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*
|
|
* @return Response
|
|
*/
|
|
public function create()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param \App\Http\Requests\StoreSanghRequest $request
|
|
* @return Response
|
|
*/
|
|
public function store(StoreSanghRequest $request)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* @param Sangh $sangh
|
|
* @return Application|Factory|View
|
|
*/
|
|
public function show(Request $request, $id)
|
|
{
|
|
|
|
$sangh = $this->sanghService->query()->find($id);
|
|
$sangh->load('dharma', 'sampraday', 'createdBy');
|
|
|
|
$dharma = dharma::all();
|
|
$sampraday = sampraday::all();
|
|
|
|
return view('backend.sangh.detail',compact('sangh', 'dharma', 'sampraday'));
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*
|
|
* @param Sangh $sangh
|
|
* @return Response
|
|
*/
|
|
public function edit(Sangh $sangh)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param \App\Http\Requests\UpdateSanghRequest $request
|
|
* @param Sangh $sangh
|
|
* @return Response
|
|
*/
|
|
public function update(UpdateSanghRequest $request, Sangh $sangh, $id)
|
|
{
|
|
\Log::info('Sangh update started', ['id' => $id, 'status' => $request->status]);
|
|
|
|
$allUser = User::all();
|
|
$user = loggedInUser();
|
|
|
|
$sangh = $this->sanghService->query()->find($id);
|
|
$sangh->name = $request['sangh_name'];
|
|
$sangh->address = $request['sangh_address'];
|
|
$sangh->latitude = $request['latitude'];
|
|
$sangh->longitude = $request['longitude'];
|
|
|
|
if ($request->status === 'Approved') {
|
|
$sangh->sangh_status = 1;
|
|
$sangh->reject_reason = null;
|
|
$sangh->save();
|
|
|
|
dispatch(new SendApproveSangh($user, $sangh));
|
|
dispatch(new SendCreateSanghUser($sangh, $allUser));
|
|
|
|
return redirect(route('admin.sanghs.index'))
|
|
->with('flash_success', __('message.approved_sangh_success'));
|
|
} elseif ($request->status === 'Rejected') {
|
|
$sangh->sangh_status = 2;
|
|
$sangh->reject_reason = $request->reject_reason;
|
|
$sangh->save();
|
|
|
|
dispatch(new SendRejectSangh($user, $sangh));
|
|
|
|
return redirect(route('admin.sanghs.index'))
|
|
->with('flash_success', __('message.reject_sangh_success'));
|
|
} else {
|
|
$sangh->save();
|
|
return redirect(route('admin.sanghs.index'))->with('flash_success', __('Sangh details updated successfully'));
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param Sangh $sangh
|
|
* @return Response
|
|
*/
|
|
public function destroy(Sangh $sangh)
|
|
{
|
|
//
|
|
}
|
|
|
|
public function listing(Request $request)
|
|
{
|
|
return $this->sanghService->getListing($request);
|
|
}
|
|
}
|