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

@@ -3,11 +3,8 @@
namespace App\Http\Controllers\Agent\kb;
// Controllers
use App\Http\Controllers\client\kb\UserController;
use App\Http\Controllers\admin\kb\ArticleController;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\kb\SettingsController;
use App\Http\Controllers\Agent\helpdesk\TicketController;
use App\Http\Controllers\Controller;
// Requests
use App\Http\Requests\kb\CategoryRequest;
use App\Http\Requests\kb\CategoryUpdate;
@@ -16,28 +13,28 @@ use App\Model\kb\Category;
use App\Model\kb\Relationship;
// Classes
use Datatable;
use Redirect;
use Exception;
use Redirect;
/**
* CategoryController
* This controller is used to CRUD category
* This controller is used to CRUD category.
*
* @package Controllers
* @subpackage Controller
* @author Ladybird <info@ladybirdweb.com>
*/
class CategoryController extends Controller {
class CategoryController 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()
{
// checking authentication
$this->middleware('auth');
// checking roles
@@ -46,11 +43,14 @@ class CategoryController extends Controller {
}
/**
* Indexing all Category
* Indexing all Category.
*
* @param type Category $category
*
* @return Response
*/
public function index() {
public function index()
{
/* get the view of index of the catogorys with all attributes
of category model */
try {
@@ -61,10 +61,12 @@ class CategoryController extends Controller {
}
/**
* fetching category list in chumper datatables
* fetching category list in chumper datatables.
*
* @return type chumper datatable
*/
public function getData() {
public function getData()
{
/* fetching chumper datatables */
return Datatable::collection(Category::All())
/* search column name */
@@ -78,13 +80,14 @@ class CategoryController extends Controller {
/* add column Created */
->addColumn('Created', function ($model) {
$t = $model->created_at;
return TicketController::usertimezone($t);
})
/* add column Actions */
/* there are action buttons and modal popup to delete a data column */
->addColumn('Actions', function ($model) {
return '<span data-toggle="modal" data-target="#deletecategory' . $model->slug . '"><a href="#" ><button class="btn btn-danger btn-xs"></a>' . \Lang::get("lang.delete") . '</button></span>&nbsp;<a href=category/' . $model->id . '/edit class="btn btn-warning btn-xs">' . \Lang::get("lang.edit") . '</a>&nbsp;<a href=article-list class="btn btn-primary btn-xs">' . \Lang::get("lang.view") . '</a>
<div class="modal fade" id="deletecategory' . $model->slug . '">
return '<span data-toggle="modal" data-target="#deletecategory'.$model->slug.'"><a href="#" ><button class="btn btn-danger btn-xs"></a>'.\Lang::get('lang.delete').'</button></span>&nbsp;<a href=category/'.$model->id.'/edit class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a>&nbsp;<a href=article-list class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>
<div class="modal fade" id="deletecategory'.$model->slug.'">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@@ -92,11 +95,11 @@ class CategoryController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4>
</div>
<div class="modal-body">
' . $model->name . '
'.$model->name.'
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
<a href="category/delete/' . $model->id . '"><button class="btn btn-danger">delete</button></a>
<a href="category/delete/'.$model->id.'"><button class="btn btn-danger">delete</button></a>
</div>
</div>
</div>
@@ -106,11 +109,14 @@ class CategoryController extends Controller {
}
/**
* Create a Category
* Create a Category.
*
* @param type Category $category
*
* @return type view
*/
public function create(Category $category) {
public function create(Category $category)
{
/* Get the all attributes in the category model */
$category = $category->get();
/* get the view page to create new category with all attributes
@@ -123,32 +129,39 @@ class CategoryController extends Controller {
}
/**
* To store the selected category
* @param type Category $category
* @param type CategoryRequest $request
* To store the selected category.
*
* @param type Category $category
* @param type CategoryRequest $request
*
* @return type Redirect
*/
public function store(Category $category, CategoryRequest $request) {
public function store(Category $category, CategoryRequest $request)
{
/* Get the whole request from the form and insert into table via model */
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
$slug = str_slug($sl, '-');
$category->slug = $slug;
// send success message to index page
try {
$category->fill($request->except('slug'))->save();
return Redirect::back()->with('success', 'Category Inserted Successfully');
} catch (Exception $e) {
return Redirect::back()->with('fails', 'Category Not Inserted' . '<li>' . $e->errorInfo[2] . '</li>');
return Redirect::back()->with('fails', 'Category Not Inserted'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* Show the form for editing the specified category.
* @param type $slug
* @param type Category $category
*
* @param type $slug
* @param type Category $category
*
* @return type view
*/
public function edit($slug, Category $category) {
public function edit($slug, Category $category)
{
// fetch the category
$cid = $category->where('id', $slug)->first();
$id = $cid->id;
@@ -160,17 +173,20 @@ class CategoryController extends Controller {
/**
* Update the specified Category in storage.
* @param type $slug
* @param type Category $category
* @param type CategoryUpdate $request
*
* @param type $slug
* @param type Category $category
* @param type CategoryUpdate $request
*
* @return type redirect
*/
public function update($slug, Category $category, CategoryUpdate $request) {
public function update($slug, Category $category, CategoryUpdate $request)
{
/* Edit the selected category via id */
$category = $category->where('id', $slug)->first();
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
$slug = str_slug($sl, '-');
// dd($slug);
$category->slug = $slug;
/* update the values at the table via model according with the request */
@@ -179,22 +195,25 @@ class CategoryController extends Controller {
$category->fill($request->all())->save();
$category->slug = $slug;
$category->save();
return redirect('category')->with('success', 'Category Updated Successfully');
} catch (Exception $e) {
//redirect to index with fails message
return redirect('category')->with('fails', 'Category Not Updated' . '<li>' . $e->errorInfo[2] . '</li>');
return redirect('category')->with('fails', 'Category Not Updated'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* Remove the specified category from storage.
* @param type $id
* @param type Category $category
* @param type Relationship $relation
*
* @param type $id
* @param type Category $category
* @param type Relationship $relation
*
* @return type Redirect
*/
public function destroy($id, Category $category, Relationship $relation) {
public function destroy($id, Category $category, Relationship $relation)
{
$relation = $relation->where('category_id', $id)->first();
if ($relation != null) {
return Redirect::back()->with('fails', 'Category Not Deleted');
@@ -204,11 +223,11 @@ class CategoryController extends Controller {
// redirect to index with success message
try {
$category->delete();
return Redirect::back()->with('success', 'Category Deleted Successfully');
} catch (Exception $e) {
return Redirect::back()->with('fails', 'Category Not Deleted' . '<li>' . $e->errorInfo[2] . '</li>');
return Redirect::back()->with('fails', 'Category Not Deleted'.'<li>'.$e->errorInfo[2].'</li>');
}
}
}
}