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,174 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\WardManagement\Http\Controllers;
|
||||
|
||||
use Streamline\Models\HmisWard;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class HmisWardController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('permission:hmis-ward-list', ['only' => ['index', 'select']]);
|
||||
$this->middleware('permission:hmis-ward-create', ['only' => ['create', 'store']]);
|
||||
$this->middleware('permission:hmis-ward-edit', ['only' => ['edit', 'update']]);
|
||||
$this->middleware('permission:hmis-ward-delete', ['only' => ['destroy', 'inactive', 'activate']]);
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$wards = HmisWard::orderBy('name', 'asc')->paginate(50);
|
||||
|
||||
return view('ward_management::hmis_wards.index', compact('wards'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('ward_management::hmis_wards.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required|string|max:255|unique:hmis_wards',
|
||||
'slug' => 'required|string|max:255|unique:hmis_wards',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$string = "";
|
||||
foreach ($validator->errors()->getMessages() as $item) {
|
||||
$string .= "{$item[0]}<br>";
|
||||
}
|
||||
flash($string)->error();
|
||||
return back()->withErrors($validator)->withInput();
|
||||
} else {
|
||||
$ward = new HmisWard;
|
||||
$ward->name = $request->name;
|
||||
$ward->slug = $request->slug;
|
||||
$ward->created_by = auth()->user()->id;
|
||||
$ward->save();
|
||||
flash($request->name . " Hmis Ward has been created")->success();
|
||||
return redirect("/hmis_wards/");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$ward = HmisWard::findOrFail($id);
|
||||
return view('ward_management::hmis_wards.edit', compact('ward'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required|string|max:255|unique:hmis_wards,name,'.$id,
|
||||
'slug' => 'required|string|max:255|unique:hmis_wards,slug,'.$id,
|
||||
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$string = "";
|
||||
foreach ($validator->errors()->getMessages() as $item) {
|
||||
$string .= "{$item[0]}<br>";
|
||||
}
|
||||
flash($string)->error();
|
||||
return back()->withErrors($validator)->withInput();
|
||||
} else {
|
||||
$ward = HmisWard::find($id);
|
||||
$ward->name = $request->name;
|
||||
$ward->slug = $request->slug;
|
||||
$ward->updated_by = auth()->user()->id;
|
||||
$ward->save();
|
||||
flash($request->name . " Hmis Ward has been updated")->success();
|
||||
return redirect("/hmis_wards/");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$ward = HmisWard::findOrFail($id);
|
||||
|
||||
if ($ward->delete()) {
|
||||
flash("Hmis Ward has been deleted.")->success();
|
||||
return redirect('/hmis_wards/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the inactive resource(s).
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function inactive()
|
||||
{
|
||||
$wards = HmisWard::onlyTrashed()->orderBy('created_at', 'desc')->paginate(50);
|
||||
|
||||
return view('ward_management::hmis_wards.inactive', compact('wards'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the specified resource in storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function activate($id)
|
||||
{
|
||||
$ward = HmisWard::onlyTrashed()->findOrFail($id);
|
||||
|
||||
if ($ward->restore()) {
|
||||
flash("Hmis Ward has been activated.")->success();
|
||||
return redirect('/hmis_wards/');
|
||||
} else {
|
||||
flash()->error("Hmis Ward hasn't been activated.");
|
||||
return redirect()->route('hmis_wards.inactive');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user