update v 1.0.7.5
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Agent\kb;
|
||||
|
||||
// controllersuse App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// request
|
||||
use App\Http\Requests\kb\PageRequest;
|
||||
@@ -13,15 +13,16 @@ use Datatable;
|
||||
// classes
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* PageController
|
||||
* This controller is used to CRUD Pages.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class PageController extends Controller
|
||||
{
|
||||
class PageController extends Controller {
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
* constructor to check
|
||||
@@ -31,8 +32,7 @@ class PageController extends Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Page $page)
|
||||
{
|
||||
public function __construct(Page $page) {
|
||||
// checking authentication
|
||||
$this->middleware('auth');
|
||||
// checking roles
|
||||
@@ -46,14 +46,13 @@ class PageController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
public function index() {
|
||||
$pages = $this->page->paginate(3);
|
||||
$pages->setPath('page');
|
||||
try {
|
||||
return view('themes.default1.agent.kb.pages.index', compact('pages'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,8 +61,7 @@ class PageController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
public function getData() {
|
||||
/* fetching chumper datatables */
|
||||
return Datatable::collection(Page::All())
|
||||
/* search column name */
|
||||
@@ -83,8 +81,8 @@ class PageController extends Controller
|
||||
/* 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="#deletepage'.$model->id.'"><a href="#" ><button class="btn btn-danger btn-xs"></a> '.\Lang::get('lang.delete').'</button></span> <a href=page/'.$model->slug.'/edit class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a> <a href=pages/'.$model->slug.' class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>
|
||||
<div class="modal fade" id="deletepage'.$model->id.'">
|
||||
return '<span data-toggle="modal" data-target="#deletepage' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . '</button></span> <a href=page/' . $model->slug . '/edit class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a> <a href=pages/' . $model->slug . ' class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
|
||||
<div class="modal fade" id="deletepage' . $model->id . '">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@@ -92,11 +90,11 @@ class PageController 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="page/delete/'.$model->id.'"><button class="btn btn-danger">delete</button></a>
|
||||
<a href="page/delete/' . $model->id . '"><button class="btn btn-danger">delete</button></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -110,8 +108,7 @@ class PageController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
public function create() {
|
||||
return view('themes.default1.agent.kb.pages.create');
|
||||
}
|
||||
|
||||
@@ -122,17 +119,16 @@ class PageController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function store(PageRequest $request)
|
||||
{
|
||||
public function store(PageRequest $request) {
|
||||
$sl = $request->input('slug');
|
||||
$slug = str_slug($sl, '-');
|
||||
$this->page->slug = $slug;
|
||||
try {
|
||||
$this->page->fill($request->except('slug'))->save();
|
||||
|
||||
return redirect('page')->with('success', 'Page created successfully');
|
||||
return redirect('page')->with('success', Lang::get('lang.page_created_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('page')->with('fails', $e->errorInfo[2]);
|
||||
return redirect('page')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,14 +139,13 @@ class PageController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function edit($slug)
|
||||
{
|
||||
public function edit($slug) {
|
||||
try {
|
||||
$page = $this->page->where('slug', $slug)->first();
|
||||
|
||||
return view('themes.default1.agent.kb.pages.edit', compact('page'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('page')->with('fails', $e->errorInfo[2]);
|
||||
return redirect('page')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,8 +157,7 @@ class PageController extends Controller
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function update($slug, PageUpdate $request)
|
||||
{
|
||||
public function update($slug, PageUpdate $request) {
|
||||
// get pages with respect to slug
|
||||
$pages = $this->page->where('slug', $slug)->first();
|
||||
$sl = $request->input('slug');
|
||||
@@ -174,9 +168,9 @@ class PageController extends Controller
|
||||
$pages->slug = $slug;
|
||||
$pages->save();
|
||||
|
||||
return redirect('page')->with('success', 'Your Page Updated Successfully');
|
||||
return redirect('page')->with('success', Lang::get('lang.your_page_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('page')->with('fails', $e->errorInfo[2]);
|
||||
return redirect('page')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,16 +181,16 @@ class PageController extends Controller
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
public function destroy($id) {
|
||||
try {
|
||||
// get the page to be deleted
|
||||
$page = $this->page->whereId($id)->first();
|
||||
$page->delete();
|
||||
|
||||
return redirect('page')->with('success', 'Page Deleted Successfully');
|
||||
return redirect('page')->with('success', Lang::get('lang.page_deleted_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('page')->with('fails', $e->errorInfo[2]);
|
||||
return redirect('page')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user