Applied fixes from StyleCI

This commit is contained in:
Sujit Prasad
2016-02-19 02:20:12 -05:00
committed by StyleCI Bot
parent be5df5334f
commit d637c2b23f
439 changed files with 19063 additions and 19210 deletions

View File

@@ -32,24 +32,23 @@ use Input;
use Redirect;
/**
* UserController
* UserController.
*
* @package Controllers
* @subpackage Controller
* @author Ladybird <info@ladybirdweb.com>
*/
class UserController extends Controller {
class UserController extends Controller
{
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* 3. roles must be agent.
*
* @return void
*/
public function __construct() {
public function __construct()
{
$this->middleware('auth');
$this->middleware('role.agent');
// $this->middleware('roles');
@@ -57,10 +56,13 @@ class UserController extends Controller {
/**
* Display a listing of the resource.
*
* @param type User $user
*
* @return type Response
*/
public function index() {
public function index()
{
try {
/* get all values in Sys_user */
return view('themes.default1.agent.helpdesk.user.index');
@@ -70,11 +72,12 @@ class UserController extends Controller {
}
/**
* This function is used to display the list of users
* This function is used to display the list of users.
*
* @return datatable
*/
public function user_list() {
public function user_list()
{
return \Datatable::collection(User::where('role', '!=', 'admin')->where('role', '!=', 'agent')->get())
->searchColumns('user_name')
->orderColumns('user_name', 'email')
@@ -83,18 +86,20 @@ class UserController extends Controller {
})
->addColumn('email', function ($model) {
$email = $model->email;
return $email;
})
->addColumn('phone', function ($model) {
$phone = "";
$phone = '';
if ($model->phone_number) {
$phone = $model->ext . ' ' . $model->phone_number;
$phone = $model->ext.' '.$model->phone_number;
}
$mobile = "";
$mobile = '';
if ($model->mobile) {
$mobile = $model->mobile;
}
$phone = $phone . "&nbsp;&nbsp;&nbsp;" . $mobile;
$phone = $phone.'&nbsp;&nbsp;&nbsp;'.$mobile;
return $phone;
})
->addColumn('status', function ($model) {
@@ -104,17 +109,19 @@ class UserController extends Controller {
} else {
$stat = '<button class="btn btn-danger btn-xs">Inactive</button>';
}
return $stat;
})
->addColumn('lastlogin', function ($model) {
$t = $model->updated_at;
return TicketController::usertimezone($t);
})
->addColumn('Actions', function ($model) {
//return '<a href=article/delete/ ' . $model->id . ' class="btn btn-danger btn-flat" onclick="myFunction()">Delete</a>&nbsp;<a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a>&nbsp;<a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>';
//return '<form action="article/delete/ ' . $model->id . '" method="post" onclick="alert()"><button type="sumbit" value="Delete"></button></form><a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a>&nbsp;<a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>';
return '<span data-toggle="modal" data-target="#deletearticle' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span>&nbsp;<a href="' . route('user.edit', $model->id) . '" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp;<a href="' . route('user.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
<div class="modal fade" id="deletearticle' . $model->id . '">
return '<span data-toggle="modal" data-target="#deletearticle'.$model->id.'"><a href="#" ><button class="btn btn-danger btn-xs"></a> '.\Lang::get('lang.delete').' </button></span>&nbsp;<a href="'.route('user.edit', $model->id).'" class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a>&nbsp;<a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>
<div class="modal fade" id="deletearticle'.$model->id.'">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@@ -122,11 +129,11 @@ class UserController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4>
</div>
<div class="modal-body">
' . $model->user_name . '
'.$model->user_name.'
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
<a href="' . route('user.delete', $model->id) . '"><button class="btn btn-danger">delete</button></a>
<a href="'.route('user.delete', $model->id).'"><button class="btn btn-danger">delete</button></a>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
@@ -137,9 +144,11 @@ class UserController extends Controller {
/**
* Show the form for creating a new resource.
*
* @return type Response
*/
public function create() {
public function create()
{
try {
return view('themes.default1.agent.helpdesk.user.create');
} catch (Exception $e) {
@@ -149,11 +158,14 @@ class UserController extends Controller {
/**
* Store a newly created resource in storage.
* @param type User $user
*
* @param type User $user
* @param type Sys_userRequest $request
*
* @return type Response
*/
public function store(User $user, Sys_userRequest $request) {
public function store(User $user, Sys_userRequest $request)
{
try {
/* insert the input request to sys_user table */
/* Check whether function success or not */
@@ -180,14 +192,18 @@ class UserController extends Controller {
/**
* Display the specified resource.
*
* @param type int $id
* @param type User $user
*
* @return type Response
*/
public function show($id, User $user) {
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');
@@ -196,14 +212,18 @@ class UserController extends Controller {
/**
* Show the form for editing the specified resource.
* @param type int $id
*
* @param type int $id
* @param type User $user
*
* @return type Response
*/
public function edit($id, User $user) {
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');
@@ -212,12 +232,15 @@ class UserController extends Controller {
/**
* Update the specified resource in storage.
* @param type int $id
* @param type User $user
*
* @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) {
public function update($id, User $user, Sys_userUpdate $request)
{
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
@@ -238,11 +261,14 @@ class UserController extends Controller {
/**
* Remove the specified resource from storage.
* @param type int $id
*
* @param type int $id
* @param type User $user
*
* @return type Response
*/
public function destroy($id, User $user) {
public function destroy($id, User $user)
{
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
@@ -262,30 +288,39 @@ class UserController extends Controller {
}
/**
* get profile page
* get profile page.
*
* @return type Response
*/
public function getProfile() {
public function getProfile()
{
$user = Auth::user();
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
}
/**
* get profile edit page
* get profile edit page.
*
* @return type Response
*/
public function getProfileedit() {
public function getProfileedit()
{
$user = Auth::user();
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
}
/**
* post profile page
* @param type int $id
* post profile page.
*
* @param type int $id
* @param type ProfileRequest $request
*
* @return type Response
*/
public function postProfileedit(ProfileRequest $request) {
public function postProfileedit(ProfileRequest $request)
{
$user = Auth::user();
$user->gender = $request->input('gender');
$user->save();
@@ -304,12 +339,13 @@ class UserController extends Controller {
//$extension = Input::file('profile_pic')->getClientOriginalExtension();
$name = Input::file('profile_pic')->getClientOriginalName();
$destinationPath = 'lb-faveo/profilepic';
$fileName = rand(0000, 9999) . '.' . $name;
$fileName = rand(0000, 9999).'.'.$name;
//echo $fileName;
Input::file('profile_pic')->move($destinationPath, $fileName);
$user->profile_pic = $fileName;
} else {
$user->fill($request->except('profile_pic', 'gender'))->save();
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
}
if ($user->fill($request->except('profile_pic'))->save()) {
@@ -318,17 +354,21 @@ class UserController extends Controller {
}
/**
* Post profile password
* @param type int $id
* Post profile password.
*
* @param type int $id
* @param type ProfilePassword $request
*
* @return type Response
*/
public function postProfilePassword($id, ProfilePassword $request) {
public function postProfilePassword($id, ProfilePassword $request)
{
$user = Auth::user();
//echo $user->password;
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
$user->password = Hash::make($request->input('new_password'));
$user->save();
return redirect('profile-edit')->with('success1', 'Password Updated sucessfully');
} else {
return redirect('profile-edit')->with('fails1', 'Password was not Updated. Incorrect old password');
@@ -336,25 +376,30 @@ class UserController extends Controller {
}
/**
* User Assign Org
* @param type $id
* User Assign Org.
*
* @param type $id
*
* @return type boolean
*/
public function UserAssignOrg($id) {
public function UserAssignOrg($id)
{
$org = Input::get('org');
$user_org = new User_org;
$user_org = new User_org();
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
return 1;
}
/**
* user create organisation
* user create organisation.
*
* @return type value
*/
public function User_Create_Org($id) {
public function User_Create_Org($id)
{
if (Input::get('website') != null) {
// checking website
$check = Organization::where('website', '=', Input::get('website'))->first();
@@ -366,13 +411,13 @@ class UserController extends Controller {
$check2 = Organization::where('name', '=', Input::get('name'))->first();
if (\Input::get('name') == null) {
return "Name is required";
return 'Name is required';
} elseif ($check2 != null) {
return "Name should be Unique";
return 'Name should be Unique';
} elseif ($check != null) {
return "Website should be Unique";
return 'Website should be Unique';
} else {
$org = new Organization;
$org = new Organization();
$org->name = Input::get('name');
$org->phone = Input::get('phone');
$org->website = Input::get('website');
@@ -380,7 +425,7 @@ class UserController extends Controller {
$org->internal_notes = Input::get('internal');
$org->save();
$user_org = new User_org;
$user_org = new User_org();
$user_org->org_id = $org->id;
$user_org->user_id = $id;
$user_org->save();
@@ -388,5 +433,4 @@ class UserController extends Controller {
return 0;
}
}
}