update v1.0.5
This commit is contained in:
@@ -1,18 +1,25 @@
|
||||
<?php namespace App\Http\Controllers\Agent\helpdesk;
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\OrganizationRequest;
|
||||
|
||||
/* include organization model */
|
||||
use App\Http\Requests\helpdesk\OrganizationUpdate;
|
||||
|
||||
// models
|
||||
/* Define OrganizationRequest to validate the create form */
|
||||
use App\Model\helpdesk\Agent_panel\Organization;
|
||||
|
||||
/* Define OrganizationUpdate to validate the create form */
|
||||
use App\Model\helpdesk\Agent_panel\User_org_head;
|
||||
use App\Model\helpdesk\Agent_panel\User_org;
|
||||
// classes
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* OrganizationController
|
||||
* This controller is used to CRUD organization detail.
|
||||
*
|
||||
* @package Controllers
|
||||
* @subpackage Controller
|
||||
@@ -26,13 +33,13 @@ class OrganizationController extends Controller {
|
||||
* 1. authentication
|
||||
* 2. user roles
|
||||
* 3. roles must be agent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
// checking for authentication
|
||||
$this->middleware('auth');
|
||||
// checking if the role is agent
|
||||
$this->middleware('role.agent');
|
||||
// $this->middleware('roles');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,47 +61,54 @@ class OrganizationController extends Controller {
|
||||
* @return datatable
|
||||
*/
|
||||
public function org_list() {
|
||||
// chumper datable package call to display Advance datatable
|
||||
return \Datatable::collection(Organization::all())
|
||||
/* searchable name */
|
||||
->searchColumns('name')
|
||||
/* order by name and website */
|
||||
->orderColumns('name', 'website')
|
||||
/* column name */
|
||||
->addColumn('name', function ($model) {
|
||||
return $model->name;
|
||||
})
|
||||
/* column website */
|
||||
->addColumn('website', function ($model) {
|
||||
$website = $model->website;
|
||||
return $website;
|
||||
})
|
||||
/* column phone number */
|
||||
->addColumn('phone', function ($model) {
|
||||
$phone = $model->phone;
|
||||
return $phone;
|
||||
})
|
||||
/* column action buttons */
|
||||
->addColumn('Actions', function ($model) {
|
||||
//return '<a href=article/delete/ ' . $model->id . ' class="btn btn-danger btn-flat" onclick="myFunction()">Delete</a> <a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a> <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> <a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>';
|
||||
// displaying action buttons
|
||||
// modal popup to delete data
|
||||
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> <a href="'.route('organizations.edit', $model->id).'" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a> <a href="'.route('organizations.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">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">Are You Sure ?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
'.$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('org.delete',$model->id).'"><button class="btn btn-danger">delete</button></a>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>';
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">Are You Sure ?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
'.$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('org.delete',$model->id).'"><button class="btn btn-danger">delete</button></a>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>';
|
||||
})
|
||||
->make();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* Show the form for creating a new organization.
|
||||
* @return type Response
|
||||
*/
|
||||
public function create() {
|
||||
@@ -106,10 +120,10 @@ class OrganizationController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* Store a newly created organization in storage.
|
||||
* @param type Organization $org
|
||||
* @param type OrganizationRequest $request
|
||||
* @return type Response
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function store(Organization $org, OrganizationRequest $request) {
|
||||
try {
|
||||
@@ -129,11 +143,10 @@ class OrganizationController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* Display the specified organization.
|
||||
* @param type $id
|
||||
* @param type Organization $org
|
||||
* @return type Response
|
||||
* @return type view
|
||||
*/
|
||||
public function show($id, Organization $org) {
|
||||
try {
|
||||
@@ -142,16 +155,15 @@ class OrganizationController extends Controller {
|
||||
/* To view page */
|
||||
return view('themes.default1.agent.helpdesk.organization.show', compact('orgs'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* Show the form for editing the specified organization.
|
||||
* @param type $id
|
||||
* @param type Organization $org
|
||||
* @return type Response
|
||||
* @return type view
|
||||
*/
|
||||
public function edit($id, Organization $org) {
|
||||
try {
|
||||
@@ -165,63 +177,69 @@ class OrganizationController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* Update the specified organization in storage.
|
||||
* @param type $id
|
||||
* @param type Organization $org
|
||||
* @param type OrganizationUpdate $request
|
||||
* @return type Response
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function update($id, Organization $org, OrganizationUpdate $request) {
|
||||
try {
|
||||
|
||||
/* select the field by id */
|
||||
$orgs = $org->whereId($id)->first();
|
||||
/* update the organization table */
|
||||
/* Check whether function success or not */
|
||||
if ($orgs->fill($request->input())->save() == true) {
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('organizations')->with('success', 'Organization Updated Successfully');
|
||||
} else {
|
||||
try {
|
||||
if ($orgs->fill($request->input())->save() == true) {
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('organizations')->with('success', 'Organization Updated Successfully');
|
||||
} else {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', 'Organization can not Update');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', 'Organization can not Update');
|
||||
return redirect('organizations')->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', 'Organization can not Update');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* Delete a specified organization from storage.
|
||||
* @param type int $id
|
||||
* @return type Response
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function destroy($id, Organization $org) {
|
||||
try {
|
||||
// User_org
|
||||
public function destroy($id, Organization $org, User_org $user_org) {
|
||||
|
||||
/* select the field by id */
|
||||
$orgs = $org->whereId($id)->first();
|
||||
$user_orgs = $user_org->where('org_id','=',$id)->get();
|
||||
foreach ($user_orgs as $user_org) {
|
||||
$user_org->delete();
|
||||
}
|
||||
/* Delete the field selected from the table */
|
||||
/* Check whether function success or not */
|
||||
if ($orgs->delete() == true) {
|
||||
try {
|
||||
$orgs->delete();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('organizations')->with('success', 'Organization Deleted Successfully');
|
||||
} else {
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', 'Organization can not Delete');
|
||||
return redirect('organizations')->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', 'Organization can not Delete');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Soring an organization head
|
||||
* @param type $id
|
||||
* @return type boolean
|
||||
*/
|
||||
public function Head_Org($id){
|
||||
|
||||
// get the user to make organization head
|
||||
$head_user = \Input::get('user');
|
||||
|
||||
// get an instance of the selected organization
|
||||
$org_head = Organization::where('id','=',$id)->first();
|
||||
$org_head->head = $head_user;
|
||||
// save the user to organization head
|
||||
$org_head->save();
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user