';
})
->make();
}
/**
* Show the form for creating a new resource.
*
* @return type Response
*/
public function create()
{
try {
return view('themes.default1.agent.helpdesk.user.create');
} catch (Exception $e) {
return view('404');
}
}
/**
* Store a newly created resource in storage.
*
* @param type User $user
* @param type Sys_userRequest $request
*
* @return type Response
*/
public function store(User $user, Sys_userRequest $request)
{
try {
/* insert the input request to sys_user table */
/* Check whether function success or not */
$user->email = $request->input('email');
$user->user_name = $request->input('full_name');
$user->mobile = $request->input('mobile');
$user->ext = $request->input('ext');
$user->phone_number = $request->input('phone_number');
$user->active = $request->input('active');
$user->internal_note = $request->input('internal_note');
$user->role = 'user';
if ($user->save() == true) {
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Created Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Create');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Create');
}
}
/**
* Display the specified resource.
*
* @param type int $id
* @param type User $user
*
* @return type Response
*/
public function show($id, User $user)
{
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.show', compact('users'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for editing the specified resource.
*
* @param type int $id
* @param type User $user
*
* @return type Response
*/
public function edit($id, User $user)
{
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.edit', compact('users'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Update the specified resource in storage.
*
* @param type int $id
* @param type User $user
* @param type Sys_userUpdate $request
*
* @return type Response
*/
public function update($id, User $user, Sys_userUpdate $request)
{
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
/* Update the value by selected field */
/* Check whether function success or not */
if ($users->fill($request->except('active', 'role', 'is_delete', 'ban'))->save() == true) {
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Updated Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Update');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Update');
}
}
/**
* Remove the specified resource from storage.
*
* @param type int $id
* @param type User $user
*
* @return type Response
*/
public function destroy($id, User $user)
{
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
/* delete the selected field */
/* Check whether function success or not */
if ($users->delete() == true) {
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Deleted Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Delete');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Delete');
}
}
/**
* User Assign Org.
*
* @param type $id
*
* @return type boolean
*/
public function UserAssignOrg($id)
{
$org = Input::get('org');
$user_org = new User_org();
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
return 1;
}
/**
* user create organisation.
*
* @return type value
*/
public function User_Create_Org($id)
{
if (Input::get('website') != null) {
// checking website
$check = Organization::where('website', '=', Input::get('website'))->first();
} else {
$check = null;
}
// checking name
$check2 = Organization::where('name', '=', Input::get('name'))->first();
if (\Input::get('name') == null) {
return 'Name is required';
} elseif ($check2 != null) {
return 'Name should be Unique';
} elseif ($check != null) {
return 'Website should be Unique';
} else {
$org = new Organization();
$org->name = Input::get('name');
$org->phone = Input::get('phone');
$org->website = Input::get('website');
$org->address = Input::get('address');
$org->internal_notes = Input::get('internal');
$org->save();
$user_org = new User_org();
$user_org->org_id = $org->id;
$user_org->user_id = $id;
$user_org->save();
return 0;
}
}
}