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,194 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Insurance\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Streamline\Models\PersonTitle;
|
||||
|
||||
class PersonTitleController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('permission:person-title-list', ['only' => ['index']]);
|
||||
$this->middleware('permission:person-title-detail', ['only' => ['show']]);
|
||||
$this->middleware('permission:person-title-create', ['only' => ['create', 'store']]);
|
||||
$this->middleware('permission:person-title-edit', ['only' => ['edit', 'edit_all', 'update', 'update_all', 'updatePatientEpisode']]);
|
||||
$this->middleware('permission:person-title-delete', ['only' => ['destroy']]);
|
||||
$this->middleware('permission:person-title-status', ['only' => ['activate, inactive']]);
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
*/
|
||||
public function index() {
|
||||
$person_titles = PersonTitle::orderBy('name', 'asc')->paginate(50);
|
||||
|
||||
return view('insurance::person_titles.index', compact('person_titles'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
*/
|
||||
public function create() {
|
||||
return view('insurance::person_titles.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'
|
||||
]);
|
||||
|
||||
if ($validator->fails())
|
||||
{
|
||||
$string = "";
|
||||
foreach ($validator->errors()->getMessages() as $item) {
|
||||
$string .= "{$item[0]}<br>";
|
||||
}
|
||||
flash($string)->error();
|
||||
return back()->withErrors($validator)->withInput();
|
||||
}
|
||||
|
||||
else {
|
||||
$person_title = new PersonTitle;
|
||||
|
||||
$person_title->name = $request->name;
|
||||
$person_title->created_by = Auth::user()->id;
|
||||
$person_title->updated_by = Auth::user()->id;
|
||||
|
||||
try {
|
||||
$person_title->save();
|
||||
flash($request->name . " person_title has been saved")->success();
|
||||
return redirect("/person_titles/");
|
||||
} catch (QueryException $e) {
|
||||
flash("An error occurred")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \Streamline\person_titles $person_titles
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$person_title = PersonTitle::where(['id' => $id])->first();
|
||||
|
||||
if (!$person_title) {
|
||||
flash()->error("There is no such person title");
|
||||
return redirect('/person_titles/');
|
||||
} else {
|
||||
return view('insurance::person_titles.edit', compact('person_title'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Streamline\person_titles $person_titles
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, PersonTitle $person_titles)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required'
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$string = "";
|
||||
foreach ($validator->errors()->getMessages() as $item) {
|
||||
$string .= "{$item[0]}<br>";
|
||||
}
|
||||
//flash($string)->error();
|
||||
return back()->withErrors($validator)->withInput();
|
||||
} else {
|
||||
$logged_in_user_id = Auth::user()->id;
|
||||
|
||||
$person_title = PersonTitle::find($request->id);
|
||||
$person_title->name = $request->name;
|
||||
$person_title->updated_by = $logged_in_user_id;
|
||||
|
||||
try {
|
||||
$person_title->save();
|
||||
flash($request->name . " person title has been updated")->success();
|
||||
return redirect("/person_titles/");
|
||||
} catch (QueryException $e) {
|
||||
flash("An error occurred")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \Streamline\person_titles $person_titles
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$person_title = PersonTitle::find($id);
|
||||
|
||||
if ($person_title->delete()):
|
||||
flash("person title has been deleted.")->success();
|
||||
return redirect('/person_titles/');
|
||||
endif;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the inactive resource(s).
|
||||
*
|
||||
*/
|
||||
public function inactive()
|
||||
{
|
||||
$person_titles = PersonTitle::onlyTrashed()->orderBy('name', 'asc') ->paginate(50);
|
||||
|
||||
if (count($person_titles) < 1) {
|
||||
flash()->error("There is no inactive person_title");
|
||||
return redirect('/person_titles/');
|
||||
} else {
|
||||
return view('insurance::person_titles.inactive', compact('person_titles'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the specified resource in storage.
|
||||
*
|
||||
*/
|
||||
public function activate($id)
|
||||
{
|
||||
$person_title = PersonTitle::withTrashed()->find($id);
|
||||
|
||||
if ($person_title->restore()):
|
||||
flash("Person title has been activated.")->success();
|
||||
return redirect('/person_titles/inactive');
|
||||
endif;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user