96 lines
2.6 KiB
PHP
Executable File
96 lines
2.6 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use Response;
|
|
use Schema;
|
|
use Hash;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Libraries\ListHelper;
|
|
|
|
use App\Contracts\AdminActionLogsInterface;
|
|
use App\Helpers\HttpStatusCode;
|
|
use App\Libraries\UuidHelper;
|
|
use App\Helpers\CurrentUserHelper;
|
|
use App\AdminActionLogs;
|
|
|
|
class AdminActionLogsService implements AdminActionLogsInterface
|
|
{
|
|
|
|
public $adminActionLogs;
|
|
|
|
public $pl_id;
|
|
|
|
public $modules;
|
|
|
|
public $actions;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->modules = [
|
|
'LOGIN' => 'Login',
|
|
'USERMANAGEMENT' => 'User Management',
|
|
'MEMBERMANAGEMENT' => 'Member Management',
|
|
'PROMOTIONS' => 'Promotions',
|
|
'TOPUP' => 'Top-Up',
|
|
'CARDTYPES' => 'Card Types',
|
|
'REPORT_TOPUP' => 'Report - Top Up',
|
|
'REPORT_STATIONRATINGS' => 'Report - Station Ratings',
|
|
'REPORT_MOBILEUSAGE' => 'Report - Mobile Usage',
|
|
'REPORT_REGISTRATION' => 'Report - Registration',
|
|
'SYSTEMPREFERENCES' => 'System Preferences',
|
|
'STATION' => 'Station',
|
|
'PHOTOSLIDER' => 'Photo Slider',
|
|
'NOTIFICATION' => 'Notification'
|
|
];
|
|
|
|
$this->actions = [
|
|
'STORE' => 'store',
|
|
'UPDATE' => 'update',
|
|
'DELETE' => 'delete',
|
|
'ACTIVATE' => 'activate',
|
|
'GENERATE' => 'generate',
|
|
'EXPORT' => 'export',
|
|
'LOGIN' => 'login',
|
|
'LOGOUT' => 'logout',
|
|
];
|
|
}
|
|
|
|
public function getByField($field,$value)
|
|
{
|
|
$this->adminActionLogs = AdminActionLogs::where($field,$value)
|
|
->orderBy('created_dt','desc');
|
|
return $this->adminActionLogs->get();
|
|
}
|
|
|
|
public function log($id, $module, $action, $remarks = '')
|
|
{
|
|
if(isset($this->modules[$module]) && isset($this->actions[$action]))
|
|
{
|
|
|
|
$currentUser = CurrentUserHelper::get_currentAdmin();
|
|
|
|
$this->adminActionLogs = new AdminActionLogs;
|
|
|
|
$this->adminActionLogs->id = $id;
|
|
$this->adminActionLogs->module = $this->modules[$module];
|
|
$this->adminActionLogs->action = $this->actions[$action];
|
|
$this->adminActionLogs->created_by = isset( $currentUser ) ? $currentUser->admin_id : $id;
|
|
|
|
if($remarks != '')
|
|
$this->adminActionLogs->remarks = $remarks;
|
|
|
|
if ($this->adminActionLogs->save())
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
}
|