mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-12 03:01:32 +00:00
resolved conflicts
This commit is contained in:
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Insurance\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Streamline\Http\Controllers\Controller;
|
||||
use Streamline\Models\Risk;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RiskController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('permission:insurance-risk-list', ['only' => ['index']]);
|
||||
$this->middleware('permission:insurance-risk-create', ['only' => ['create', 'store']]);
|
||||
$this->middleware('permission:insurance-risk-edit', ['only' => ['edit', 'update']]);
|
||||
$this->middleware('permission:insurance-risk-delete', ['only' => ['destroy', 'inactive', 'activate']]);
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$risks = Risk::all();
|
||||
return view('insurance::risks.index', compact('risks'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('insurance::risks.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'code' => 'required|max:8|unique:community_health_insurance_risks',
|
||||
'name' => 'required|max:30',
|
||||
'factor' => 'required',
|
||||
'amount' => 'required'
|
||||
]);
|
||||
$validatedData['created_by'] = Auth::user()->id;
|
||||
Risk::create($validatedData);
|
||||
return redirect()->route('risks.index')->with('success','Risk created successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$risk = Risk::findOrFail($id);
|
||||
return view('insurance::risks.show', compact('risk'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$risk = Risk::findOrFail($id);
|
||||
return view('insurance::risks.edit', compact('risk'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$risk = Risk::findOrFail($id);
|
||||
$validatedData = $request->validate([
|
||||
'code' => 'required|max:8|unique:community_health_insurance_risks,code,'.$id,
|
||||
'name' => 'required|max:30',
|
||||
'factor' => 'required',
|
||||
'amount' => 'required'
|
||||
]);
|
||||
$validatedData['updated_by'] = Auth::user()->id;
|
||||
$risk->update($validatedData);
|
||||
return redirect()->route('risks.index')->with('success','Risk updated successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$risk = Risk::findOrFail($id);
|
||||
$risk->delete();
|
||||
|
||||
return redirect()->route('risks.index')->with('success','Risk deleted successfully');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the inactive resource(s).
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function inactive()
|
||||
{
|
||||
$risks = Risk::onlyTrashed()->get();
|
||||
return view('insurance::risks.inactive', compact('risks'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the specified resource in storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function activate($id)
|
||||
{
|
||||
$risk = Risk::onlyTrashed()->findOrFail($id);
|
||||
|
||||
if ($risk->restore()) return redirect()->route('risks.index')->with('success','Risk Activated successfully');
|
||||
else {
|
||||
flash()->error("Budget hasn't been activated.");
|
||||
return redirect()->route('risks.inactive');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user