WP File Manager
Current Path:
/
home
/
itutorethiopia
/
public_html
/
app
/
Http
/
Controllers
/
Core
/
Name
Action
..
GroupsController.php
Edit
LogsController.php
Edit
PagesController.php
Edit
UsersController.php
Edit
Editing: LogsController.php
<?php namespace App\Http\Controllers\Core; use App\Http\Controllers\Controller; use App\Models\Core\Logs; use Illuminate\Http\Request; use Illuminate\Pagination\LengthAwarePaginator as Paginator; use Validator, Input, Redirect ; class LogsController extends Controller { protected $layout = "layouts.main"; protected $data = array(); public $module = 'logs'; static $per_page = '10'; public function __construct() { $this->model = new Logs(); $this->info = $this->model->makeInfo( $this->module); $this->access = $this->model->validAccess($this->info['id']); $this->data = array( 'pageTitle' => $this->info['title'], 'pageNote' => $this->info['note'], 'pageModule'=> 'logs', 'return' => self::returnUrl() ); } public function Index( Request $request ) { if($this->access['is_view'] ==0) return Redirect::to('dashboard') ->with('messagetext', \Lang::get('core.note_restric'))->with('msgstatus','error'); $sort = (!is_null($request->input('sort')) ? $request->input('sort') : 'auditID'); $order = (!is_null($request->input('order')) ? $request->input('order') : 'asc'); // End Filter sort and order for query // Filter Search for query $filter = (!is_null($request->input('search')) ? '': ''); $page = $request->input('page', 1); $params = array( 'page' => $page , 'limit' => (!is_null($request->input('rows')) ? filter_var($request->input('rows'),FILTER_VALIDATE_INT) : static::$per_page ) , 'sort' => $sort , 'order' => $order, 'params' => $filter, 'global' => (isset($this->access['is_global']) ? $this->access['is_global'] : 0 ) ); // Get Query $results = $this->model->getRows( $params ); // Build pagination setting $page = $page >= 1 && filter_var($page, FILTER_VALIDATE_INT) !== false ? $page : 1; $pagination = new Paginator($results['rows'], $results['total'], $params['limit']); $pagination->setPath('logs'); $this->data['rowData'] = $results['rows']; // Build Pagination $this->data['pagination'] = $pagination; // Build pager number and append current param GET $this->data['pager'] = $this->injectPaginate(); // Row grid Number $this->data['i'] = ($page * $params['limit'])- $params['limit']; // Grid Configuration $this->data['tableGrid'] = $this->info['config']['grid']; $this->data['tableForm'] = $this->info['config']['forms']; $this->data['colspan'] = \SiteHelpers::viewColSpan($this->info['config']['grid']); // Group users permission $this->data['access'] = $this->access; // Detail from master if any // Master detail link if any $this->data['subgrid'] = (isset($this->info['config']['subgrid']) ? $this->info['config']['subgrid'] : array()); // Render into template return view('core.logs.index',$this->data); } function getUpdate(Request $request, $id = null) { if($id =='') { if($this->access['is_add'] ==0 ) return Redirect::to('dashboard')->with('messagetext',\Lang::get('core.note_restric'))->with('msgstatus','error'); } if($id !='') { if($this->access['is_edit'] ==0 ) return Redirect::to('dashboard')->with('messagetext',\Lang::get('core.note_restric'))->with('msgstatus','error'); } $row = $this->model->find($id); if($row) { $this->data['row'] = $row; } else { $this->data['row'] = $this->model->getColumnTable('logs'); } $this->data['id'] = $id; return view('core.logs.form',$this->data); } public function getShow( $id = null) { if($this->access['is_detail'] ==0) return Redirect::to('dashboard') ->with('messagetext', \Lang::get('core.note_restric'))->with('msgstatus','error'); $row = $this->model->getRow($id); if($row) { $this->data['row'] = $row; } else { $this->data['row'] = $this->model->getColumnTable('logs'); } $this->data['id'] = $id; $this->data['access'] = $this->access; return view('core.logs.view',$this->data); } function postSave( Request $request, $id =0) { $rules = $this->validateForm(); $validator = Validator::make($request->all(), $rules); if ($validator->passes()) { $data = $this->validatePost('logs'); $this->model->insertRow($data , $request->input('auditID')); return Redirect::to('core/logs?return='.self::returnUrl())->with('messagetext',\Lang::get('core.note_success'))->with('msgstatus','success'); } else { return Redirect::to('core/logs/update/'.$id)->with('messagetext',\Lang::get('core.note_error'))->with('msgstatus','error') ->withErrors($validator)->withInput(); } } public function postDelete( Request $request) { if($this->access['is_remove'] ==0) return Redirect::to('dashboard') ->with('messagetext', \Lang::get('core.note_restric'))->with('msgstatus','error'); // delete multipe rows if(count($request->input('id')) >=1) { $this->model->destroy($request->input('id')); // redirect return Redirect::to('core/logs') ->with('messagetext', \Lang::get('core.note_success_delete'))->with('msgstatus','success'); } else { return Redirect::to('core/logs') ->with('messagetext','No Item Deleted')->with('msgstatus','error'); } } }