Compare commits
No commits in common. "laravel-11" and "main" have entirely different histories.
laravel-11
...
main
|
@ -1,14 +0,0 @@
|
|||
# Ignore environment files
|
||||
.env
|
||||
|
||||
# Ignore OS-generated files
|
||||
.DS_Store
|
||||
|
||||
# Ignore logs
|
||||
*.log
|
||||
|
||||
# Ignore node_modules (if applicable)
|
||||
node_modules/
|
||||
|
||||
# Ignore the Dockerfile itself (if needed)
|
||||
Dockerfile
|
|
@ -1,15 +0,0 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.yml]
|
||||
indent_size = 2
|
94
.env
94
.env
|
@ -1,94 +0,0 @@
|
|||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=base64:0gU9IIArwNb9IW4nkiuN72zGhw0YrtIVZnM7WJxxD88=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=db_mysql
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=unioil-app
|
||||
DB_USERNAME=rootuser
|
||||
DB_PASSWORD=password
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_DRIVER=smtp
|
||||
MAIL_HOST=smtp.mailtrap.io
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
#CYWARE="http://13.229.0.154/cgi-bin/uni_app.cgi"
|
||||
#CYWARE="http://172.31.21.64/cgi-bin/uni_app.cgi"
|
||||
CYWARE="http://172.31.47.37/cgi-bin/uni_app.cgi"
|
||||
STRATUSCAST="http://unioil.com/unioilapi/ciapi/index.php"
|
||||
STRATUSCASTUSERNAME="unioil@dmin123"
|
||||
STRATUSCASTPASSWORD="!Str@tusc@stUnioil12345"
|
||||
#RNRPHTESTING="https://testing-api-station-locator.herokuapp.com/api/"
|
||||
RNRPHTESTING="https://unioilstationlocatorapi.lbteksystems.com/api/"
|
||||
RNRPH="https://unioilstationlocatorapi.lbteksystems.com/api/"
|
||||
RNRPHDEV="https://unioilstationlocatorapi.lbteksystems.com/api/"
|
||||
|
||||
# paymaya vault
|
||||
#PAYMAYA_ENV="https://pg-sandbox.paymaya.com/"
|
||||
#PAYMAYA_SANDBOX_API_KEY="pk-Z0OSzLvIcOI2UIvDhdTGVVfRSSeiGStnceqwUE7n0Ah:"
|
||||
#PAYMAYA_SANDBOX_SECRET_KEY="sk-X8qolYjy62kIzEbr0QRK1h4b4KDVHaNcwMYk39jInSl:"
|
||||
|
||||
|
||||
PASSPORT_ADMIN_CLIENT_ID=2
|
||||
PASSPORT_ADMIN_CLIENT_SECRET=LmAfZ1tQ780pQNhdfhGhLI6slWHI1QQRtsvffiZS
|
||||
|
||||
M360_BROADCAST_URL=https://smsapi.mobile360.ph/v2/api/broadcast
|
||||
M360_BROADCAST_USERNAME=unioil
|
||||
M360_BROADCAST_PASSWORD=l42Bvzh5
|
||||
M360_BROADCAST_SHORTCODE=UNIOIL
|
||||
M360_ENV=LOCAL
|
||||
M360_TEST_MOBILE=09231191959
|
||||
|
||||
#shared treats
|
||||
SHAREDTREATSENCRYPTION="https://stg.sharetreats.ph:3044/encrypt/unioil/"
|
||||
SHAREDTREATSGATEWAY="https://stg.sharetreats.ph:3044/gateway/unioil/"
|
||||
|
||||
#paypal
|
||||
#PAYPAL_ENV=SANDBOX
|
||||
#PAYPAL_SANDBOX_URL=https://api.sandbox.paypal.com/v1
|
||||
#PAYPAL_LIVE_URL=
|
||||
#PAYPAL_SANDBOX_CLIENTID=AePYXW1PMq0579oJTG-YgTwwR3KW_mLb0-9QBBQVwDUHviy--Upy3X6s9000CBSJQRhUxtiLL9RZkzDC
|
||||
#PAYPAL_SANDBOX_SECRET=EC0z4zgVIl4Ztm-vUOBxoXuuPkZ9iXtlGsn32PXwNuUW9FaewCNqEPbfIvZr_ddg3w9cxMqqovq3HBhp
|
||||
#PAYPAL_LIVE_CLIENTID=
|
||||
#PAYPAL_LIVE_SECRET=
|
||||
|
||||
#s3
|
||||
AWS_ACCESS_KEY_ID=AKIA4H24QCFWUMHBERLW
|
||||
AWS_SECRET_ACCESS_KEY=mBMX+Zy/FxChpgfjIRZ420ck/wqsNBmlD94objyS
|
||||
AWS_DEFAULT_REGION=ap-southeast-1
|
||||
AWS_BUCKET=unioil.mobiletestbucket
|
||||
AWS_BUCKET_ENV=mobileapp
|
||||
S3_FORMAT_VERSION=2
|
||||
|
||||
#front end
|
||||
FRONT_END_URL="http://mobileinteglb-993304533.ap-southeast-1.elb.amazonaws.com"
|
||||
|
||||
#si_num
|
||||
SI_NUM_RANDOM=false
|
||||
VIEW_COMPILED_PATH=/var/www/storage/framework/views
|
46
.env.example
46
.env.example
|
@ -1,46 +0,0 @@
|
|||
APP_NAME=Laravel
|
||||
APP_ENV=production
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=db_mysql
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=unioil-app
|
||||
DB_USERNAME=armiejean
|
||||
DB_PASSWORD=your_pass
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_DRIVER=smtp
|
||||
MAIL_HOST=smtp.mailtrap.io
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
|
||||
#urls
|
||||
CYWARE="http://13.229.0.154/cgi-bin/uni_app.cgi"
|
||||
STRATUSCAST="http://unioil.com/unioilapi/ciapi/index.php"
|
||||
STRATUSCASTUSERNAME="unioil@dmin123"
|
||||
STRATUSCASTPASSWORD="!Str@tusc@stUnioil12345"
|
|
@ -1,5 +0,0 @@
|
|||
* text=auto
|
||||
*.css linguist-vendored
|
||||
*.scss linguist-vendored
|
||||
*.js linguist-vendored
|
||||
CHANGELOG.md export-ignore
|
|
@ -1,14 +0,0 @@
|
|||
/node_modules
|
||||
#/public/hot
|
||||
#/public/storage
|
||||
# /storage/*.key
|
||||
/vendor
|
||||
/.idea
|
||||
/.vscode
|
||||
/.vagrant
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
|
||||
.phpunit.result.cache
|
|
@ -1,3 +1,2 @@
|
|||
# UniOil-API
|
||||
# unioil-loyalty-app
|
||||
|
||||
This repository contains all the backend code for the Unioil Loyalty Mobile Application.
|
Binary file not shown.
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Abstracts;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
abstract class CustomFormRequest extends FormRequest
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a failed validation attempt.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Validation\Validator $validator
|
||||
* @return void
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
protected function failedValidation(Validator $validator)
|
||||
{
|
||||
|
||||
throw new ValidationException($validator, $this->response(
|
||||
$this->formatErrors($validator)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the errors from the given Validator instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Validation\Validator $validator
|
||||
* @return array
|
||||
*/
|
||||
protected function formatErrors(Validator $validator)
|
||||
{
|
||||
return $validator->getMessageBag()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the proper failed validation response for the request.
|
||||
*
|
||||
* @param array $errors
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function response(array $errors)
|
||||
{
|
||||
if ($this->expectsJson()) {
|
||||
return new JsonResponse($errors, 422);
|
||||
}
|
||||
|
||||
return $this->redirector->to($this->getRedirectUrl())
|
||||
->withInput($this->except($this->dontFlash))
|
||||
->withErrors($errors, $this->errorBag);
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Admin extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Table name of model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'admin';
|
||||
|
||||
/**
|
||||
* Primary key field name of table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'admin_id';
|
||||
|
||||
/**
|
||||
* Additional fields from other connected tables
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
||||
protected $hidden = ['password'];
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = ['created_at','updated_at'];
|
||||
|
||||
public function getFullNameAttribute($key)
|
||||
{
|
||||
return ucwords($this->firstname." ".$this->lastname);
|
||||
}
|
||||
|
||||
public function setFullNameAttribute($key)
|
||||
{
|
||||
return ucwords($this->firstname." ".$this->lastname);
|
||||
}
|
||||
|
||||
public function setFirstnameAttribute($value)
|
||||
{
|
||||
return $this->attributes['firstname'] = ucwords($value);
|
||||
}
|
||||
|
||||
public function setLastnameAttribute($value)
|
||||
{
|
||||
return $this->attributes['lastname'] = ucwords($value);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->hasOne('App\User','username',"username");
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AdminActionLogs extends Model
|
||||
{
|
||||
/**
|
||||
* Table name of model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'admin_action_logs';
|
||||
|
||||
/**
|
||||
* Primary key field name of table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'actionlog_id';
|
||||
|
||||
/**
|
||||
* Additional fields from other connected tables
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
||||
protected $hidden = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = ['created_dt'];
|
||||
|
||||
|
||||
/**
|
||||
* Enable / Disable timestamp saving
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $timestamps = false;
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CodeCardType extends Model
|
||||
{
|
||||
/**
|
||||
* Table name of model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'code_card_type';
|
||||
|
||||
/**
|
||||
* Primary key field name of table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'cardtype_id';
|
||||
|
||||
/**
|
||||
* Additional fields from other connected tables
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['created_at','updated_at','created_by','updated_by','is_active'];
|
||||
|
||||
|
||||
public function idNumberType()
|
||||
{
|
||||
return $this->hasMany('App\IDNumberType','cardtype_id','cardtype_id');
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CodeCity extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Table name of model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'code_city';
|
||||
|
||||
/**
|
||||
* Primary key field name of table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'city_id';
|
||||
|
||||
/**
|
||||
* Additional fields from other connected tables
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['city_id'];
|
||||
|
||||
// public function province()
|
||||
// {
|
||||
// return $this->hasOne('App\CodeProvince','province_id','province_id');
|
||||
// }
|
||||
|
||||
public function station()
|
||||
{
|
||||
return $this->hasMany('App\Station','city_id','city_id');
|
||||
}
|
||||
|
||||
public function scopeUuid($query,$uuid)
|
||||
{
|
||||
$query->where('is_active',1);
|
||||
$query->where('city_uuid',$uuid);
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CodeCivilStatus extends Model
|
||||
{
|
||||
/**
|
||||
* Table name of model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'code_civil_status';
|
||||
|
||||
/**
|
||||
* Primary key field name of table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'civilstatus_id';
|
||||
|
||||
/**
|
||||
* Additional fields from other connected tables
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['civilstatus_id','created_at','updated_at','created_by','updated_by','is_active'];
|
||||
|
||||
public function scopeCode($query,$code)
|
||||
{
|
||||
$query->where('is_active',1);
|
||||
$query->where('code',$code);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CodeFuelType extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Table name of model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'code_fuel_type';
|
||||
|
||||
/**
|
||||
* Primary key field name of table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'fueltype_id';
|
||||
|
||||
/**
|
||||
* Additional fields from other connected tables
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['fueltype_id','created_at','updated_at','created_by','updated_by','is_active'];
|
||||
|
||||
public function scopeCode($query,$code)
|
||||
{
|
||||
$query->where('is_active',1);
|
||||
$query->where('code',$code);
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CodeGender extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Table name of model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'code_gender';
|
||||
|
||||
/**
|
||||
* Primary key field name of table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'gender_id';
|
||||
|
||||
/**
|
||||
* Additional fields from other connected tables
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['gender_id','created_at','updated_at','created_by','updated_by','is_active'];
|
||||
|
||||
public function scopeCode($query,$code)
|
||||
{
|
||||
$query->where('is_active',1);
|
||||
$query->where('code',$code);
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CodeProvince extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Table name of model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'code_province';
|
||||
|
||||
/**
|
||||
* Primary key field name of table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'province_id';
|
||||
|
||||
/**
|
||||
* Additional fields from other connected tables
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['province_id'];
|
||||
|
||||
|
||||
public function city()
|
||||
{
|
||||
return $this->hasMany('App\CodeCity','province_id','province_id');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CodeVehicleOwn extends Model
|
||||
{
|
||||
/**
|
||||
* Table name of model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'code_vehicle_own';
|
||||
|
||||
/**
|
||||
* Primary key field name of table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'vo_id';
|
||||
|
||||
/**
|
||||
* Additional fields from other connected tables
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['vo_id','created_at','updated_at','created_by','updated_by','is_active'];
|
||||
|
||||
public function scopeCode($query,$code)
|
||||
{
|
||||
$query->where('is_active',1);
|
||||
$query->where('code',$code);
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Contracts\LcardActionLogsInterface;
|
||||
use App\Contracts\LoyaltyCardResourceInterface;
|
||||
use App\Contracts\MobileAnalyticsResourceInterface;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class InactiveLoyaltyCard extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'inactive:loyaltycard';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Inactived loyalty card that has no transactions in the log';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(LcardActionLogsInterface $lcardActionLogscard, LoyaltyCardResourceInterface $loyalty_card,MobileAnalyticsResourceInterface $mobile_usage)
|
||||
{
|
||||
|
||||
$now = Carbon::now()->subYear();
|
||||
$orders = DB::select(
|
||||
"SELECT *
|
||||
FROM lcard_action_logs t1
|
||||
WHERE t1.created_at = (
|
||||
SELECT MAX(t2.created_at)
|
||||
FROM lcard_action_logs t2
|
||||
WHERE t2.created_by = t1.created_by)
|
||||
and created_at < '".$now."'
|
||||
and created_by <> 0
|
||||
group by created_by");
|
||||
echo "-------start-------";
|
||||
foreach ($orders as $key => $value){
|
||||
$mobile_usage->add_inactive();
|
||||
$loyalty_card->setInactive($value->created_by);
|
||||
$lcardActionLogscard->log($value->created_by,'CRONJOB','INACTIVE');
|
||||
print_r($value);
|
||||
}
|
||||
echo "-------finish-------";
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
//
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('inactive:loyaltycard')
|
||||
->daily();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface AdminActionLogsInterface
|
||||
{
|
||||
|
||||
public function getByField($field,$value);
|
||||
|
||||
public function log($id, $module, $action, $remarks = '');
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface AdminResourceInterface
|
||||
{
|
||||
|
||||
public function getAll();
|
||||
|
||||
public function listing($params);
|
||||
|
||||
public function store(Request $request);
|
||||
|
||||
public function getByField($data);
|
||||
|
||||
public function changePassword(Request $request);
|
||||
|
||||
public function show($uuid);
|
||||
|
||||
public function update($request,$id);
|
||||
|
||||
public function changeStatus($status,$uuid);
|
||||
|
||||
public function delete($uuid);
|
||||
|
||||
public function getDetailsWhereIn($field,$value,$relationship = null);
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface CardTypeResourceInterface
|
||||
{
|
||||
|
||||
public function listing($params);
|
||||
|
||||
public function store(Request $request);
|
||||
|
||||
public function getByField($data, $relationship = null);
|
||||
|
||||
public function update($request, $uuid);
|
||||
|
||||
public function delete($uuid);
|
||||
|
||||
public function getDetailsWhereIn($field,$value,$relationship = null);
|
||||
|
||||
public function getAllCardType();
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: root
|
||||
* Date: 9/26/18
|
||||
* Time: 4:34 PM
|
||||
*/
|
||||
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface CityAndProvinceResourceInterface
|
||||
{
|
||||
|
||||
public function getAll();
|
||||
public function getCityByField($field,$value);
|
||||
public function getProvinceByField($field,$value);
|
||||
public function storeCity($value);
|
||||
public function storeProvince( $value );
|
||||
public function updateProvince( $value );
|
||||
public function updateCity( $value );
|
||||
public function getAllRelationship();
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface CodeCivilStatusResourceInterface
|
||||
{
|
||||
|
||||
public function getAll();
|
||||
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface CodeFuelTypeResourceInterface
|
||||
{
|
||||
|
||||
public function getAll();
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface CodeGenderResourceInterface
|
||||
{
|
||||
|
||||
public function getAll();
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface CodeVehicleOwnResourceInterface
|
||||
{
|
||||
|
||||
public function getAll();
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface FuelTrackerResourceInterface
|
||||
{
|
||||
|
||||
public function listing($params);
|
||||
public function store($request);
|
||||
public function update($request);
|
||||
public function getByFieldAndLcardId($field, $value, $uuid);
|
||||
public function delete($uuid);
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,149 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Earwin Delos Santos
|
||||
* Date: 12 Nov 2017
|
||||
* Time: 7:49 PM
|
||||
*/
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
|
||||
use Illuminate\Support\Facades\Response;
|
||||
|
||||
interface HttpStatusCodeInterface
|
||||
{
|
||||
/**
|
||||
* Standard response for successful HTTP requests. The actual response will depend on the request method used.
|
||||
* In a GET request, the response will contain an entity corresponding to the requested resource.
|
||||
* In a POST request, the response will contain an entity describing or containing the result of the action.[7]
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
*/
|
||||
public function success($message="SUCCESS",$content=array());
|
||||
|
||||
/**
|
||||
* The request has been fulfilled, resulting in the creation of a new resource
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
*/
|
||||
public function created($message="CREATED",$content=array());
|
||||
|
||||
/**
|
||||
* The server successfully processed the request and is not returning any data.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function noContent($message="NO CONTENT",$content=array());
|
||||
|
||||
/**
|
||||
* The server successfully processed the request, but is not returning any data.
|
||||
* Unlike a 204 response, this response requires that the requester reset the document view.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
*/
|
||||
public function resetContent($message="RESET CONTENT",$content=array());
|
||||
|
||||
/**
|
||||
* The server is delivering only part of the resource (byte serving) due to a range header sent by the client.
|
||||
* The range header is used by HTTP clients to enable resuming of interrupted downloads,
|
||||
* or split a download into multiple simultaneous streams.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
*/
|
||||
public function partialContent($message="PARTIAL CONTENT",$content=array());
|
||||
|
||||
/**
|
||||
* The server cannot or will not process the request due to an apparent client error
|
||||
* (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing)
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
*/
|
||||
public function badRequest($message="BAD REQUEST",$content=array());
|
||||
|
||||
/**
|
||||
* Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet been provided.
|
||||
* The response must include a WWW-Authenticate header field containing a challenge applicable to the requested resource.
|
||||
* See Basic access authentication and Digest access authentication.
|
||||
* 401 semantically means "unauthenticated",[34] i.e. the user does not have the necessary credentials.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
*/
|
||||
public function unauthorized($message="UNAUTHORIZED",$content=array());
|
||||
|
||||
/**
|
||||
* The request was a valid request, but the server is refusing to respond to it.
|
||||
* The user might be logged in but does not have the necessary permissions for the resource.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
*/
|
||||
public function forbidden($message="FORBIDDEN",$content=array());
|
||||
|
||||
/**
|
||||
* The requested resource could not be found but may be available in the future.
|
||||
* Subsequent requests by the client are permissible.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
*/
|
||||
public function notFound($message="NOT FOUND",$content=array());
|
||||
|
||||
/**
|
||||
* The request is larger than the server is willing or able to process.
|
||||
* Previously called "Request Entity Too Large".
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
*/
|
||||
public function payloadToLarge($message="PAYLOAD TO LARGE",$content=array());
|
||||
|
||||
/**
|
||||
* The request was well-formed but was unable to be followed due to semantic errors
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
*/
|
||||
public function unprocessableEntity($message="Unprocessable Entity",$content=array());
|
||||
|
||||
/**
|
||||
* Error found during process
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function applicationValidationErrorCode($message="Error found",$content=array());
|
||||
|
||||
/**
|
||||
* A code of 498 indicates an expired or otherwise invalid token.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
*/
|
||||
public function invalidToken($message="INVALID TOKEN",$content=array());
|
||||
|
||||
/**
|
||||
* A code of 499 indicates that a token is required but was not submitted.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
*/
|
||||
public function requiredToken($message="REQUIRED TOKEN",$content=array());
|
||||
|
||||
/**
|
||||
* A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
*/
|
||||
public function internalServerError($message="INTERNAL SERVER ERROR",$content=array());
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface IDNumberTypeInterface
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface LcardActionLogsInterface
|
||||
{
|
||||
|
||||
public function getByFieldWithOperator($field, $operator, $value);
|
||||
|
||||
public function getByField($field, $value);
|
||||
|
||||
public function log($id, $module, $action, $remarks = '');
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface LoyaltyCardResourceInterface
|
||||
{
|
||||
|
||||
public function getAll();
|
||||
|
||||
public function store($pd_id, $data, $deviceUUID = null, $cyware_synced = null);
|
||||
|
||||
public function listing($params);
|
||||
|
||||
public function getDetailsWhereIn($field,$value,$relationship = null);
|
||||
|
||||
public function getByField($data,$relationship = null);
|
||||
|
||||
public function delete($uuid);
|
||||
|
||||
public function show($uuid,$relationship = null);
|
||||
|
||||
public function activate_locked($uuid);
|
||||
|
||||
public function numberOfOTPAttempts($uuid);
|
||||
|
||||
public function lockMember($id,$lock_code);
|
||||
|
||||
public function validateMember($id);
|
||||
|
||||
public function setInactive($id);
|
||||
|
||||
public function remove_deviceuuid($card_number, $deactivated = 0);
|
||||
|
||||
public function update_deviceuuid($lcard_id,$deviceUUID);
|
||||
|
||||
public function sync_cyware($data);
|
||||
|
||||
public function cyware_activate($lcard_id, $data);
|
||||
|
||||
public function update_non_cyware_synced($lcard_id, $data);
|
||||
|
||||
public function store_signup($pd_id, $data);
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface LoyaltyCardSignUpInterface
|
||||
{
|
||||
|
||||
public function store($data);
|
||||
|
||||
public function upload_document($request);
|
||||
|
||||
public function count_between($from,$to);
|
||||
|
||||
public function assign_ref_no($lcard_s_uuid,$ref_no);
|
||||
|
||||
public function getByField($data, $relationship = null);
|
||||
|
||||
public function listing($params);
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface MobileAnalyticsResourceInterface
|
||||
{
|
||||
|
||||
public function report_mobileUsage($params, $export = false);
|
||||
|
||||
public function add_active();
|
||||
|
||||
public function add_inactive();
|
||||
|
||||
public function add_locked();
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface MpinCodesResourceInterface
|
||||
{
|
||||
|
||||
public function getCodes($field,$value);
|
||||
|
||||
public function store($data);
|
||||
|
||||
public function getMpin($lcardId);
|
||||
|
||||
public function updateMpin($lcardId,$data);
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface OtpAttemptsResourceInterface
|
||||
{
|
||||
public function delete($id);
|
||||
|
||||
public function store($id, $otp);
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface OtpLogResourceInterface
|
||||
{
|
||||
|
||||
public function store($lcard_id,$data);
|
||||
|
||||
public function getByField($data);
|
||||
|
||||
public function getLastLog($lcard_id);
|
||||
|
||||
public function setUsed($id);
|
||||
|
||||
public function getLastLog_limit($limit,$card_number);
|
||||
|
||||
public function getLastLogByNumber($number);
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface PasswordLogsResourceInterface
|
||||
{
|
||||
|
||||
public function store($admin_id,$password,$created_by, $is_generated = false);
|
||||
|
||||
public function getByField($data);
|
||||
|
||||
public function getLastLog($admin_id);
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface PaymentResourceInterface
|
||||
{
|
||||
|
||||
public function report_topUp($params, $export = false);
|
||||
|
||||
public function get_by_trans_num($trans_num);
|
||||
|
||||
public function store_non_app($data,$member_data);
|
||||
|
||||
public function count_between($lcard_id, $from, $to);
|
||||
|
||||
public function count_trans_month();
|
||||
|
||||
public function failed_transaction($paypal_id,$other);
|
||||
|
||||
public function success_transaction($trans_num, $data);
|
||||
|
||||
public function cyware_synced($id, $points);
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface PersonalDetailsResourceInterface
|
||||
{
|
||||
public function getDetailsWhereIn($field,$value);
|
||||
|
||||
public function delete($uuid);
|
||||
|
||||
public function store($data);
|
||||
|
||||
public function update($request, $id);
|
||||
|
||||
public function sync_cyware($id, $data);
|
||||
|
||||
public function update_non_cyware_synced($pd_id, $data);
|
||||
|
||||
public function store_signup($data);
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface PhotoSliderResourceInterface
|
||||
{
|
||||
|
||||
public function listing($params);
|
||||
|
||||
public function store(Request $request);
|
||||
|
||||
public function getByField($field,$value);
|
||||
|
||||
public function update($request, $uuid);
|
||||
|
||||
public function delete($uuid);
|
||||
|
||||
public function getDetailsWhereIn($field,$value,$relationship = null);
|
||||
|
||||
public function count();
|
||||
|
||||
public function getPhotoSlider();
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: root
|
||||
* Date: 9/26/18
|
||||
* Time: 4:34 PM
|
||||
*/
|
||||
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface ProductDetailsResourceInterface
|
||||
{
|
||||
|
||||
public function getProductCategoryByField($field,$value);
|
||||
public function getProductDetailsByField($field,$value);
|
||||
public function storeProductDetails($value);
|
||||
public function storeProductCategory($value);
|
||||
public function updateProductCategory( $value );
|
||||
public function updateProductDetails( $value );
|
||||
public function getAllProductCategory();
|
||||
public function getProductsByCategory($pc_id);
|
||||
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface PromotionResourceInterface
|
||||
{
|
||||
|
||||
public function listing($params);
|
||||
|
||||
public function store(Request $request);
|
||||
|
||||
public function getByField($field,$value, $relationship = null);
|
||||
|
||||
public function update($request, $uuid);
|
||||
|
||||
public function delete($uuid);
|
||||
|
||||
public function getDetailsWhereIn($field,$value,$relationship = null);
|
||||
|
||||
public function get_promotion($include_promotion = null);
|
||||
|
||||
public function getTopTwoPromotion($type);
|
||||
|
||||
public function get_promo_by_date_type($date,$type);
|
||||
|
||||
public function get_promo_by_date_birthdate_type($date,$birthdate,$type);
|
||||
|
||||
public function get_promo_by_date_station_gps($station_ids, $date, $type);
|
||||
|
||||
public function get_promo_by_birthdate_station_gps($station_ids,$date,$birthdate,$type);
|
||||
|
||||
public function expire_top_two();
|
||||
|
||||
public function get_all_branch_promo($date, $type);
|
||||
|
||||
public function get_all_branch_promo_by_birthdate($date,$birthdate,$type);
|
||||
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface PromotionStationsInterface
|
||||
{
|
||||
|
||||
public function getByField($field,$value);
|
||||
|
||||
public function store($promotion_id, $station_ids);
|
||||
|
||||
public function delete($promotion_id);
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface RatingsResourceInterface
|
||||
{
|
||||
|
||||
public function report_stationRatings($params, $export = false);
|
||||
|
||||
public function store($data);
|
||||
|
||||
public function update($data, $rating_id);
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface RegistrationResourceInterface
|
||||
{
|
||||
|
||||
public function report_registration($params, $export = false);
|
||||
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface SignUpAPICallsInterface
|
||||
{
|
||||
|
||||
public function log($user_id);
|
||||
|
||||
public function success($signup_api_id,$lcard_id);
|
||||
|
||||
public function count($date = '');
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface StationFavoriteResourceInterface
|
||||
{
|
||||
|
||||
public function getFavorites($lcard_id);
|
||||
|
||||
public function store($station_id, $lcard_id);
|
||||
|
||||
public function delete($station_id, $lcard_id);
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface StationFuelPricesInterface
|
||||
{
|
||||
|
||||
public function store($station_id, $data);
|
||||
|
||||
public function update_price($uuid, $price);
|
||||
|
||||
public function delete($station_id,$ids);
|
||||
|
||||
public function getByField($field,$value);
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface StationResourceInterface
|
||||
{
|
||||
|
||||
public function getByField($field,$value);
|
||||
|
||||
public function getDetailsWhereIn($field,$value,$relationship = null);
|
||||
|
||||
public function radius($meters,$longitude,$latitude);
|
||||
|
||||
public function nearby($longitude,$latitude);
|
||||
|
||||
public function favorites();
|
||||
|
||||
public function search_by_keyword($keyword);
|
||||
|
||||
public function search_by_province($province_uuid);
|
||||
|
||||
public function search_all();
|
||||
|
||||
public function search_by_city($city_uuid);
|
||||
|
||||
public function search_by_uuid($uuid);
|
||||
|
||||
public function search_by_code($station_code);
|
||||
|
||||
public function update_content($value);
|
||||
|
||||
public function store($data);
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: root
|
||||
* Date: 9/26/18
|
||||
* Time: 4:34 PM
|
||||
*/
|
||||
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface SystemPreferenceResourceInterface
|
||||
{
|
||||
|
||||
public function getAll();
|
||||
|
||||
public function getByField($field,$value);
|
||||
|
||||
public function update($name, $value);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface TermsAndPrivacyResourceInterface
|
||||
{
|
||||
|
||||
public function listing($params);
|
||||
public function store($request);
|
||||
public function update($request);
|
||||
public function check($id);
|
||||
public function getByField($field, $value);
|
||||
public function delete($uuid);
|
||||
public function getDetailsWhereIn($field,$value,$relationship = null);
|
||||
public function getAllActive();
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface TopUpResourceInterface
|
||||
{
|
||||
|
||||
// public function getAll();
|
||||
|
||||
public function listing($params);
|
||||
public function store($request);
|
||||
public function update($request);
|
||||
public function check($id);
|
||||
public function getByField($field, $value);
|
||||
public function delete($uuid);
|
||||
public function getDetailsWhereIn($field,$value,$relationship = null);
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface UserResourceInterface
|
||||
{
|
||||
|
||||
public function getAll();
|
||||
|
||||
public function getUsername($username, $type = 1);
|
||||
|
||||
public function store(Request $request, $type);
|
||||
|
||||
public function store_member($data);
|
||||
|
||||
public function changePassword(Request $request, $username);
|
||||
|
||||
public function updateAdmin(Request $request, $username);
|
||||
|
||||
public function updateMember(Request $request, $username);
|
||||
|
||||
public function delete($uuid);
|
||||
|
||||
public function force_logout($username, $type = 1);
|
||||
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $exception)
|
||||
{
|
||||
parent::report($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
{
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Contracts\MobileAnalyticsResourceInterface;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Libraries\ParameterHelper;
|
||||
|
||||
class ReportMobileUsageExport implements FromCollection
|
||||
{
|
||||
private $mobileAnalytics;
|
||||
|
||||
public function __construct(MobileAnalyticsResourceInterface $mobileAnalytics)
|
||||
{
|
||||
$this->mobileAnalytics = $mobileAnalytics;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$request = request();
|
||||
|
||||
$params = [
|
||||
'page_size' => null,
|
||||
'page' => null,
|
||||
'date_start' => ($request->has('date_start') ? $request->get('date_start') : null),
|
||||
'date_end' => ($request->has('date_end') ? $request->get('date_end') : null),
|
||||
'sorting' => ParameterHelper::prepareSortingParameter($request)
|
||||
];
|
||||
|
||||
|
||||
if(ParameterHelper::validateStartEndDate($params))
|
||||
{
|
||||
return $this->format->unprocessableEntity('Start date must not be greater than end date');
|
||||
}
|
||||
|
||||
$list = $this->mobileAnalytics->report_mobileUsage($params, true);
|
||||
|
||||
$data = collect([['Date', 'Active', 'Inactive', 'Locked']]);
|
||||
|
||||
if($list->count())
|
||||
{
|
||||
foreach ($list as $key => $value) {
|
||||
$data->push([
|
||||
date('d-M-Y',strtotime($value->date)),
|
||||
$value->active == 0 ? "0" : $value->active,
|
||||
$value->inactive == 0 ? "0" : $value->inactive,
|
||||
$value->locked == 0 ? "0" : $value->locked,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Contracts\RegistrationResourceInterface;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Libraries\ParameterHelper;
|
||||
|
||||
class ReportRegistrationExport implements FromCollection
|
||||
{
|
||||
private $register;
|
||||
|
||||
public function __construct(RegistrationResourceInterface $register)
|
||||
{
|
||||
$this->register = $register;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$request = request();
|
||||
|
||||
$params = [
|
||||
'page_size' => null,
|
||||
'page' => null,
|
||||
'date_start' => ($request->has('date_start') ? $request->get('date_start') : null),
|
||||
'date_end' => ($request->has('date_end') ? $request->get('date_end') : null),
|
||||
'sorting' => ParameterHelper::prepareSortingParameter($request)
|
||||
];
|
||||
|
||||
$list = $this->register->report_registration($params, true);
|
||||
$data = collect([['Date', 'Activated', 'Registered']]);
|
||||
|
||||
if($list->count())
|
||||
{
|
||||
|
||||
foreach ($list as $key => $value) {
|
||||
$data->push([
|
||||
date('d-M-Y',strtotime($value->created_at)),
|
||||
$value->activated == 0 ? "0" : $value->activated,
|
||||
$value->registered == 0 ? "0" : $value->registered,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Contracts\RatingsResourceInterface;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Libraries\ParameterHelper;
|
||||
|
||||
class ReportStationRatingsExport implements FromCollection
|
||||
{
|
||||
private $ratings;
|
||||
|
||||
public function __construct(RatingsResourceInterface $ratings)
|
||||
{
|
||||
$this->ratings = $ratings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$request = request();
|
||||
|
||||
$params = [
|
||||
'search' => ($request->has('_search') ? $request->get('_search') : NULL),
|
||||
'page_size' => null,
|
||||
'page' => null,
|
||||
'date_start' => ($request->has('date_start') ? $request->get('date_start') : null),
|
||||
'date_end' => ($request->has('date_end') ? $request->get('date_end') : null),
|
||||
'sorting' => ParameterHelper::prepareSortingParameter($request)
|
||||
];
|
||||
|
||||
|
||||
if(ParameterHelper::validateStartEndDate($params))
|
||||
{
|
||||
return $this->format->unprocessableEntity('Start date must not be greater than end date');
|
||||
}
|
||||
|
||||
$list = $this->ratings->report_stationRatings($params, true);
|
||||
|
||||
$data = collect([['Transaction Date & Time', 'Card Number', 'Sales Invoice', 'Station', 'Ratings']]);
|
||||
|
||||
if($list->count())
|
||||
{
|
||||
foreach ($list as $key => $value) {
|
||||
$data->push( [
|
||||
date('d-M-Y h:i A',strtotime($value->created_at)),
|
||||
'="' .$value->loyaltyCard->card_number. '"',
|
||||
$value->payment->trans_num,
|
||||
$value->station->description,
|
||||
$value->rate
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Contracts\PaymentResourceInterface;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Libraries\ParameterHelper;
|
||||
|
||||
class ReportTopUpExport implements FromCollection
|
||||
{
|
||||
|
||||
private $payments;
|
||||
|
||||
public function __construct(PaymentResourceInterface $payments)
|
||||
{
|
||||
$this->payments = $payments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$request = request();
|
||||
|
||||
$params = [
|
||||
'search' => ($request->has('_search') ? $request->get('_search') : NULL),
|
||||
'page_size' => null,
|
||||
'page' => null,
|
||||
'date_start' => ($request->has('date_start') ? $request->get('date_start') : null),
|
||||
'date_end' => ($request->has('date_end') ? $request->get('date_end') : null),
|
||||
'sorting' => ParameterHelper::prepareSortingParameter($request)
|
||||
];
|
||||
|
||||
if(ParameterHelper::validateStartEndDate($params))
|
||||
{
|
||||
return $this->format->unprocessableEntity('Start date must not be greater than end date');
|
||||
}
|
||||
|
||||
$list = $this->payments->report_topUp($params, true);
|
||||
|
||||
$data = collect([['Date & Time', 'Card Number', 'Amount']]);
|
||||
|
||||
if($list->count())
|
||||
{
|
||||
foreach ($list as $key => $value) {
|
||||
$data->push( [
|
||||
date('d-M-Y h:i A',strtotime($value->paid_at)),
|
||||
'="' .$value->loyaltyCard->card_number. '"',
|
||||
$value->amount,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FuelTracker extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Table name of model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'fuel_tracker';
|
||||
|
||||
/**
|
||||
* Primary key field name of table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'fueltracker_id';
|
||||
|
||||
/**
|
||||
* Additional fields from other connected tables
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['fueltracker_id','created_at','updated_at','created_by','updated_by','is_active'];
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Admin;
|
||||
use App\LoyaltyCard;
|
||||
|
||||
class CurrentUserHelper
|
||||
{
|
||||
public static function get_currentAdmin()
|
||||
{
|
||||
$auth = Auth::user();
|
||||
|
||||
if($auth)
|
||||
{
|
||||
$admin = Admin::where('username',$auth->username)
|
||||
->where('is_active',1)
|
||||
->get()
|
||||
->first();
|
||||
|
||||
if($admin)
|
||||
return $admin;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static function getAdminName($id)
|
||||
{
|
||||
$admin = Admin::where('admin_id',$id)->get()->first();
|
||||
|
||||
if($admin)
|
||||
return ucwords($admin->firstname." ".$admin->lastname);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function get_currentMember()
|
||||
{
|
||||
$auth = Auth::user();
|
||||
if($auth)
|
||||
{
|
||||
$member = LoyaltyCard::with('personalDetails')
|
||||
->join('users', 'loyalty_card.card_number' , '=', 'users.username')
|
||||
->select('users.name', 'loyalty_card.*')
|
||||
->where('loyalty_card.card_number',$auth->username)
|
||||
->where('loyalty_card.is_active',1)
|
||||
->get()
|
||||
->first();
|
||||
if($member)
|
||||
return $member;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static function get_currentUser()
|
||||
{
|
||||
$auth = Auth::user();
|
||||
if($auth) return $auth;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function get_member_by_lcard($lcard_uuid)
|
||||
{
|
||||
$member = LoyaltyCard::with('personalDetails')
|
||||
->where('lcard_uuid',$lcard_uuid)
|
||||
->where('is_active',1)
|
||||
->get()
|
||||
->first();
|
||||
|
||||
if($member){
|
||||
return $member;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,385 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Earwin Delos Santos
|
||||
* Date: 12 Nov 2017
|
||||
* Time: 7:49 PM
|
||||
*/
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
|
||||
use App\Contracts\HttpStatusCodeInterface;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
|
||||
class HttpStatusCode implements HttpStatusCodeInterface
|
||||
{
|
||||
/**
|
||||
* Standard response for successful HTTP requests. The actual response will depend on the request method used.
|
||||
* In a GET request, the response will contain an entity corresponding to the requested resource.
|
||||
* In a POST request, the response will contain an entity describing or containing the result of the action.[7]
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function success($message="SUCCESS",$content=array(), $withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'code'=>200,
|
||||
'message'=>$message,
|
||||
'data' => $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,$return['code']);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The request has been fulfilled, resulting in the creation of a new resource
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function created($message="CREATED",$content=array(),$withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'code'=>201,
|
||||
'message'=>$message,
|
||||
'data' => $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,$return['code']);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The server successfully processed the request and is not returning any data.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function noContent($message="NO CONTENT",$content=array(),$withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'code'=>204,
|
||||
'message'=>$message,
|
||||
'data' => $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,$return['code']);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The server successfully processed the request, but is not returning any data.
|
||||
* Unlike a 204 response, this response requires that the requester reset the document view.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function resetContent($message="RESET CONTENT",$content=array(),$withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'code'=>205,
|
||||
'message'=>$message,
|
||||
'data' => $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,$return['code']);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The server is delivering only part of the resource (byte serving) due to a range header sent by the client.
|
||||
* The range header is used by HTTP clients to enable resuming of interrupted downloads,
|
||||
* or split a download into multiple simultaneous streams.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function partialContent($message="PARTIAL CONTENT",$content=array(),$withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'code'=>206,
|
||||
'message'=>$message,
|
||||
'data' => $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,$return['code']);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The server cannot or will not process the request due to an apparent client error
|
||||
* (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing)
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function badRequest($message="BAD REQUEST",$content=array(),$withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'code'=>400,
|
||||
'message'=>$message,
|
||||
'data' => $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,$return['code']);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet been provided.
|
||||
* The response must include a WWW-Authenticate header field containing a challenge applicable to the requested resource.
|
||||
* See Basic access authentication and Digest access authentication.
|
||||
* 401 semantically means "unauthenticated",[34] i.e. the user does not have the necessary credentials.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function unauthorized($message="UNAUTHORIZED",$content=array(),$withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'code'=>401,
|
||||
'message'=>$message,
|
||||
'data' => $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,$return['code']);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The request was a valid request, but the server is refusing to respond to it.
|
||||
* The user might be logged in but does not have the necessary permissions for the resource.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function forbidden($message="FORBIDDEN",$content=array(),$withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'code'=>403,
|
||||
'message'=>$message,
|
||||
'data' => $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,$return['code']);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The requested resource could not be found but may be available in the future.
|
||||
* Subsequent requests by the client are permissible.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function notFound($message="NOT FOUND",$content=array(),$withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'code'=>404,
|
||||
'message'=>$message,
|
||||
'data' => $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,$return['code']);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The request is larger than the server is willing or able to process.
|
||||
* Previously called "Request Entity Too Large".
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function payloadToLarge($message="PAYLOAD TO LARGE",$content=array(),$withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'code'=>413,
|
||||
'message'=>$message,
|
||||
'data' => $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,$return['code']);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The request was well-formed but was unable to be followed due to semantic errors
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function unprocessableEntity($message="Unprocessable Entity",$content=array(),$withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'code'=>422,
|
||||
'message'=>$message,
|
||||
'data' => $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,$return['code']);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error found during process
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function applicationValidationErrorCode($message="Error found",$content=array(),$withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'code'=>400,
|
||||
'message'=>$message,
|
||||
'data' => $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,$return['code']);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* A code of 498 indicates an expired or otherwise invalid token.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function invalidToken($message="INVALID TOKEN",$content=array(),$withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'code'=>498,
|
||||
'message'=>$message,
|
||||
'data' => $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,$return['code']);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* A code of 499 indicates that a token is required but was not submitted.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function requiredToken($message="REQUIRED TOKEN",$content=array(),$withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'code'=>499,
|
||||
'message'=>$message,
|
||||
'data' => $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,$return['code']);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function internalServerError($message="INTERNAL SERVER ERROR",$content=array(),$withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'code'=>500,
|
||||
'message'=>$message,
|
||||
'data' => $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,$return['code']);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mobile Success Response
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function mobile_success($message="Success",$content=null, $withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'status'=>1,
|
||||
'message'=>$message,
|
||||
'data' => is_null($content) ? (object)[] : $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,200);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mobile Error Response
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $content
|
||||
* @return Response object
|
||||
*/
|
||||
public function mobile_error($message="Error",$content=null, $withJson = true)
|
||||
{
|
||||
$return = [
|
||||
'status'=>0,
|
||||
'message'=>$message,
|
||||
'data' => is_null($content) ? (object)[] : $content
|
||||
];
|
||||
|
||||
if($withJson)
|
||||
return Response::json($return,200);
|
||||
else
|
||||
return $return;
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
class StringHelper
|
||||
{
|
||||
public static function random_string($length = 16, $specialCharacters = 0)
|
||||
{
|
||||
|
||||
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$temp = substr(str_shuffle(str_repeat($pool, 5)), 0, ($length - $specialCharacters));
|
||||
if($specialCharacters > 0)
|
||||
{
|
||||
$SCPool = '!"#$%&()*+,-./:;<=>?@[\]^_`{|}~';
|
||||
$temp .= substr(str_shuffle(str_repeat($SCPool, 5)), 0, $specialCharacters);
|
||||
}
|
||||
|
||||
// return substr(str_shuffle(str_repeat($pool, 5)), 0, $length);
|
||||
return str_shuffle($temp);
|
||||
}
|
||||
|
||||
public static function random_num($length = 16)
|
||||
{
|
||||
|
||||
$pool = '0123456789';
|
||||
|
||||
return substr(str_shuffle(str_repeat($pool, 5)), 0, $length);
|
||||
}
|
||||
|
||||
public static function check_time_exceeded($from, $interval, $to = null)
|
||||
{
|
||||
|
||||
$from = strtotime($interval, strtotime($from));
|
||||
$to = ($to == null) ? strtotime(date('Y-m-d H:i:s')) : strotime($to);
|
||||
|
||||
if($from > $to )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static function check_date_if_between($from, $to, $now = null)
|
||||
{
|
||||
if($now == null)
|
||||
$now = date('Y-m-d H:i:s');
|
||||
|
||||
$from = strtotime($from);
|
||||
$to = strtotime($to);
|
||||
$now = strtotime($now);
|
||||
|
||||
if(($now > $from) && ($now < $to))
|
||||
return 'On-Going';
|
||||
elseif($now < $from)
|
||||
return 'Pending';
|
||||
else
|
||||
return 'Done';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Binary file not shown.
|
@ -1,336 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Contracts\SystemPreferenceResourceInterface;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use Validator;
|
||||
use App\Http\Requests\AdminFormValidation;
|
||||
use App\Contracts\UserResourceInterface;
|
||||
use App\Contracts\AdminResourceInterface;
|
||||
use App\Contracts\PasswordLogsResourceInterface;
|
||||
use App\Contracts\AdminActionLogsInterface;
|
||||
use App\Libraries\ParameterHelper;
|
||||
use App\Helpers\CurrentUserHelper;
|
||||
use App\Helpers\StringHelper;
|
||||
use App\Http\Resources\AdminResource;
|
||||
use App\Libraries\StaticContents;
|
||||
|
||||
|
||||
|
||||
class AdminController extends Controller
|
||||
{
|
||||
const MODULE = 'USERMANAGEMENT';
|
||||
|
||||
public $admin;
|
||||
|
||||
public $user;
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $module;
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $password_logs;
|
||||
|
||||
protected $admin_logs;
|
||||
|
||||
protected $systemPreference;
|
||||
|
||||
public function __construct(AdminResourceInterface $admin, HttpStatusCode $httpStatusCode, UserResourceInterface $user, PasswordLogsResourceInterface $password_logs, AdminActionLogsInterface $admin_logs, SystemPreferenceResourceInterface $systemPreference)
|
||||
{
|
||||
$this->admin = $admin;
|
||||
$this->user = $user;
|
||||
$this->format = $httpStatusCode;
|
||||
$this->module = "admin";
|
||||
$this->model = "admin";
|
||||
$this->password_logs = $password_logs;
|
||||
$this->admin_logs = $admin_logs;
|
||||
$this->systemPreference = $systemPreference;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$params = [
|
||||
'search' => ($request->has('_search') ? $request->get('_search') : NULL),
|
||||
'page_size' => ($request->has('page_size') ? $request->get('page_size') : 10),
|
||||
'page' => ($request->has('page') ? $request->get('page') : 10),
|
||||
'sorting' => ParameterHelper::prepareSortingParameter($request),
|
||||
'filter' => [
|
||||
'role' => ($request->has('role') ? $request->get('role') : null),
|
||||
'status' => ($request->has('status') ? $request->get('status') : null)
|
||||
]
|
||||
];
|
||||
|
||||
$list = $this->admin->listing($params);
|
||||
|
||||
|
||||
|
||||
if(count($list))
|
||||
{
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = AdminResource::collection($list)->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->success("No records found",[]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(AdminFormValidation $request)
|
||||
{
|
||||
$id = $this->admin->store($request);
|
||||
if($id)
|
||||
{
|
||||
$this->user->store($request, 1);
|
||||
$this->admin_logs->log($id,self::MODULE,'STORE');
|
||||
|
||||
return $this->format->created();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->notFound();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($uuid)
|
||||
{
|
||||
$details = $this->admin->getByField(['admin_uuid' => $uuid]);
|
||||
|
||||
if($details->count())
|
||||
{
|
||||
$details = $details[0];
|
||||
|
||||
// check if there's existing generated password
|
||||
$last_password_log = $this->password_logs->getLastLog($details['admin_id']);
|
||||
|
||||
if($last_password_log)
|
||||
{
|
||||
$hasExceeded = StringHelper::check_time_exceeded($last_password_log['created_dt'], '+15 minutes');
|
||||
|
||||
if($last_password_log['is_generated'] == 1 && $hasExceeded == true)
|
||||
{
|
||||
$details['generated_password'] = $last_password_log['generated_password'];
|
||||
}
|
||||
}
|
||||
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = (new AdminResource($details))->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(AdminFormValidation $request, $uuid)
|
||||
{
|
||||
// get old data
|
||||
$old_data = $this->admin->getByField(['admin_uuid' => $uuid]);
|
||||
|
||||
if($old_data->count())
|
||||
{
|
||||
if($this->admin->update($request,$uuid))
|
||||
{
|
||||
$this->user->updateAdmin($request, $old_data[0]['username']);
|
||||
|
||||
|
||||
if($request->has('password'))
|
||||
{
|
||||
$currentUser = CurrentUserHelper::get_currentAdmin();
|
||||
$this->password_logs->store($old_data[0]['admin_id'],$request->get('password'),$currentUser->admin_id, true);
|
||||
}
|
||||
|
||||
$this->admin_logs->log($old_data[0]['admin_id'],self::MODULE,'UPDATE');
|
||||
return $this->format->success("ADMIN UPDATED");
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->badRequest('Something went wrong');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($uuid)
|
||||
{
|
||||
$admin_details = $this->admin->getByField(['admin_uuid' => $uuid]);
|
||||
|
||||
if($admin_details->count())
|
||||
{
|
||||
$currentUser = CurrentUserHelper::get_currentAdmin();
|
||||
|
||||
if($admin_details[0]['admin_id'] != $currentUser->admin_id)
|
||||
{
|
||||
$user_details = $this->user->getUsername($admin_details[0]['username']);
|
||||
$this->admin->delete($uuid);
|
||||
if($this->user->delete($user_details['id']) ){
|
||||
$this->admin_logs->log($admin_details[0]['admin_id'],self::MODULE,'DELETE');
|
||||
return $this->format->success("Admin Successfully Deleted");
|
||||
}
|
||||
}
|
||||
else
|
||||
return $this->format->badRequest('Cannot delete own account');
|
||||
}
|
||||
else
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
public function batch_delete(Request $request)
|
||||
{
|
||||
$admin_uuid = $request->has('admin_uuid') ? $request->get('admin_uuid') : null;
|
||||
|
||||
if($admin_uuid)
|
||||
{
|
||||
$admin_details = $this->admin->getDetailsWhereIn('admin_uuid',$admin_uuid,'user');
|
||||
$currentUser = CurrentUserHelper::get_currentAdmin();
|
||||
|
||||
$id = array();
|
||||
|
||||
foreach ($admin_details as $key => $value)
|
||||
{
|
||||
if($value['admin_id'] != $currentUser->admin_id)
|
||||
{
|
||||
$id[] = $value['user']['id'];
|
||||
$this->admin_logs->log($value['admin_id'],self::MODULE,'DELETE');
|
||||
}
|
||||
else
|
||||
return $this->format->badRequest('Cannot delete own acount');
|
||||
}
|
||||
|
||||
if($this->admin->delete($admin_uuid) && $this->user->delete($id))
|
||||
{
|
||||
return $this->format->success("Admin Successfully Deleted");
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->badRequest('Something went wrong');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['admin_uuid'] = 'admin_uuid is required';
|
||||
return $this->format->unprocessableEntity("Submit at least one admin",$data);
|
||||
}
|
||||
}
|
||||
|
||||
public function generate_password(Request $request)
|
||||
{
|
||||
$admin_uuid = ($request->has('admin_uuid') ? $request->get('admin_uuid') : NULL);
|
||||
|
||||
if($admin_uuid == NULL)
|
||||
{
|
||||
$data['password'] = StringHelper::random_string(8,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['password'] = StringHelper::random_string(8,1);
|
||||
$admin = $this->admin->getByField(['admin_uuid' => $admin_uuid]);
|
||||
$logs = $this->password_logs->getByField(['admin_id' => $admin[0]['admin_id']]);
|
||||
|
||||
if(count($logs) > 0)
|
||||
{
|
||||
$ctr = 1;
|
||||
foreach ($logs as $key => $value) {
|
||||
if($ctr <= 2)
|
||||
{
|
||||
if($value['password'] == md5($data['password']))
|
||||
$data['password'] = StringHelper::random_string(8,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $this->format->success("Password Generated",$data);
|
||||
}
|
||||
|
||||
public function myProfile()
|
||||
{
|
||||
$currentUser = CurrentUserHelper::get_currentAdmin();
|
||||
|
||||
$admin = $this->admin->show($currentUser->admin_uuid);
|
||||
|
||||
$rpreference = $this->systemPreference->getByField('name', 'logo');
|
||||
$admin->logo = $rpreference[0]->value;
|
||||
|
||||
if ($admin){
|
||||
return $this->format->success("SUCCESS",$admin);
|
||||
|
||||
}else{
|
||||
return $this->format->notFound();
|
||||
}
|
||||
}
|
||||
|
||||
public function changeStatus(Request $request)
|
||||
{
|
||||
$admin_uuid = ($request->has('admin_uuid') ? $request->get('admin_uuid') : NULL);
|
||||
$old_data = $this->admin->getByField(['admin_uuid' => $admin_uuid]);
|
||||
|
||||
if($old_data->count())
|
||||
{
|
||||
$currentUser = CurrentUserHelper::get_currentAdmin();
|
||||
|
||||
if($old_data[0]['admin_id'] != $currentUser->admin_id)
|
||||
{
|
||||
// $newStatus = $old_data[0]['status'] == 0 ? 1 : 0;
|
||||
$newStatus = StaticContents::admin_status($request->get('status'), true);
|
||||
|
||||
if($this->admin->changeStatus($newStatus,$admin_uuid))
|
||||
{
|
||||
|
||||
if($newStatus == 1)
|
||||
{
|
||||
$this->user->force_logout($old_data[0]['username']);
|
||||
}
|
||||
|
||||
$this->admin_logs->log($old_data[0]['admin_id'],self::MODULE,'UPDATE','Changed Status to '.($newStatus == 1 ? "inactive" : "active"));
|
||||
return $this->format->success("User Account is ".($newStatus == 1 ? "deactivated" : "activated"),["status" => ($newStatus == 1 ? "inactive" : "active")]);
|
||||
}
|
||||
}
|
||||
else
|
||||
return $this->format->badRequest('Cannot update own acount');
|
||||
}
|
||||
|
||||
return $this->format->notFound();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,263 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Contracts\CardTypeResourceInterface;
|
||||
use App\Contracts\AdminActionLogsInterface;
|
||||
use App\Http\Resources\CardTypeResource;
|
||||
use App\Libraries\ParameterHelper;
|
||||
use App\Helpers\CurrentUserHelper;
|
||||
use App\Helpers\StringHelper;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use App\Http\Requests\CardTypeFormValidation;
|
||||
use App\Libraries\S3;
|
||||
|
||||
class CardTypeController extends Controller
|
||||
{
|
||||
const MODULE = 'CARDTYPES';
|
||||
|
||||
public $cardType;
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $module;
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $admin_logs;
|
||||
|
||||
public function __construct(CardTypeResourceInterface $cardType, HttpStatusCode $httpStatusCode,AdminActionLogsInterface $admin_logs)
|
||||
{
|
||||
$this->cardType = $cardType;
|
||||
$this->format = $httpStatusCode;
|
||||
$this->module = "cardType";
|
||||
$this->model = "cardType";
|
||||
$this->admin_logs = $admin_logs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$params = [
|
||||
'search' => ($request->has('_search') ? $request->get('_search') : NULL),
|
||||
'page_size' => ($request->has('page_size') ? $request->get('page_size') : 10),
|
||||
'page' => ($request->has('page') ? $request->get('page') : 10),
|
||||
'sorting' => ParameterHelper::prepareSortingParameter($request)
|
||||
];
|
||||
|
||||
$list = $this->cardType->listing($params);
|
||||
|
||||
if(count($list))
|
||||
{
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = CardTypeResource::collection($list)->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->success("No records found",[]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(CardTypeFormValidation $request)
|
||||
{
|
||||
$id = $this->cardType->store($request);
|
||||
|
||||
if($id)
|
||||
{
|
||||
$this->admin_logs->log($id,self::MODULE,'STORE');
|
||||
|
||||
return $this->format->created('Card Type has been added');
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->notFound();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($uuid)
|
||||
{
|
||||
$details = $this->cardType->getByField(['cardtype_uuid' => $uuid]);
|
||||
|
||||
if($details->count())
|
||||
{
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = (new CardTypeResource($details[0]))->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(CardTypeFormValidation $request, $uuid)
|
||||
{
|
||||
$old_data = $this->cardType->getByField(['cardtype_uuid' => $uuid]);
|
||||
|
||||
if($old_data->count())
|
||||
{
|
||||
if($this->cardType->update($request,$uuid))
|
||||
{
|
||||
$this->admin_logs->log($old_data[0]['cardtype_id'],self::MODULE,'UPDATE');
|
||||
return $this->format->success("Card Type has been updated");
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->notFound();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($uuid)
|
||||
{
|
||||
$details = $this->cardType->getByField(['cardtype_uuid' => $uuid]);
|
||||
if($details->count())
|
||||
{
|
||||
$details = $details[0];
|
||||
if($this->cardType->delete($uuid))
|
||||
{
|
||||
$this->admin_logs->log($details['cardtype_id'],self::MODULE,'DELETE');
|
||||
return $this->format->success("Card Type Successfully Deleted");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
public function batch_delete(Request $request)
|
||||
{
|
||||
$uuid = $request->has('cardtype_uuid') ? $request->get('cardtype_uuid') : null;
|
||||
|
||||
if($uuid)
|
||||
{
|
||||
$details = $this->cardType->getDetailsWhereIn('cardtype_uuid',$uuid);
|
||||
|
||||
|
||||
$id = array();
|
||||
|
||||
if($this->cardType->delete($uuid))
|
||||
{
|
||||
foreach ($details as $key => $value)
|
||||
{
|
||||
$this->admin_logs->log($value['cardtype_id'],self::MODULE,'DELETE');
|
||||
}
|
||||
|
||||
return $this->format->success("Card Type Successfully Deleted");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->badRequest('Something went wrong');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['cardtype_uuid'] = 'cardtype_uuid is required';
|
||||
return $this->format->unprocessableEntity("Submit at least one item",$data);
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllCardType()
|
||||
{
|
||||
$data = $this->cardType->getAllCardType();
|
||||
if (count($data) < 1){
|
||||
return $this->format->mobile_error('please contact us');
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value){
|
||||
// $data[$key]['image'] = $value['image'] ? str_replace('https', 'http', str_replace('/public/index.php','',secure_url('storage/app/'.$value['image']))) : '' ;
|
||||
$data[$key]['image'] = $value['image'] ? S3::public_path($value['image']) : '' ;
|
||||
$data[$key]['bg_image'] = $value['bg_image'] ? S3::public_path($value['bg_image']) : '' ;
|
||||
$data[$key]['description'] = is_null($value['description']) ? "" : $value['description'];
|
||||
$data[$key]['terms_and_conditions'] = is_null($value['terms_and_conditions']) ? "" : $value['terms_and_conditions'];
|
||||
$data[$key]['faqs'] = is_null($value['faqs']) ? "" : $value['faqs'];
|
||||
|
||||
$data[$key]['details'] = [
|
||||
[
|
||||
"level"=>0,
|
||||
"title"=>"Description",
|
||||
"details"=>[[
|
||||
"level"=>1,
|
||||
"details"=>is_null($value['description']) ? "" : $value['description']
|
||||
]]
|
||||
],
|
||||
[
|
||||
"level"=>0,
|
||||
"title"=>"Terms and Conditions",
|
||||
"details"=>[[
|
||||
"level"=>1,
|
||||
"details"=>is_null($value['terms_and_conditions']) ? "" : $value['terms_and_conditions']
|
||||
]]
|
||||
],
|
||||
[
|
||||
"level"=>0,
|
||||
"title"=>"FAQS",
|
||||
"details"=>[[
|
||||
"level"=>1,
|
||||
"details"=>is_null($value['faqs']) ? "" : $value['faqs']
|
||||
]]
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
return $this->format->mobile_success('Sucess',$data);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,285 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Contracts\AdminResourceInterface;
|
||||
use App\Contracts\CityAndProvinceResourceInterface;
|
||||
use App\Contracts\StationResourceInterface;
|
||||
use App\Helpers\CurrentUserHelper;
|
||||
use App\Http\Requests\SystemPreferenceFormValidation;
|
||||
use App\Http\Resources\SystemPreferencesResource;
|
||||
use App\Libraries\StratuscastLibrary;
|
||||
use App\Libraries\RNRPHLibrary;
|
||||
use App\Services\CityAndProvinceService;
|
||||
use App\Services\StationService;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use App\Contracts\SystemPreferenceResourceInterface;
|
||||
|
||||
use Illuminate\Routing\UrlGenerator;
|
||||
|
||||
class CityAndProvinceController extends Controller
|
||||
{
|
||||
|
||||
public $cityAndProvince;
|
||||
public $station;
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $module;
|
||||
|
||||
protected $model;
|
||||
|
||||
public $admin;
|
||||
|
||||
|
||||
public function __construct(CityAndProvinceResourceInterface $cityAndProvince,HttpStatusCode $httpStatusCode, UrlGenerator $url, AdminResourceInterface $admin, StationResourceInterface $station)
|
||||
{
|
||||
|
||||
$this->cityAndProvince = $cityAndProvince;
|
||||
$this->station = $station;
|
||||
$this->format = $httpStatusCode;
|
||||
$this->module = "CitAndProvince";
|
||||
$this->model = "CitAndProvince";
|
||||
$this->url = $url;
|
||||
$this->admin = $admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(SystemPreferenceFormValidation $request)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*d
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function sync()
|
||||
{
|
||||
|
||||
$cyware = new StratuscastLibrary();
|
||||
$cyware->getCityAndProvince();
|
||||
if ($cyware->response['status_code'] == "200") {
|
||||
foreach ($cyware->response['data'] as $key => $value) {
|
||||
$province = $this->cityAndProvince->getProvinceByField("code", $value->province_code);
|
||||
$province_id = 0;
|
||||
|
||||
$data['code'] = $value->province_code;
|
||||
$data['name'] = $value->province_name;
|
||||
|
||||
if (isset($value->province_code)){
|
||||
if (count($province) == 0) {
|
||||
$province_id = $this->cityAndProvince->storeProvince($data);
|
||||
} else {
|
||||
$province_id = $province[0]->province_id;
|
||||
$data['province_id'] = $province_id;
|
||||
$this->cityAndProvince->updateProvince($data);
|
||||
}
|
||||
}
|
||||
|
||||
$city = $this->cityAndProvince->getCityByField("code", $value->city_code);
|
||||
$data['code'] = $value->city_code;
|
||||
$data['name'] = $value->city_name;
|
||||
|
||||
if (isset($value->city_code)){
|
||||
if (count($city) == 0) {
|
||||
$data['province_id'] = $province_id;
|
||||
$this->cityAndProvince->storeCity($data);
|
||||
} else {
|
||||
$data['province_id'] = $province_id;
|
||||
$data['city_id'] = $city[0]->city_id;
|
||||
$this->cityAndProvince->updateCity($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return $this->format->success("Success", []);
|
||||
|
||||
}else{
|
||||
return $this->format->success("Something went wrong",[]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function get_all()
|
||||
{
|
||||
$province_city = $this->cityAndProvince->getAllRelationship();
|
||||
|
||||
|
||||
$return = [];
|
||||
$previous_province = '';
|
||||
$ctr = 0;
|
||||
$current_array = [];
|
||||
|
||||
foreach ($province_city as $key => $province)
|
||||
{
|
||||
if($previous_province != $province->name)
|
||||
{
|
||||
if($ctr != 0)
|
||||
$return[] = $current_array;
|
||||
|
||||
$current_array = [];
|
||||
|
||||
$current_array['name'] = $province->name;
|
||||
$current_array['city'][] = [
|
||||
'name' => $province->city_name,
|
||||
'city_uuid' => $province->city_uuid,
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
$current_array['city'][] = [
|
||||
'name' => $province->city_name,
|
||||
'city_uuid' => $province->city_uuid,
|
||||
];
|
||||
}
|
||||
$previous_province = $province->name;
|
||||
$ctr++;
|
||||
}
|
||||
|
||||
return $this->format->mobile_success('Success',$return);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//RNRPH
|
||||
public function syncCityProvince()
|
||||
{
|
||||
|
||||
$rnrph = new RNRPHLibrary();
|
||||
$rnrph->getAllBranches();
|
||||
if (count($rnrph->response['data']) > 0) {
|
||||
$ids = [];
|
||||
$st = $this->cityAndProvince->getAllCities();
|
||||
foreach ($st as $key => $value) {
|
||||
array_push($ids,$value->city_id);
|
||||
}
|
||||
$this->cityAndProvince->disbale_cities($ids);
|
||||
foreach ($rnrph->response['data'] as $key => $value) {
|
||||
// $province = $this->cityAndProvince->getProvinceByField("code", $value->province_code);
|
||||
// $province_id = 0;
|
||||
|
||||
// $data['code'] = $value->province_code;
|
||||
// $data['name'] = $value->province_name;
|
||||
|
||||
// if (isset($value->province_code)){
|
||||
// if (count($province) == 0) {
|
||||
// $province_id = $this->cityAndProvince->storeProvince($data);
|
||||
// } else {
|
||||
// $province_id = $province[0]->province_id;
|
||||
// $data['province_id'] = $province_id;
|
||||
// $this->cityAndProvince->updateProvince($data);
|
||||
// }
|
||||
// }
|
||||
|
||||
$city = $this->cityAndProvince->getCityByField("code", $value->city_code);
|
||||
$data['code'] = $value->city_code;
|
||||
$data['name'] = $value->city_name;
|
||||
|
||||
if (isset($value->city_code)){
|
||||
if (count($city) == 0) {
|
||||
$this->cityAndProvince->storeCity($data);
|
||||
} else {
|
||||
$data['city_id'] = $city[0]->city_id;
|
||||
$this->cityAndProvince->updateCity($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return $this->format->success("Success", $rnrph->response['data']);
|
||||
|
||||
}else{
|
||||
return $this->format->success("Something went wrong",[]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function get_city_list()
|
||||
{
|
||||
$city = $this->cityAndProvince->getAllCities();
|
||||
$return = [];
|
||||
foreach ($city as $key => $value) {
|
||||
$station = $this->station->get_station_by_city_uuid($value->city_id);
|
||||
if(count($station) > 0){
|
||||
$return[] = $value;
|
||||
}
|
||||
}
|
||||
return $this->format->mobile_success('Success',$return);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Contracts\CodeCivilStatusResourceInterface;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
|
||||
class CodeCivilStatusController extends Controller
|
||||
{
|
||||
public $civilStatus;
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $module;
|
||||
|
||||
protected $model;
|
||||
|
||||
public function __construct(CodeCivilStatusResourceInterface $civilStatus,HttpStatusCode $httpStatusCode)
|
||||
{
|
||||
|
||||
$this->civilStatus = $civilStatus;
|
||||
$this->format = $httpStatusCode;
|
||||
}
|
||||
|
||||
public function get_all()
|
||||
{
|
||||
$data = $this->civilStatus->getAll();
|
||||
$return = [];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$return[] = [
|
||||
'name' => $value->description,
|
||||
'civilstatus_uuid' => $value->civilstatus_uuid
|
||||
];
|
||||
}
|
||||
|
||||
return $this->format->mobile_success('Success',$return);
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Contracts\CodeFuelTypeResourceInterface;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
|
||||
class CodeFuelTypeController extends Controller
|
||||
{
|
||||
public $fueltype;
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $module;
|
||||
|
||||
protected $model;
|
||||
|
||||
public function __construct(CodeFuelTypeResourceInterface $fueltype,HttpStatusCode $httpStatusCode)
|
||||
{
|
||||
|
||||
$this->fueltype = $fueltype;
|
||||
$this->format = $httpStatusCode;
|
||||
}
|
||||
|
||||
public function get_all()
|
||||
{
|
||||
$data = $this->fueltype->getAll();
|
||||
$return = [];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$return[] = [
|
||||
'name' => $value->description,
|
||||
'fueltype_uuid' => $value->fueltype_uuid
|
||||
];
|
||||
}
|
||||
|
||||
return $this->format->mobile_success('Success',$return);
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Contracts\CodeGenderResourceInterface;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
|
||||
class CodeGenderController extends Controller
|
||||
{
|
||||
|
||||
public $gender;
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $module;
|
||||
|
||||
protected $model;
|
||||
|
||||
public function __construct(CodeGenderResourceInterface $gender,HttpStatusCode $httpStatusCode)
|
||||
{
|
||||
|
||||
$this->gender = $gender;
|
||||
$this->format = $httpStatusCode;
|
||||
}
|
||||
|
||||
public function get_all()
|
||||
{
|
||||
$data = $this->gender->getAll();
|
||||
$return = [];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$return[] = [
|
||||
'name' => $value->description,
|
||||
'gender_uuid' => $value->gender_uuid
|
||||
];
|
||||
}
|
||||
|
||||
return $this->format->mobile_success('Success',$return);
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Contracts\CodeVehicleOwnResourceInterface;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
|
||||
class CodeVehicleOwnController extends Controller
|
||||
{
|
||||
|
||||
public $vehicleOwn;
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $module;
|
||||
|
||||
protected $model;
|
||||
|
||||
public function __construct(CodeVehicleOwnResourceInterface $vehicleOwn,HttpStatusCode $httpStatusCode)
|
||||
{
|
||||
|
||||
$this->vehicleOwn = $vehicleOwn;
|
||||
$this->format = $httpStatusCode;
|
||||
}
|
||||
|
||||
public function get_all()
|
||||
{
|
||||
$data = $this->vehicleOwn->getAll();
|
||||
$return = [];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$return[] = [
|
||||
'name' => $value->description,
|
||||
'vo_uuid' => $value->vo_uuid,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->format->mobile_success('Success',$return);
|
||||
}
|
||||
}
|
|
@ -1,176 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Contracts\FuelTrackerResourceInterface;
|
||||
use App\Contracts\LcardActionLogsInterface;
|
||||
use App\FuelTracker;
|
||||
use App\Http\Requests\FuelTrackerFormValidation;
|
||||
use App\Http\Requests\TopUpFormValidation;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Libraries\ParameterHelper;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use App\Http\Resources\TopUpResource;
|
||||
use App\Helpers\CurrentUserHelper;
|
||||
|
||||
class FuelTrackerController extends Controller
|
||||
{
|
||||
|
||||
public $fuel_tracker;
|
||||
public $lcard_logs;
|
||||
|
||||
protected $format;
|
||||
const MODULE = 'FUELTRACKER';
|
||||
|
||||
|
||||
public function __construct(HttpStatusCode $httpStatusCode, FuelTrackerResourceInterface $fuel_tracker,LcardActionLogsInterface $lcard_logs)
|
||||
{
|
||||
$this->lcard_logs = $lcard_logs;
|
||||
$this->fuel_tracker = $fuel_tracker;
|
||||
$this->format = $httpStatusCode;
|
||||
$this->module = "FuelTracker";
|
||||
$this->model = "FuelTracker";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$member_details = CurrentUserHelper::get_currentMember();
|
||||
|
||||
$list = $this->fuel_tracker->listing($member_details->lcard_id);
|
||||
|
||||
if(count($list)){
|
||||
$this->lcard_logs->log(0 ,self::MODULE,'VIEW','View Fuel Tracker');
|
||||
return $this->format->mobile_success('Success',$list);
|
||||
|
||||
}else{
|
||||
return $this->format->mobile_error('Empty');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
return "create";
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(FuelTrackerFormValidation $request)
|
||||
{
|
||||
$member_details = CurrentUserHelper::get_currentMember();
|
||||
if($member_details->lcard_id){
|
||||
$request->lcard_id = $member_details->lcard_id;
|
||||
$return = $this->fuel_tracker->store($request) ? $this->fuel_tracker->store($request) : false;
|
||||
$this->lcard_logs->log($return ,self::MODULE,'STORE','Added Fuel Tracker');
|
||||
|
||||
return $this->format->mobile_success('Success Added',[]);
|
||||
}
|
||||
|
||||
return $this->format->mobile_error('Empty');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($uuid)
|
||||
{
|
||||
$member_details = CurrentUserHelper::get_currentMember();
|
||||
|
||||
$details = FuelTracker::where(['fueltracker_uuid' => $uuid,'lcard_id' => $member_details->lcard_id, 'is_active' => 1])->first();
|
||||
if ($details){
|
||||
$this->lcard_logs->log($details->fueltracker_id ,self::MODULE,'VIEW','View Fuel Tracker');
|
||||
return $this->format->mobile_success('Success',$details);
|
||||
}
|
||||
return $this->format->mobile_error('Empty');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
return "edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(FuelTrackerFormValidation $request, $uuid)
|
||||
{
|
||||
$member_details = CurrentUserHelper::get_currentMember();
|
||||
|
||||
if ($uuid == null && empty($uuid)) {
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
$request->lcard_id = $member_details->lcard_id;
|
||||
$request->fueltracker_uuid = $uuid;
|
||||
|
||||
$details = $this->fuel_tracker->update($request);
|
||||
|
||||
if ($details){
|
||||
$this->lcard_logs->log($details['fueltracker_id'],self::MODULE,'UPDATE','Update Fuel Tracker');
|
||||
return $this->format->mobile_success('Success',$details);
|
||||
}
|
||||
|
||||
return $this->format->mobile_error('Error');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($uuid)
|
||||
{
|
||||
$member_details = CurrentUserHelper::get_currentMember();
|
||||
$details = $this->fuel_tracker->getByFieldAndLcardId('fueltracker_uuid',$uuid,$member_details->lcard_id);
|
||||
|
||||
if (!$details){
|
||||
return $this->format->mobile_error('not found');
|
||||
}
|
||||
|
||||
if(isset($details['0']))
|
||||
{
|
||||
$details = $details['0'];
|
||||
$fueltrack_id = $this->fuel_tracker->delete($uuid);
|
||||
if($fueltrack_id)
|
||||
{
|
||||
$this->lcard_logs->log($fueltrack_id,self::MODULE,'DELETE','Delete Fuel Tracker');
|
||||
return $this->format->mobile_success('Success',null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->format->mobile_error('not found');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Contracts\CardTypeResourceInterface;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
|
||||
class IDNumberTypeController extends Controller
|
||||
{
|
||||
const MODULE = 'IDNUMBERTYPE';
|
||||
|
||||
public $user;
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $module;
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $cardType;
|
||||
|
||||
public function __construct(CardTypeResourceInterface $cardType, HttpStatusCode $httpStatusCode)
|
||||
{
|
||||
$this->cardType = $cardType;
|
||||
$this->format = $httpStatusCode;
|
||||
$this->module = "IDNumberType";
|
||||
$this->model = "IDNumberType";
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function mobile_show($code)
|
||||
{
|
||||
$details = $this->cardType->getByField([
|
||||
'code' => $code,
|
||||
'is_active' => 1
|
||||
],['idNumberType']);
|
||||
|
||||
if(count($details) > 0)
|
||||
{
|
||||
if(count($details[0]->idNumberType) > 0)
|
||||
{
|
||||
$data = [];
|
||||
|
||||
foreach ($details[0]->idNumberType as $key => $value)
|
||||
{
|
||||
$data[$value->idnt_uuid] = $value->name;
|
||||
}
|
||||
|
||||
return $this->format->mobile_success('Success',$data);
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_success('Empty',[]);
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error('Card Type does not exist');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\InAppNotifications;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use App\Contracts\AdminActionLogsInterface;
|
||||
use App\Helpers\CurrentUserHelper;
|
||||
use App\Http\Resources\InAppNotificationResource;
|
||||
use App\Http\Requests\InAppNotificationFormValidation;
|
||||
use App\Admin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class InAppNotificationController extends Controller
|
||||
{
|
||||
public $top_up;
|
||||
public $admin_logs;
|
||||
|
||||
protected $format;
|
||||
const MODULE = 'NOTIFICATION';
|
||||
|
||||
public function __construct(HttpStatusCode $httpStatusCode, AdminActionLogsInterface $admin_logs)
|
||||
{
|
||||
$this->admin_logs = $admin_logs;
|
||||
$this->format = $httpStatusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$otp = DB::select('select * from otp_logs order by otplog_id desc limit 1');
|
||||
// Get all Notifications from the Notifications Table
|
||||
$list = InAppNotifications::all();
|
||||
if(!count($list)) return $this->format->success("No records found",[]); // Check if notifications are present and return the appropriate response
|
||||
return response()->json(["code"=>200,"message"=>"SUCCESS","data"=>$otp], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(InAppNotificationFormValidation $request)
|
||||
{
|
||||
// Check if admin is the one who is issuing the action.
|
||||
$currentUser = CurrentUserHelper::get_currentUser();
|
||||
$admin = Admin::where('username', $currentUser->username)->first();
|
||||
if(!$admin->admin_id) return $this->format->unauthorized(); // Check if it is the admin, otherwise return appropriate response
|
||||
|
||||
$notification = new InAppNotifications();
|
||||
$notification->subject = $request->get('subject');
|
||||
$notification->description = $request->get('description');
|
||||
$notification->trigger_schedule = $request->get('schedule') ? $request->get('schedule') : null;
|
||||
$notification->expiration_date = $request->get('expiration') or null;
|
||||
$notification->status = 0;
|
||||
|
||||
if(!$notification->save()) return $this->format->unprocessableEntity('Failed to create a notification.');
|
||||
|
||||
$id = $notification->id;
|
||||
$this->admin_logs->log($id,self::MODULE,'STORE');
|
||||
return $this->format->created('Notification has been created', ["id"=>$id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
// Show specific notification
|
||||
$data = InAppNotifications::where(['id' => $id])->first();
|
||||
if(!$data) return $this->format->notFound(); // Check if notifications are present and return the appropriate response
|
||||
return response()->json(["code"=>200,"message"=>"SUCCESS","data"=>$data], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(InAppNotificationFormValidation $request, $id)
|
||||
{
|
||||
// Check if ID is present, otherwise return a not found error.
|
||||
if(!$id) return $this->format->notFound();
|
||||
|
||||
// Check if admin is the one who is issuing the action.
|
||||
// $currentUser = CurrentUserHelper::get_currentUser();
|
||||
// $admin = Admin::where('username', $currentUser->username)->first();
|
||||
// if(!$admin->admin_id) return $this->format->unauthorized(); // Check if it is the admin, otherwise return appropriate response
|
||||
|
||||
$data = InAppNotifications::where(['id' => $id])->first();
|
||||
|
||||
if(!$data) return $this->format->notFound(); // Check if notifications are present and return the appropriate response
|
||||
|
||||
$data->subject = $request->get('subject');
|
||||
$data->description = $request->get('description');
|
||||
$data->status = $request->get('status');
|
||||
|
||||
if(!$data->save()) return $this->format->unprocessableEntity('Failed to update the notification');
|
||||
$id = $data->id;
|
||||
$this->admin_logs->log($id,self::MODULE,'STORE');
|
||||
return $this->format->success('Notification has been updated', ["id"=>$id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
// Check if ID is present, otherwise return a not found error.
|
||||
if(!$id) return $this->format->notFound();
|
||||
|
||||
$currentUser = CurrentUserHelper::get_currentUser();
|
||||
$admin = Admin::where('username', $currentUser->username)->first();
|
||||
if(!$admin->admin_id) return $this->format->unauthorized(); // Check if it is the admin, otherwise return appropriate response
|
||||
|
||||
$data = InAppNotifications::where(['id' => $id])->first();
|
||||
|
||||
if(!$data) return $this->format->notFound(); // Check if notifications are present and return the appropriate response
|
||||
|
||||
if(!$data->delete()) return $this->format->unprocessableEntity('Failed to delete the notification');
|
||||
$id = $data->id;
|
||||
$this->admin_logs->log($id,self::MODULE,'STORE');
|
||||
return $this->format->success('Notification has been deleted');
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use Validator;
|
||||
|
||||
use App\Contracts\LoyaltyCardResourceInterface;
|
||||
|
||||
class LoyaltyCardController extends Controller
|
||||
{
|
||||
public $loyaltyCard;
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $module;
|
||||
|
||||
protected $model;
|
||||
|
||||
public function __construct(LoyaltyCardResourceInterface $loyaltyCard,HttpStatusCode $httpStatusCode)
|
||||
{
|
||||
$this->loyaltyCard = $loyaltyCard;
|
||||
$this->format = $httpStatusCode;
|
||||
$this->module = "LoyaltyCard";
|
||||
$this->model = "LoyaltyCard";
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
if($this->loyaltyCard->store())
|
||||
{
|
||||
return $this->format->created();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->badRequest();
|
||||
}
|
||||
}
|
||||
|
||||
public function test_login()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -1,484 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use Validator;
|
||||
use App\Libraries\ParameterHelper;
|
||||
use App\Contracts\LoyaltyCardResourceInterface;
|
||||
use App\Contracts\PersonalDetailsResourceInterface;
|
||||
use App\Contracts\AdminActionLogsInterface;
|
||||
use App\Contracts\UserResourceInterface;
|
||||
use App\Contracts\LcardActionLogsInterface;
|
||||
use App\Contracts\SystemPreferenceResourceInterface;
|
||||
use App\Contracts\OtpAttemptsResourceInterface;
|
||||
use App\Contracts\OtpLogResourceInterface;
|
||||
use App\Contracts\MpinCodesResourceInterface;
|
||||
use App\Http\Resources\LoyaltyCardResource;
|
||||
use App\Http\Resources\MobileUserProfileResource;
|
||||
use App\Http\Requests\SecurityFormValidation;
|
||||
use App\Http\Requests\MpinFormValidation;
|
||||
use App\Contracts\MobileAnalyticsResourceInterface;
|
||||
use App\Libraries\StaticContents;
|
||||
use App\Http\Requests\MobileEditProfileFormValidation;
|
||||
use App\Libraries\CywareLibrary;
|
||||
use App\Helpers\CurrentUserHelper;
|
||||
use App\CodeCity;
|
||||
use App\Helpers\StringHelper;
|
||||
use App\Libraries\S3;
|
||||
|
||||
class MemberController extends Controller
|
||||
{
|
||||
const MODULE = 'MEMBERMANAGEMENT';
|
||||
|
||||
public $loyalty_card;
|
||||
|
||||
public $personal_details;
|
||||
|
||||
public $admin_logs;
|
||||
|
||||
public $user;
|
||||
|
||||
public $lcard_logs;
|
||||
|
||||
public $mobile_usage;
|
||||
|
||||
protected $system_preferences;
|
||||
|
||||
protected $otp_attempts;
|
||||
|
||||
protected $otp_logs;
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $mpin_codes;
|
||||
|
||||
public function __construct(LoyaltyCardResourceInterface $loyalty_card,
|
||||
HttpStatusCode $httpStatusCode,
|
||||
PersonalDetailsResourceInterface $personal_details,
|
||||
AdminActionLogsInterface $admin_logs,
|
||||
UserResourceInterface $user,
|
||||
LcardActionLogsInterface $lcard_logs,
|
||||
SystemPreferenceResourceInterface $system_preferences,
|
||||
OtpAttemptsResourceInterface $otp_attempts,
|
||||
OtpLogResourceInterface $otp_logs,
|
||||
MobileAnalyticsResourceInterface $mobile_usage,
|
||||
MpinCodesResourceInterface $mpin_codes)
|
||||
{
|
||||
$this->loyalty_card = $loyalty_card;
|
||||
$this->personal_details = $personal_details;
|
||||
$this->format = $httpStatusCode;
|
||||
$this->admin_logs = $admin_logs;
|
||||
$this->user = $user;
|
||||
$this->lcard_logs = $lcard_logs;
|
||||
$this->system_preferences = $system_preferences;
|
||||
$this->otp_attempts = $otp_attempts;
|
||||
$this->otp_logs = $otp_logs;
|
||||
$this->mobile_usage = $mobile_usage;
|
||||
$this->mpin_codes = $mpin_codes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$params = [
|
||||
'locked' => ($request->has('_locked') ? 1 : 0),
|
||||
'search' => ($request->has('_search') ? $request->get('_search') : NULL),
|
||||
'page_size' => ($request->has('page_size') ? $request->get('page_size') : 10),
|
||||
'page' => ($request->has('page') ? $request->get('page') : 10),
|
||||
'sorting' => ParameterHelper::prepareSortingParameter($request),
|
||||
'filter' => [
|
||||
'is_validated' => ($request->has('status') ? $request->get('status') : null)
|
||||
]
|
||||
];
|
||||
|
||||
$list = $this->loyalty_card->listing($params);
|
||||
|
||||
if(count($list))
|
||||
{
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = LoyaltyCardResource::collection($list)->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->success("No records found",[]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($uuid)
|
||||
{
|
||||
$details = $this->loyalty_card->show($uuid,['personalDetails','codeVehicleOwn','codeCivilStatus','codeGender','codeCardType']);
|
||||
|
||||
if($details)
|
||||
{
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = (new LoyaltyCardResource($details))->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This function is accessed from mobile
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(MobileEditProfileFormValidation $request)
|
||||
{
|
||||
$member_details = CurrentUserHelper::get_currentMember();
|
||||
|
||||
|
||||
// $city = $request->has('city_uuid') ? CodeCity::uuid($request->city_uuid)->first() : null;
|
||||
|
||||
|
||||
$cyware = new CywareLibrary();
|
||||
|
||||
$cyware->setCardNumber($member_details->card_number);
|
||||
$cyware->setFirstName($member_details->personalDetails->firstname);
|
||||
$cyware->setLastName($member_details->personalDetails->lastname);
|
||||
$cyware->setAddress($request->address);
|
||||
$cyware->setMobile('63'.$request->mobile);
|
||||
$cyware->setEmail($request->email);
|
||||
$cyware->setCivilStatusCode($request->civilstatus_code);
|
||||
$cyware->setGenderCode($request->gender_code);
|
||||
$cyware->setFuelType($request->fueltype_code);
|
||||
$cyware->setVehicleOwn($request->vo_code);
|
||||
$cyware->setCityCode($request->city);
|
||||
// if($city)
|
||||
// {
|
||||
// $cyware->setCityCode($city->code);
|
||||
// $request->merge(['city_id' => $city->city_id]);
|
||||
// }
|
||||
|
||||
$cyware->state_update();
|
||||
|
||||
if($cyware->response['status_code'] == "200" && $cyware->response['message'] == "success")
|
||||
{
|
||||
$this->loyalty_card->update($request, $member_details->lcard_id);
|
||||
// $this->user->updateMember($request, $member_details->card_number);
|
||||
$path = $this->personal_details->update($request, $member_details->personalDetails->pd_id);
|
||||
$this->lcard_logs->log($member_details->lcard_id,'PROFILE','UPDATE');
|
||||
|
||||
if($path)
|
||||
{
|
||||
// $photo_url = str_replace('/public/index.php','',secure_url('storage/app/'.$path));
|
||||
// $photo_url = str_replace('https','http',$photo_url);
|
||||
return $this->format->mobile_success('Profile updated',['photo' => S3::public_path($path)]);
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_success('Profile updated',['photo' => '']);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->mobile_error($cyware->response['message']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($uuid)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function batch_delete(Request $request)
|
||||
{
|
||||
$lcard_uuid = $request->has('lcard_uuid') ? $request->get('lcard_uuid') : null;
|
||||
|
||||
if($lcard_uuid)
|
||||
{
|
||||
$details_loyaltyCard = $this->loyalty_card->getDetailsWhereIn('lcard_uuid',$lcard_uuid,'personalDetails');
|
||||
$pd_uuid = array();
|
||||
|
||||
foreach ($details_loyaltyCard as $key => $value)
|
||||
{
|
||||
$pd_uuid[] = $value['personal_details']['pd_uuid'];
|
||||
$this->admin_logs->log($value['lcard_id'],self::MODULE,'DELETE');
|
||||
}
|
||||
|
||||
if($this->loyalty_card->delete($lcard_uuid) && $this->personal_details->delete($pd_uuid))
|
||||
{
|
||||
return $this->format->success("Member Successfully Deleted");
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->badRequest('Something went wrong');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['lcard_uuid'] = 'lcard_uuid is required';
|
||||
return $this->format->unprocessableEntity("Submit at least one user",$data);
|
||||
}
|
||||
}
|
||||
|
||||
public function activate_locked($uuid)
|
||||
{
|
||||
|
||||
$details = $this->loyalty_card->getByField(['lcard_uuid' => $uuid]);
|
||||
|
||||
if($details->count())
|
||||
{
|
||||
$details = $details[0];
|
||||
|
||||
if($this->loyalty_card->activate_locked($uuid))
|
||||
{
|
||||
$adminLog = $this->admin_logs->log($details['lcard_id'],self::MODULE,'ACTIVATE');
|
||||
$data['is_locked'] = false;
|
||||
return $this->format->success('User has been activated', $data);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
|
||||
// public function direct_update(MobileEditProfileFormValidation $request)
|
||||
// {
|
||||
// $status = $this->update($request);
|
||||
|
||||
// if($status == true)
|
||||
// {
|
||||
// return $this->format->mobile_success('Profile Details Updated', [
|
||||
// 'photo' =>
|
||||
// ]);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return $this->format->mobile_error($status);
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
public function confirm_otp(Request $request)
|
||||
{
|
||||
$member_details = CurrentUserHelper::get_currentMember();
|
||||
// lock after 3 attempts
|
||||
$numberOfAttempts = 0;
|
||||
|
||||
$attempts = $this->loyalty_card->numberOfOTPAttempts($member_details->lcard_uuid);
|
||||
|
||||
if(!is_null($attempts))
|
||||
{
|
||||
$numberOfAttempts = $attempts->otpAttempts->count();
|
||||
}
|
||||
|
||||
if($numberOfAttempts >= 3)
|
||||
{
|
||||
|
||||
$customer_service_email = $this->system_preferences->getByField('name','contact_email_address_mobile');
|
||||
$customer_service_number = $this->system_preferences->getByField('name','contact_number_mobile');
|
||||
|
||||
return $this->format->mobile_error('You have entered the wrong OTP for 3 times. Your account is now locked for 24 hours and you will be logged out of the system.',[
|
||||
'code' => 1,
|
||||
'email' => $customer_service_email[0]['value'],
|
||||
'number' => $customer_service_number[0]['value'],
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$numberOfAttempts++;
|
||||
$this->otp_attempts->store($member_details->lcard_id,$request->otp);
|
||||
$this->lcard_logs->log($member_details->lcard_id,'OTP','ATTEMPT','Member entered otp '.$request->otp);
|
||||
|
||||
// check if correct
|
||||
|
||||
$otpLog = $this->otp_logs->getByField(['lcard_id' => $member_details->lcard_id, 'otp' => $request->otp]);
|
||||
if(count($otpLog))
|
||||
{
|
||||
$latestOtp = $this->otp_logs->getLastLog($member_details->lcard_id);
|
||||
|
||||
// checks if otp entered is expired and it's the latest otp created
|
||||
if(!StringHelper::check_time_exceeded($otpLog[0]['created_at'],'+5 minutes') || $latestOtp->otp != $request->otp)
|
||||
{
|
||||
if($numberOfAttempts >= 3)
|
||||
{
|
||||
return $this->format->mobile_error('You have entered the wrong OTP for 3 times. Your account is now locked for 24 hours, call or email customer service.',$this->lock_member($member_details));
|
||||
|
||||
$this->user->force_logout($member_details->card_number,2);
|
||||
}
|
||||
|
||||
return $this->format->mobile_error('The OTP you have entered has already expired. Please select the Resend OTP option',['code' => 3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->mobile_success('OTP Confirmed');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($numberOfAttempts >= 3)
|
||||
{
|
||||
return $this->format->mobile_error('You have entered the wrong OTP for 3 times. Your account is now locked for 24 hours, call or email customer service.',$this->lock_member($member_details));
|
||||
}
|
||||
|
||||
return $this->format->mobile_error('Incorrect OTP. The OTP you have entered does not exist.',['code' => 2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function lock_member($member_details)
|
||||
{
|
||||
$this->loyalty_card->lockMember($member_details->lcard_id,'02');
|
||||
$this->lcard_logs->log($member_details->lcard_id,'OTP','LOCKED','Account is locked due to wrong OTP entered when updating the mobile phone number');
|
||||
$this->mobile_usage->add_locked();
|
||||
|
||||
$customer_service_email = $this->system_preferences->getByField('name','contact_email_address_mobile');
|
||||
$customer_service_number = $this->system_preferences->getByField('name','contact_number_mobile');
|
||||
|
||||
return [
|
||||
'code' => 1,
|
||||
'email' => $customer_service_email[0]['value'],
|
||||
'number' => $customer_service_number[0]['value'],
|
||||
];
|
||||
}
|
||||
|
||||
public function myProfile()
|
||||
{
|
||||
$member_details = CurrentUserHelper::get_currentMember();
|
||||
$cyware = new CywareLibrary();
|
||||
$details = $this->loyalty_card->show($member_details->lcard_uuid,['personalDetails','codeVehicleOwn','codeCivilStatus','codeGender','codeCardType','codeCity','codeFuelType']);
|
||||
|
||||
if($details)
|
||||
{
|
||||
$cyware->setCardNumber($member_details->card_number);
|
||||
$cyware->state_retrieve();
|
||||
$additionals = $this->format->mobile_success("Success",[],false);
|
||||
$additionals["retrieved"] = $cyware->response["data"];
|
||||
$data = (new MobileUserProfileResource($details))->additional($additionals);
|
||||
//return $data->response()->setStatusCode(200);
|
||||
|
||||
//getmpin
|
||||
$mpin = $this->mpin_codes->getMpin($additionals["retrieved"]->customer_number);
|
||||
$dataResult = $this->StateRetrieve($data->response()->setStatusCode(200),$mpin);
|
||||
|
||||
return $dataResult;
|
||||
// return $this->StateRetrieve($data->response()->setStatusCode(200));
|
||||
}
|
||||
else
|
||||
return $this->format->notFound();
|
||||
|
||||
}
|
||||
|
||||
public function validateMember(SecurityFormValidation $request)
|
||||
{
|
||||
// $member_details = CurrentUserHelper::get_currentMember();
|
||||
// return $this->format->mobile_success($request->card_number,[
|
||||
// 'is_valid' => 0
|
||||
// ]);
|
||||
$cyware = new CywareLibrary();
|
||||
$cyware->setCardNumber($request->get('card_number'));
|
||||
$cyware->state_validate();
|
||||
|
||||
if ($cyware->response['status_code'] == "200" && $cyware->response['data'] != null)
|
||||
{
|
||||
if($cyware->response['data']->birthdate != $request->get('birthdate'))
|
||||
{
|
||||
return $this->format->mobile_error( 'Incorrect Birthdate');
|
||||
}
|
||||
|
||||
if(strtolower($cyware->response['data']->email) != strtolower($request->get('email_address')))
|
||||
{
|
||||
return $this->format->mobile_error( 'Incorrect Email');
|
||||
}
|
||||
return $this->format->mobile_success('Success',[
|
||||
'is_valid' => 1
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->mobile_error($cyware->response['message'], ['card_number' => $cyware->response['message']]);
|
||||
}
|
||||
}
|
||||
|
||||
public function StateRetrieve($data,$mpin){
|
||||
$newData = $data->getData();
|
||||
$mainData = [];
|
||||
$mainData["lcard_uuid"] = $newData->data->lcard_uuid;
|
||||
$mainData["card_number"] = $newData->data->card_number;
|
||||
$mainData["customer_number"] = $newData->retrieved->customer_number;
|
||||
$mainData["pin"] = $newData->data->pin;
|
||||
$mainData["birthdate"] = $newData->data->birthdate;
|
||||
$mainData["mobile"] = $newData->data->mobile;
|
||||
$mainData["email"] = $newData->data->email;
|
||||
$mainData["firstname"] = $newData->data->firstname;
|
||||
$mainData["lastname"] = $newData->data->lastname;
|
||||
$mainData["photo"] = $newData->data->photo;
|
||||
$mainData["card_type"] = $newData->data->card_type;
|
||||
$mainData["card_code"] = $newData->data->card_code;
|
||||
$mainData["card_image"] = $newData->data->card_image;
|
||||
$mainData["card_bg_image"] = $newData->data->card_bg_image;
|
||||
$mainData["card_black_label"] = $newData->data->card_black_label;
|
||||
$mainData["expiry_date"] = $newData->data->expiry_date;
|
||||
$mainData["points"] = $newData->data->points;
|
||||
//DATA THAT MUST GET FROM STATE RETRIEVE
|
||||
$mainData["middlename"] = $newData->retrieved->middle_initial;
|
||||
$mainData["city_name"] = $newData->retrieved->address;
|
||||
$mainData["address"] = $newData->retrieved->address;
|
||||
$mainData["civilstatus_code"] = $newData->retrieved->civil_status_code;
|
||||
$mainData["gender_code"] = $newData->retrieved->gender_code;
|
||||
$mainData["vo_code"] = $newData->retrieved->vehicle_own_code;
|
||||
$mainData["fueltype_code"] = $newData->retrieved->fuel_type_code;
|
||||
if($mpin){
|
||||
$mainData["mpin"] = $mpin->mpin_code;
|
||||
}
|
||||
//$mainData['log'] = "start:".$datestart." ---- end:".$dateend;
|
||||
$newData->data = $mainData;
|
||||
return response()->json($newData);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,198 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\PaymayaTokens;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\PaymayaTokenResource;
|
||||
use App\Contracts\LcardActionLogsInterface;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use App\Http\Requests\PaymayaTokenFormValidation;
|
||||
use App\Libraries\UuidHelper;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use App\Libraries\RNRPHLibrary;
|
||||
|
||||
|
||||
class PaymayaTokensController extends Controller
|
||||
{
|
||||
|
||||
public function __construct(
|
||||
HttpStatusCode $httpStatusCode,
|
||||
LcardActionLogsInterface $lcard_logs)
|
||||
{
|
||||
$this->format = $httpStatusCode;
|
||||
$this->lcard_logs = $lcard_logs;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
$list = PaymayaTokens::all();
|
||||
// $this->lcard_logs->log(0,'PAYMAYATOKEN','VIEW','Member view all paymaya tokens');
|
||||
return $this->format->mobile_success("Success", $list);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return $this->format->mobile_error('No Paymaya tokens found');
|
||||
}
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(PaymayaTokenFormValidation $request)
|
||||
{
|
||||
try {
|
||||
$data = PaymayaTokens::where('token',$request->get('token'))->where('is_active','<>',0)->get();
|
||||
if(count($data) > 0){
|
||||
return $this->format->mobile_error('Token already exist for '.$request->get('card_number'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$uuid = new UuidHelper;
|
||||
$paymayatoken = new PaymayaTokens();
|
||||
$paymayatoken->card_number = $request->get('card_number');
|
||||
$paymayatoken->customer_id = $request->get('customer_id');
|
||||
$paymayatoken->token = $request->get('token');
|
||||
$paymayatoken->is_active = 1;
|
||||
$paymayatoken->paymaya_token_uuid = $uuid->generate_uuid1();
|
||||
if(!$paymayatoken->save()) return $this->format->mobile_error('Failed to saved token.');
|
||||
// $this->lcard_logs->log(0,'PAYMAYATOKEN','STORE','Member store paymaya token');
|
||||
return $this->format->mobile_success('Paymaya token has been created', $paymayatoken);
|
||||
}
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return $this->format->mobile_error('Error saving');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\PaymayaTokens $paymayaTokens
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($card_number)
|
||||
{
|
||||
try {
|
||||
$data = PaymayaTokens::where('card_number',$card_number)->where('is_active','1')->get();
|
||||
|
||||
if(count($data) > 0){
|
||||
|
||||
$rnrph = new RNRPHLibrary();
|
||||
|
||||
// $this->lcard_logs->log(0,'PAYMAYATOKEN','VIEW','Member view paymaya token');
|
||||
$tokenData = [];
|
||||
$cards = [];
|
||||
|
||||
$rnrph->getPaymayaCustomerDetails($data[0]['customer_id']);
|
||||
$cardsData = $rnrph->response['data'];
|
||||
foreach($cardsData as $key => $cardDetail){
|
||||
$c = get_object_vars($cardDetail);
|
||||
$c["uuid"] = $data[0]["paymaya_token_uuid"];
|
||||
$c["customer_id"] = $data[0]["customer_id"];
|
||||
$cards[] = $c;
|
||||
}
|
||||
|
||||
//SYNC ACCOUNT CARDS
|
||||
$synced = [];
|
||||
$todelete = [];
|
||||
foreach($cards as $key => $paymayacards){
|
||||
foreach($data as $key => $savedcards){
|
||||
if($paymayacards["cardTokenId"] == $savedcards["token"]){
|
||||
$c = $paymayacards;
|
||||
$c["uuid"] = $savedcards["paymaya_token_uuid"];
|
||||
$c["customer_id"] = $savedcards["customer_id"];
|
||||
$synced[] = $c;
|
||||
}else{
|
||||
//IF SAVED TOKEN FROM THE DATABASE DOESNT HAVE A MATCH TO PAYMAYA API, DELETE
|
||||
$todelete[] = $savedcards;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$res = [];
|
||||
$res["customer_id"] = $data[0]["customer_id"];
|
||||
$res["card_number"] = $data[0]["card_number"];
|
||||
$res["is_active"] = $data[0]["is_active"];
|
||||
$res["created_at"] = get_object_vars($data[0]["created_at"])["date"];
|
||||
$res["updated_at"] = get_object_vars($data[0]["updated_at"])["date"];
|
||||
// $res["cards"] = $cards;
|
||||
// $res["full"] = $data;
|
||||
// $res["to_delete"] = $todelete;
|
||||
$res["cards"] = $synced;
|
||||
|
||||
// return $this->format->mobile_success('Success', $res);
|
||||
return $this->format->mobile_success('Success', $res);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->mobile_error('Paymaya token not found', []);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
return $this->format->mobile_error('Error');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\PaymayaTokens $paymayaTokens
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(PaymayaTokens $paymayaTokens)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\PaymayaTokens $paymayaTokens
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, PaymayaTokens $paymayaTokens)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\PaymayaTokens $paymayaTokens
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($paymaya_token_uuid)
|
||||
{
|
||||
try {
|
||||
PaymayaTokens::where('paymaya_token_uuid',$paymaya_token_uuid)
|
||||
->update([
|
||||
'is_active' => 0
|
||||
]);
|
||||
return $this->format->mobile_success('Success');
|
||||
} catch (\Throwable $th) {
|
||||
return $this->format->mobile_error('Error',$th);
|
||||
|
||||
}
|
||||
//
|
||||
}
|
||||
}
|
|
@ -1,716 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Contracts\LcardActionLogsInterface;
|
||||
use App\Contracts\PaymentResourceInterface;
|
||||
use App\Contracts\RatingsResourceInterface;
|
||||
use App\Contracts\StationResourceInterface;
|
||||
use App\Contracts\LoyaltyCardResourceInterface;
|
||||
use App\Contracts\SystemPreferenceResourceInterface;
|
||||
use App\Helpers\StringHelper;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use App\Libraries\CywareLibrary;
|
||||
use App\Helpers\CurrentUserHelper;
|
||||
use App\Libraries\StaticContents;
|
||||
use App\Libraries\Paypal;
|
||||
use App\Http\Requests\MobileTopUpFormValidation;
|
||||
use App\Http\Requests\PaypalExecuteFormValidation;
|
||||
use App\Http\Requests\PaymayaFormValidation;
|
||||
use App\TopUp;
|
||||
use App\Libraries\UuidHelper;
|
||||
use App\Payment;
|
||||
|
||||
class PaymentController extends Controller
|
||||
{
|
||||
public $payment;
|
||||
|
||||
public $rating;
|
||||
|
||||
public $station;
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $lcard_logs;
|
||||
|
||||
protected $loyalty_card;
|
||||
|
||||
protected $system_preferences;
|
||||
|
||||
public function __construct(PaymentResourceInterface $payment,
|
||||
RatingsResourceInterface $rating,
|
||||
StationResourceInterface $station,
|
||||
HttpStatusCode $httpStatusCode,
|
||||
LcardActionLogsInterface $lcard_logs,
|
||||
LoyaltyCardResourceInterface $loyalty_card,
|
||||
SystemPreferenceResourceInterface $system_preferences)
|
||||
{
|
||||
$this->format = $httpStatusCode;
|
||||
$this->lcard_logs = $lcard_logs;
|
||||
$this->payment = $payment;
|
||||
$this->rating = $rating;
|
||||
$this->station = $station;
|
||||
$this->loyalty_card = $loyalty_card;
|
||||
$this->system_preferences = $system_preferences;
|
||||
|
||||
}
|
||||
|
||||
public function filter_by_value ($array, $index, $value){
|
||||
if(is_array($array) && count($array)>0)
|
||||
{
|
||||
foreach(array_keys($array) as $key){
|
||||
$temp[$key] = $array[$key][$index];
|
||||
|
||||
if ($temp[$key] == $value){
|
||||
$newarray[$key] = $array[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $newarray;
|
||||
}
|
||||
|
||||
public function unique_multidim_array($array, $key) {
|
||||
$temp_array = array();
|
||||
$i = 0;
|
||||
$key_array = array();
|
||||
$res = [];
|
||||
foreach($array as $val) {
|
||||
if (!in_array($val[$key], $key_array)) {
|
||||
$key_array[$i] = $val[$key];
|
||||
$temp_array[$i] = $val;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
foreach($temp_array as $v) {
|
||||
$res[] = $v;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function transactions(Request $request)
|
||||
{
|
||||
$date_start = $request->has('date_start') ? date('Ymd',strtotime($request->date_start)) : date('Ymd');
|
||||
$date_end = $request->has('date_end') ? date('Ymd',strtotime($request->date_end)) : date('Ymd');
|
||||
$member_details = CurrentUserHelper::get_currentMember();
|
||||
|
||||
$cyware = new CywareLibrary();
|
||||
|
||||
$cyware->setCardNumber($member_details->card_number);
|
||||
$cyware->setStartDate($date_start);
|
||||
$cyware->setEndDate($date_end);
|
||||
$cyware->setLcardID($member_details->lcard_id);
|
||||
$cyware->state_trans();
|
||||
$this->lcard_logs->log($member_details->lcard_id,'TRANSACTIONS','VIEW','Member viewed transaction lists');
|
||||
|
||||
if ($cyware->response['status_code'] == "200" && $cyware->response['data'] != null)
|
||||
{
|
||||
|
||||
if(isset($cyware->response['data']->total_amount))
|
||||
{
|
||||
// Note : if the result from cyware has only one transaction. The response data is not indexed
|
||||
|
||||
$det = $cyware->response['data'];
|
||||
$cyware->response['data'] = null;
|
||||
$cyware->response['data'][0] = $det;
|
||||
}
|
||||
|
||||
if(count((array)$cyware->response['data']))
|
||||
{
|
||||
$in_app_stations = StaticContents::in_app_stations();
|
||||
$data = [];
|
||||
$ctr = 0;
|
||||
$total_count = count((array)$cyware->response['data']);
|
||||
foreach ($cyware->response['data'] as $key => $value)
|
||||
{
|
||||
// if(($total_count - 5) <= $ctr)
|
||||
// {
|
||||
$is_disabled = true;
|
||||
$is_feedback_disabled = true;
|
||||
$rating = 0;
|
||||
if(!isset($value->receipt_num))
|
||||
{
|
||||
$payment = $this->payment->get_by_trans_num($value->trans_num);
|
||||
|
||||
if(!isset($in_app_stations[$value->store_id]))
|
||||
{
|
||||
$rating = isset($payment->ratings) ? $payment->ratings->rate : 0;
|
||||
$is_disabled = (isset($payment->ratings) && $payment->ratings->rate > 0 )? true : false;;
|
||||
$is_feedback_disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
$items = [];
|
||||
if(isset($value->items) && count($value->items) > 0)
|
||||
{
|
||||
foreach ($value->items as $k => $i)
|
||||
{
|
||||
$items[] = [
|
||||
'item' => $i->item_desc,
|
||||
'quantity' => (double)$i->qty,
|
||||
'price' => (double)$i->price,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE : removed for multiple items
|
||||
// 'item' => isset($value->reward_desc) ? $value->reward_desc : $value->item_desc,
|
||||
// 'price' => $value->total_amount,
|
||||
|
||||
$data[] = [
|
||||
'station' => $value->store_name,
|
||||
'total_amount' => (double)$value->total_amount,
|
||||
'earned' => isset($value->reward_code) ? 0 : (double)$value->total_points,
|
||||
'redeemed' => isset($value->reward_code) ? (double)$value->total_points : 0,
|
||||
'date' => date('d M Y, h:i A',strtotime($value->date.' '.$value->time)),
|
||||
'rating' => $rating,
|
||||
'is_disabled' => $is_disabled,
|
||||
'is_feedback_disabled' => $is_feedback_disabled,
|
||||
'trans_num' => isset($value->receipt_num) ? $value->receipt_num : $value->trans_num,
|
||||
'items' => $items,
|
||||
];
|
||||
// }
|
||||
$ctr++;
|
||||
}
|
||||
|
||||
$nResults = [];
|
||||
foreach ($data as $key => $trans) {
|
||||
$ftr = $this->filter_by_value($data, 'trans_num', $trans['trans_num']);
|
||||
if(count($ftr) > 1){
|
||||
//DUPLICATES FOUND
|
||||
$trans['total_amount'] = 0;
|
||||
$trans['redeemed'] = 0;
|
||||
$trans['earned'] = 0;
|
||||
$trans['items'] = [];
|
||||
foreach ($ftr as $duplicates => $tran) {
|
||||
$trans['redeemed'] += $tran['redeemed'];
|
||||
$trans['earned'] += $tran['earned'];
|
||||
$trans['total_amount'] += $tran['total_amount'];
|
||||
foreach ($tran['items'] as $items => $item) {
|
||||
$trans['items'][] = $item;
|
||||
}
|
||||
}
|
||||
$nResults[] = $trans;
|
||||
}else{
|
||||
$nResults[] = $trans;
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->unique_multidim_array($nResults, 'trans_num');
|
||||
$final = [];
|
||||
$final['sorted'] = $result;
|
||||
$final['original'] = $data;
|
||||
|
||||
return $this->format->mobile_success('Success', $result);
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_success('Success');
|
||||
}
|
||||
else
|
||||
{
|
||||
if($cyware->response['message'] == null)
|
||||
return $this->format->mobile_success("No records found",[]);
|
||||
else
|
||||
return $this->format->mobile_error($cyware->response['message'],[]);
|
||||
}
|
||||
}
|
||||
|
||||
public function single_transaction(Request $request)
|
||||
{
|
||||
$date_start = $request->has('date_start') ? date('Ymd',strtotime($request->date_start)) : date('Ymd');
|
||||
$date_end = $request->has('date_end') ? date('Ymd',strtotime($request->date_end)) : date('Ymd');
|
||||
$member_details = CurrentUserHelper::get_currentMember();
|
||||
|
||||
$searched = $this->search_transaction(new CywareLibrary(), $member_details->card_number, $request->trans_num, $date_start, $date_end);
|
||||
$this->lcard_logs->log($member_details->lcard_id,'TRANSACTIONS','VIEW','Member viewed a transaction');
|
||||
if ($searched['success'])
|
||||
{
|
||||
|
||||
$value = $searched['data'];
|
||||
|
||||
$is_disabled = true;
|
||||
$is_feedback_disabled = true;
|
||||
$rating = 0;
|
||||
if(!isset($value->receipt_num))
|
||||
{
|
||||
$payment = isset($value->trans_num) ? $this->payment->get_by_trans_num($value->trans_num) : null;
|
||||
$in_app_stations = StaticContents::in_app_stations();
|
||||
if(!isset($in_app_stations[$value->store_id]))
|
||||
{
|
||||
$rating = isset($payment->ratings) ? $payment->ratings->rate : 0;
|
||||
$is_disabled = (isset($payment->ratings) && $payment->ratings->rate > 0 )? true : false;
|
||||
$is_feedback_disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
$customer_service_email = $this->system_preferences->getByField('name','contact_email_address_mobile');
|
||||
$customer_service_number = $this->system_preferences->getByField('name','contact_number_mobile');
|
||||
|
||||
$items = [];
|
||||
if(isset($value->items) && count($value->items) > 0)
|
||||
{
|
||||
foreach ($value->items as $k => $i)
|
||||
{
|
||||
$items[] = [
|
||||
'item' => $i->item_desc,
|
||||
'quantity' => (double)$i->qty,
|
||||
'price' => (double)$i->price,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'station' => $value->store_name,
|
||||
// 'item' => isset($value->reward_desc) ? $value->reward_desc : $value->item_desc,
|
||||
'total_amount' => (double)$value->total_amount,
|
||||
'earned' => isset($value->reward_code) ? 0 : (double)$value->total_points,
|
||||
'redeemed' => isset($value->reward_code) ? (double)$value->total_points : 0,
|
||||
'date' => date('d M Y, h:i A',strtotime($value->date.' '.$value->time)),
|
||||
// 'quantity' => isset($value->qty) ? (double)$value->qty : 1,
|
||||
'rating' => $rating,
|
||||
'is_disabled' => $is_disabled,
|
||||
'is_feedback_disabled' => $is_feedback_disabled,
|
||||
'trans_num' => isset($value->receipt_num) ? $value->receipt_num : $value->trans_num,
|
||||
'contact_email' => $customer_service_email[0]['value'],
|
||||
'contact_number' => $customer_service_number[0]['value'],
|
||||
'items' => $items
|
||||
];
|
||||
return $this->format->mobile_success('Success',$data);
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error($searched['message']);
|
||||
}
|
||||
|
||||
public function rate_transaction(Request $request)
|
||||
{
|
||||
$payment = $this->payment->get_by_trans_num($request->trans_num);
|
||||
$member_details = CurrentUserHelper::get_currentMember();
|
||||
|
||||
if($payment)
|
||||
{
|
||||
if(isset($payment->ratings))
|
||||
{
|
||||
$data = [
|
||||
'lcard_id' => $member_details->lcard_id,
|
||||
'station_id' => $payment->station_id,
|
||||
'payment_id' => $payment->payment_id,
|
||||
'rate' => $request->rate,
|
||||
];
|
||||
|
||||
if($this->rating->update($data,$payment->ratings->rating_id))
|
||||
{
|
||||
$this->lcard_logs->log($member_details->lcard_id,'RATINGS','UPDATE','Member updated a rate on a transaction');
|
||||
return $this->format->mobile_success('Success');
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error('Something went wrong');
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = [
|
||||
'lcard_id' => $member_details->lcard_id,
|
||||
'station_id' => $payment->station_id,
|
||||
'payment_id' => $payment->payment_id,
|
||||
'rate' => $request->rate,
|
||||
];
|
||||
|
||||
if($this->rating->store($data))
|
||||
{
|
||||
$this->lcard_logs->log($member_details->lcard_id,'RATINGS','STORE','Member rated a transaction');
|
||||
return $this->format->mobile_success('Success');
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error('Something went wrong');
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$date_start = $request->has('date_start') ? date('Ymd',strtotime($request->date_start)) : date('Ymd');
|
||||
$date_end = $request->has('date_end') ? date('Ymd',strtotime($request->date_end)) : date('Ymd');
|
||||
|
||||
$searched = $this->search_transaction(new CywareLibrary(), $member_details->card_number, $request->trans_num, $date_start, $date_end);
|
||||
|
||||
if($searched['success'])
|
||||
{
|
||||
$value = $searched['data'];
|
||||
if($value)
|
||||
{
|
||||
$items = [];
|
||||
if(isset($value->items) && count($value->items) > 0)
|
||||
{
|
||||
foreach ($value->items as $k => $i)
|
||||
{
|
||||
$items[] = [
|
||||
'item' => $i->item_desc,
|
||||
'quantity' => (double)$i->qty,
|
||||
'price' => (double)$i->price,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$station = $this->station->getByField('code',$value->store_id);
|
||||
$store_data = [
|
||||
'station_id' => $station ? $station[0]['station_id'] : 0,
|
||||
'trans_num' => isset($value->receipt_num) ? $value->receipt_num : $value->trans_num,
|
||||
// 'item_name' => isset($value->reward_desc) ? $value->reward_desc : $value->item_desc,
|
||||
// 'item_code' => isset($value->reward_code) ? $value->reward_code : $value->item_code,
|
||||
'total_amount' => $value->total_amount,
|
||||
'points' => isset($value->reward_code) ? $value->total_points : 0,
|
||||
'entry_type_code' => isset($value->reward_code) ? $value->reward_code : $value->entry_type_code,
|
||||
'entry_type_desc' => isset($value->reward_desc) ? $value->reward_desc : $value->entry_type_desc,
|
||||
// 'receipt_num' => isset($data->receipt_num) ? $data->receipt_num : null,
|
||||
// 'quantity' => isset($value->qty) ? $value->qty : 1,
|
||||
'date' => date('Y-m-d H:i:00',strtotime($value->date.' '.$value->time)),
|
||||
'items' => $items
|
||||
];
|
||||
|
||||
$payment_id = $this->payment->store_non_app($store_data,$member_details);
|
||||
if($payment_id)
|
||||
{
|
||||
$data = [
|
||||
'lcard_id' => $member_details->lcard_id,
|
||||
'station_id' => $store_data['station_id'],
|
||||
'payment_id' => $payment_id,
|
||||
'rate' => $request->rate,
|
||||
];
|
||||
|
||||
if($this->rating->store($data))
|
||||
{
|
||||
$this->lcard_logs->log($member_details->lcard_id,'PAYMENTS','STORE','Member added a non-APP transaction through ratings');
|
||||
return $this->format->mobile_success('Success');
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error('Something went wrong');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->format->mobile_error('Something went wrong');
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error($searched['message']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// paypal transactions
|
||||
|
||||
public function get_paypal_url(MobileTopUpFormValidation $request)
|
||||
{
|
||||
// check if already have 5 transactions in 24 hours
|
||||
// $date_yesterday = date('Y-m-d H:i:s', strtotime('-24 hours'));
|
||||
// $date_now = date('Y-m-d H:i:s');
|
||||
|
||||
// $payments = $this->payment->count_between($member_details->lcard_id, $date_yesterday, $date_now);
|
||||
$payments = $this->count_transaction(new CywareLibrary, $member_details->card_number, date('Y-m-d'));
|
||||
if($payments < 5)
|
||||
{
|
||||
$trans_count = $this->payment->count_trans_month() + 1;
|
||||
$trans_num = (env('SI_NUM_RANDOM','false') == true ? StringHelper::random_num(2).date('m') : date('ym')).str_pad($trans_count, 4, "0", STR_PAD_LEFT);
|
||||
|
||||
$paypal = new Paypal;
|
||||
$paypal->set_amount($request->amount);
|
||||
$paypal->set_invoice_number($trans_num);
|
||||
|
||||
if($paypal->generate_paypal_url())
|
||||
{
|
||||
$this->payment->store([
|
||||
'trans_num' => $trans_num,
|
||||
// 'item_name' => 'PREPAID LOAD',
|
||||
// 'item_code' => 'PREPAID',
|
||||
'amount' => $request->amount,
|
||||
'entry_type_code' => 'APP',
|
||||
'entry_type_desc' => 'APP',
|
||||
'paypal_id' => $paypal->get_paypal_id(),
|
||||
'other' => serialize($paypal->get_response()),
|
||||
'items' => [
|
||||
[
|
||||
'item' => 'PREPAID LOAD',
|
||||
'quantity' => 1,
|
||||
'price' => $request->amount
|
||||
]
|
||||
]
|
||||
],$member_details);
|
||||
|
||||
$this->lcard_logs->log($member_details->lcard_id,'PAYMENTS','STORE','Member added a pending payment through Paypal. Transaction Number : '.$trans_num);
|
||||
|
||||
return $this->format->mobile_success('Success',[
|
||||
'redirect_url' => $paypal->get_approval_url(),
|
||||
'paypal_id' => $paypal->get_paypal_id(),
|
||||
'trans_num' => $trans_num,
|
||||
]);
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error('Paypal Error');
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error('You already reached the maximum allowed Top Up transactions per day. Please Top Up again after 24 hours.');
|
||||
}
|
||||
|
||||
// Count the total number of transactions for the Payments Table
|
||||
public function count_total_transactions(){
|
||||
$listCount = Payment::with(['loyaltyCard'])->where('payments.created_at', '>=' ,date('Y-m-d').' 00:00:00')->where('payments.created_at', '<=' ,date('Y-m-d').' 23:59:59')->count();
|
||||
if($listCount <= 5){
|
||||
return $this->format->mobile_success("Success",$listCount,false);
|
||||
}
|
||||
return $this->format->unprocessableEntity("You have reached today's top up limit",$listCount);
|
||||
}
|
||||
|
||||
public function paymaya_execute(PaymayaFormValidation $request){
|
||||
// eval(\Psy\sh());
|
||||
// return $this->format->success('Yep its working',[
|
||||
// 'sample response' => "this is sample response",
|
||||
// 'sample token' => $request->header('card_number')
|
||||
// ]);
|
||||
|
||||
$member_details = CurrentUserHelper::get_currentMember();
|
||||
$reference_number = $request->post('reference_number') ? $request->post('reference_number') : StringHelper::random_num(6);
|
||||
$cyware = new CywareLibrary();
|
||||
$cyware->setCardNumber($member_details->card_number);
|
||||
$cyware->setCashier('APP');
|
||||
$cyware->setBranch('APP');
|
||||
$cyware->setRegisterNum('1');
|
||||
$cyware->setSiNum($reference_number);
|
||||
$cyware->setTotalAmount($request->post('amount'));
|
||||
$cyware->setPaymentType('CC');
|
||||
$cyware->setItemCode('PREPAID');
|
||||
|
||||
$cyware->state_points();
|
||||
|
||||
if($cyware->response['message'] == "SI Number already exist"){
|
||||
$cyware->setSiNum(StringHelper::random_num(6));
|
||||
$cyware->state_points();
|
||||
}
|
||||
|
||||
$trans_count = $this->payment->count_trans_month() + 1;
|
||||
$trans_num = (env('SI_NUM_RANDOM','false') == true ? StringHelper::random_num(2).date('m') : date('ym')).str_pad($trans_count, 4, "0", STR_PAD_LEFT);
|
||||
|
||||
$this->payment->store([
|
||||
'trans_num' => $trans_num,
|
||||
// 'item_name' => 'PREPAID LOAD',
|
||||
// 'item_code' => 'PREPAID',
|
||||
'amount' => $request->amount,
|
||||
'entry_type_code' => 'APP',
|
||||
'entry_type_desc' => 'APP',
|
||||
'paypal_id' => $reference_number,
|
||||
// 'other' => serialize($paypal->get_response()),
|
||||
'other' => '',
|
||||
'items' => [
|
||||
[
|
||||
'item' => 'PREPAID LOAD',
|
||||
'quantity' => 1,
|
||||
'price' => $request->amount
|
||||
]
|
||||
]
|
||||
],$member_details);
|
||||
|
||||
return $this->format->success('Transaction Successful',[
|
||||
'cyware' => $cyware->response,
|
||||
'card_number' => $request->header('card_number')
|
||||
]);
|
||||
|
||||
// if($cyware->response['status_code'] == "200" && $cyware->response['success'] == "Prepaid load is successfully loaded in your account")
|
||||
// {
|
||||
// return $this->format->success('Transaction Successful',[
|
||||
// 'message' => "It works",
|
||||
// 'cyware' => $cyware->response
|
||||
// ]);
|
||||
// }
|
||||
// else return $this->format->unprocessableEntity('Payment is successful. However, we encountered a problem updating your Loyalty Points. Please contact Customer Service for assistance.');
|
||||
|
||||
}
|
||||
|
||||
private function generateFeeCode(){
|
||||
$fee_code = "0001";
|
||||
$details = TopUp::orderBy('created_at', 'desc')->first();
|
||||
|
||||
if($details){
|
||||
$fee_code = ltrim($details->fee_code, '0') + 1;
|
||||
}
|
||||
|
||||
$data = str_pad($fee_code, 4, '0', STR_PAD_LEFT);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function paypal_execute(PaypalExecuteFormValidation $request)
|
||||
{
|
||||
$paypal = new Paypal;
|
||||
$paypal->set_paypal_id($request->paymentId);
|
||||
$paypal->set_payer_id($request->PayerID);
|
||||
|
||||
if($paypal->paypal_execute())
|
||||
{
|
||||
/*
|
||||
Note :
|
||||
invoice_number = trans_num --custom transaction number to be passed to cyware
|
||||
trans_num = paypal_trans_num --transaction number generated from paypal
|
||||
*/
|
||||
$save_db = $this->payment->success_transaction($paypal->get_invoice_number(),[
|
||||
'other' => $paypal->get_response(),
|
||||
'firstname' => $paypal->get_payer_firstname(),
|
||||
'lastname' => $paypal->get_payer_lastname(),
|
||||
'payer_email' => $paypal->get_payer_email(),
|
||||
'receiver_email' => $paypal->get_receiver_email(),
|
||||
'paypal_trans_num' => $paypal->get_trans_num(),
|
||||
'paid_at' => date('Y-m-d H:i:s',strtotime($paypal->get_paid_at())),
|
||||
]);
|
||||
|
||||
if($save_db)
|
||||
{
|
||||
$db = $this->payment->get_by_trans_num($paypal->get_invoice_number());
|
||||
$member_details = $this->loyalty_card->getByField(['lcard_id' => $db->lcard_id]);
|
||||
|
||||
$cyware = new CywareLibrary();
|
||||
$cyware->setCardNumber($member_details[0]->card_number);
|
||||
$cyware->setCashier('APP');
|
||||
$cyware->setBranch('APP');
|
||||
$cyware->setRegisterNum('1');
|
||||
$cyware->setSiNum($paypal->get_invoice_number());
|
||||
$cyware->setTotalAmount($db->amount);
|
||||
$cyware->setPaymentType('CC');
|
||||
$cyware->setItemCode('PREPAID');
|
||||
|
||||
$cyware->state_points();
|
||||
|
||||
if($cyware->response['status_code'] == "200" && $cyware->response['success'] == "Prepaid load is successfully loaded in your account")
|
||||
{
|
||||
|
||||
$this->payment->cyware_synced($db->payment_id,(isset($searched['data']->total_points) ? $searched['data']->total_points : 0));
|
||||
$this->lcard_logs->log($member_details[0]->lcard_id,'PAYMENTS','UPDATE','Member successfully paid transaction number '.$paypal->get_invoice_number());
|
||||
|
||||
$searched = $this->search_transaction($cyware,$member_details[0]->card_number,$paypal->get_invoice_number(),date('Ymd'),date('Ymd'));
|
||||
return $this->format->success('Transaction Successful',[
|
||||
'date' => date('d F y h:i A',strtotime($db->paid_at)),
|
||||
'card_number' => $member_details[0]->card_number,
|
||||
'invoice' => $paypal->get_invoice_number(),
|
||||
'points' => isset($searched['data']->total_points) ? $searched['data']->total_points : $paypal->get_total(),
|
||||
'payment_val' => $paypal->get_total(),
|
||||
'paypal_fee' => $paypal->get_paypal_fee(),
|
||||
]);
|
||||
}
|
||||
else return $this->format->unprocessableEntity('Payment is successful. However, we encountered a problem updating your Loyalty Points. Please contact Customer Service for assistance.',['details' => $cyware->response['message']]);
|
||||
}
|
||||
else return $this->format->unprocessableEntity('Error on database saving');
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->payment->failed_transaction($request->paymentId, $paypal->get_response());
|
||||
return $this->format->unprocessableEntity(($paypal->get_error_message() != null ? $paypal->get_error_message() : 'Your purchase for top-up is not successful. Please try again.'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function get_status($trans_num)
|
||||
{
|
||||
$details = $this->payment->get_by_trans_num($trans_num);
|
||||
if($details)
|
||||
{
|
||||
if($details->status == 1 && $details->cyware_synced == 1)
|
||||
return $this->format->mobile_success('Transaction Successful');
|
||||
else
|
||||
return $this->format->mobile_error('Transaction Failed');
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error('Transaction Doesn\'t Exist');
|
||||
}
|
||||
|
||||
private function search_transaction($cyware, $card_number, $trans_num, $date_start, $date_end)
|
||||
{
|
||||
$cyware->setCardNumber($card_number);
|
||||
$cyware->setStartDate($date_start);
|
||||
$cyware->setEndDate($date_end);
|
||||
$cyware->state_trans();
|
||||
|
||||
$data = [];
|
||||
|
||||
if($cyware->response['status_code'] == "200" && $cyware->response['data'] != null)
|
||||
{
|
||||
if(count((array)$cyware->response['data']))
|
||||
{
|
||||
if(isset($cyware->response['data']->total_amount))
|
||||
{
|
||||
// Note : if the result from cyware has only one transaction. The response data is not indexed
|
||||
if(
|
||||
(isset($cyware->response['data']->trans_num) && (strcasecmp($cyware->response['data']->trans_num,$trans_num) || $cyware->response['data']->trans_num == $trans_num)/*($cyware->response['data']->trans_num == $trans_num)*/) ||
|
||||
(isset($cyware->response['data']->receipt_num) && strcasecmp($cyware->response['data']->receipt_num,$trans_num)/*($cyware->response['data']->receipt_num == $trans_num)*/)
|
||||
)
|
||||
{
|
||||
$data = $cyware->response['data'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($cyware->response['data'] as $key => $value)
|
||||
{
|
||||
if(
|
||||
(isset($value->trans_num) && strcasecmp($value->trans_num,$trans_num) == 0/*($value->trans_num == $trans_num)*/) ||
|
||||
(isset($value->receipt_num) && strcasecmp($value->receipt_num,$trans_num) == 0/*($value->receipt_num == $trans_num)*/)
|
||||
)
|
||||
{
|
||||
$data = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($data)
|
||||
return ['success' => true, 'data' => $data];
|
||||
else
|
||||
return ['success' => false, 'message' => 'Transaction Not Found'];
|
||||
}
|
||||
return ['success' => false, 'message' => $cyware->response['message']];
|
||||
}
|
||||
|
||||
private function count_transaction($cyware, $card_number, $date)
|
||||
{
|
||||
$cyware->setCardNumber($card_number);
|
||||
$cyware->setStartDate($date);
|
||||
$cyware->setEndDate($date);
|
||||
$cyware->state_trans();
|
||||
|
||||
$count = 0;
|
||||
|
||||
if($cyware->response['status_code'] == "200" && $cyware->response['data'] != null)
|
||||
{
|
||||
if(isset($cyware->response['data']) && count((array)$cyware->response['data']))
|
||||
{
|
||||
if(isset($cyware->response['data']->total_amount))
|
||||
{
|
||||
// Note : if the result from cyware has only one transaction. The response data is not indexed
|
||||
if($cyware->response['data']->date == $date)
|
||||
$count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($cyware->response['data'] as $key => $value) {
|
||||
if($value->date == $date)
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
$cyware = new CywareLibrary();
|
||||
$cyware->setCardNumber('1100000000000003');
|
||||
$cyware->setCashier('APP');
|
||||
$cyware->setBranch('APP');
|
||||
$cyware->setRegisterNum('1');
|
||||
$cyware->setSiNum('2015111500001');
|
||||
$cyware->setTotalAmount('9999.99');
|
||||
$cyware->setPaymentType('CC');
|
||||
$cyware->setItemCode('PREPAID');
|
||||
|
||||
$cyware->state_points();
|
||||
|
||||
dd($cyware->response);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,265 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Libraries\S3;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Contracts\PhotoSliderResourceInterface;
|
||||
use App\Contracts\AdminActionLogsInterface;
|
||||
use App\Http\Resources\PhotoSliderResource;
|
||||
use App\Libraries\ParameterHelper;
|
||||
use App\Helpers\CurrentUserHelper;
|
||||
use App\Helpers\StringHelper;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use App\Http\Requests\PhotoSliderFormValidation;
|
||||
|
||||
class PhotoSliderController extends Controller
|
||||
{
|
||||
const MODULE = 'PHOTOSLIDER';
|
||||
|
||||
public $photoSlider;
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $module;
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $admin_logs;
|
||||
|
||||
public function __construct(PhotoSliderResourceInterface $photoSlider, HttpStatusCode $httpStatusCode,AdminActionLogsInterface $admin_logs)
|
||||
{
|
||||
$this->photoSlider = $photoSlider;
|
||||
$this->format = $httpStatusCode;
|
||||
$this->admin_logs = $admin_logs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$params = [
|
||||
'search' => ($request->has('_search') ? $request->get('_search') : NULL),
|
||||
'page_size' => ($request->has('page_size') ? $request->get('page_size') : 10),
|
||||
'page' => ($request->has('page') ? $request->get('page') : 10),
|
||||
'sorting' => ParameterHelper::prepareSortingParameter($request)
|
||||
];
|
||||
|
||||
$list = $this->photoSlider->listing($params);
|
||||
|
||||
if(count($list))
|
||||
{
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = PhotoSliderResource::collection($list)->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->success("No records found",[]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(PhotoSliderFormValidation $request)
|
||||
{
|
||||
$id = $this->photoSlider->store($request);
|
||||
|
||||
if($id)
|
||||
{
|
||||
$this->admin_logs->log($id,self::MODULE,'STORE');
|
||||
|
||||
return $this->format->created('Photo Slider has been added');
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->notFound();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($uuid)
|
||||
{
|
||||
$details = $this->photoSlider->getByField('photoslider_uuid',$uuid);
|
||||
|
||||
if($details->count())
|
||||
{
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = (new PhotoSliderResource($details[0]))->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(PhotoSliderFormValidation $request, $uuid)
|
||||
{
|
||||
$old_data = $this->photoSlider->getByField('photoslider_uuid',$uuid);
|
||||
|
||||
if($old_data->count())
|
||||
{
|
||||
if($this->photoSlider->update($request,$uuid))
|
||||
{
|
||||
$this->admin_logs->log($old_data[0]['photoslider_id'],self::MODULE,'UPDATE');
|
||||
return $this->format->success("Photo Slider has been updated");
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->notFound();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($uuid)
|
||||
{
|
||||
$details = $this->photoSlider->getByField('photoslider_uuid',$uuid);
|
||||
if($details->count())
|
||||
{
|
||||
$details = $details[0];
|
||||
if($this->photoSlider->delete($uuid))
|
||||
{
|
||||
$this->admin_logs->log($details['photoslider_id'],self::MODULE,'DELETE');
|
||||
return $this->format->success("Photo Slider Successfully Deleted");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
|
||||
public function batch_delete(Request $request)
|
||||
{
|
||||
$uuid = $request->has('photoslider_uuid') ? $request->get('photoslider_uuid') : null;
|
||||
|
||||
if($uuid)
|
||||
{
|
||||
$details = $this->photoSlider->getDetailsWhereIn('photoslider_uuid',$uuid);
|
||||
|
||||
|
||||
$id = array();
|
||||
|
||||
if($this->photoSlider->delete($uuid))
|
||||
{
|
||||
foreach ($details as $key => $value)
|
||||
{
|
||||
$this->admin_logs->log($value['photoslider_id'],self::MODULE,'DELETE');
|
||||
}
|
||||
|
||||
return $this->format->success("Photo Slider Successfully Deleted");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->badRequest('Something went wrong');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['photoslider_uuid'] = 'photoslider_uuid is required';
|
||||
return $this->format->unprocessableEntity("Submit at least one item",$data);
|
||||
}
|
||||
}
|
||||
|
||||
public function check_count()
|
||||
{
|
||||
if($this->photoSlider->count() < 10)
|
||||
return $this->format->success('User can add');
|
||||
else
|
||||
return $this->format->badRequest('Photo slider cannot be more than 10');
|
||||
}
|
||||
|
||||
|
||||
public function get_photo_slider(Request $request)
|
||||
{
|
||||
|
||||
$data = $this->photoSlider->getPhotoSlider();
|
||||
$currentUser = CurrentUserHelper::get_member_by_lcard($request->input('lcard_uuid'));
|
||||
|
||||
$return = [];
|
||||
foreach ($data as $key => $value){
|
||||
$return[$key]['photoslider_id'] = $value['photoslider_id'];
|
||||
$return[$key]['photoslider_uuid'] = $value['photoslider_uuid'];
|
||||
$return[$key]['title'] = $value['title'];
|
||||
$return[$key]['description'] = $value['description'];
|
||||
$return[$key]['image'] = S3::public_path($value['image']);
|
||||
$return[$key]['date_start'] = $value['date_start'];
|
||||
$return[$key]['date_end'] = $value['date_end'];
|
||||
$return[$key]['is_toppromotion'] = $value['is_toppromotion'];
|
||||
$return[$key]['is_gps'] = $value['is_gps'];
|
||||
$return[$key]['promo_type'] = $value['promo_type'];
|
||||
$return[$key]['promotion_id'] = $value['promotion_id'];
|
||||
|
||||
$promotion_uuid = 0;
|
||||
if ( strtotime(date('Y-m-d H:i:s')) >= strtotime($value['promotion_date_start']) ){
|
||||
if(strtotime(date('Y-m-d H:i:s')) <= strtotime($value['promotion_date_end'])){
|
||||
$promotion_uuid = $value['promotion_uuid'];
|
||||
}
|
||||
}
|
||||
|
||||
$return[$key]['promotion_uuid'] = $promotion_uuid;
|
||||
$return[$key]['promotion_date_start'] = $value['promotion_date_start'];
|
||||
$return[$key]['promotion_date_end'] = $value['promotion_date_end'];
|
||||
$return[$key]['promo_details'] = [
|
||||
"title"=> $promotion_uuid=="0" ? "" : $value['promotion_title'],
|
||||
"description"=>$promotion_uuid=="0" ? "" : $value['promotion_description'],
|
||||
"image"=>$promotion_uuid=="0" ? "" : S3::public_path($value['promotion_image']),
|
||||
];
|
||||
$return[$key]['promo_details'] = $value['promo_type'] != 3 ? $return[$key]['promo_details'] : ["title"=> "","description"=>"","image"=>""];
|
||||
|
||||
|
||||
if ($currentUser){
|
||||
$now = Carbon::now();
|
||||
$birthday = $now->year."-".$currentUser->birthdate->month."-".$currentUser->birthdate->day." 00:00:00";
|
||||
|
||||
if($value['promo_type'] == "3"){
|
||||
if (strtotime($value['promotion_date_start']) <= strtotime($birthday) && strtotime($value['promotion_date_end']) >= strtotime($birthday) ){
|
||||
$return[$key]['promo_details'] = [
|
||||
"title"=> $promotion_uuid=="0" ? "" : $value['promotion_title'],
|
||||
"description"=>$promotion_uuid=="0" ? "" : $value['promotion_description'],
|
||||
"image"=>$promotion_uuid=="0" ? "" : S3::public_path($value['promotion_image']),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (count($data) == 0 ) {
|
||||
return $this->format->mobile_success("Data is Empty");
|
||||
}
|
||||
return $this->format->mobile_success('Success',$return);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,385 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Contracts\AdminResourceInterface;
|
||||
use App\Contracts\ProductDetailsResourceInterface;
|
||||
use App\Http\Requests\SystemPreferenceFormValidation;
|
||||
use App\Libraries\StratuscastLibrary;
|
||||
use App\Libraries\RNRPHLibrary;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
|
||||
use Illuminate\Routing\UrlGenerator;
|
||||
|
||||
class ProductDetailsController extends Controller
|
||||
{
|
||||
|
||||
public $product_details;
|
||||
public $product_category;
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $module;
|
||||
|
||||
protected $model;
|
||||
|
||||
public $admin;
|
||||
|
||||
|
||||
public function __construct(ProductDetailsResourceInterface $product_details,HttpStatusCode $httpStatusCode, UrlGenerator $url, AdminResourceInterface $admin)
|
||||
{
|
||||
|
||||
$this->product_details = $product_details;
|
||||
$this->format = $httpStatusCode;
|
||||
$this->module = "Products";
|
||||
$this->model = "Products";
|
||||
$this->url = $url;
|
||||
$this->admin = $admin;
|
||||
}
|
||||
|
||||
public function getFuelList(){
|
||||
$rnrph = new RNRPHLibrary();
|
||||
$rnrph->getAllFuels();
|
||||
if (count($rnrph->response['data']) > 0) {
|
||||
return $this->format->success("Success", $rnrph->response['data']);
|
||||
|
||||
}else{
|
||||
return $this->format->success("Something went wrong",[]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function sync()
|
||||
{
|
||||
$this->product_details->inActiveProductDetails();
|
||||
|
||||
$cyware = new StratuscastLibrary();
|
||||
$cyware->getProducts();
|
||||
if ($cyware->response['status_code'] == "200"){
|
||||
foreach ($cyware->response['data'] as $key => $value){
|
||||
$product_category = $this->product_details->getProductCategoryByField( "type", $value->product_category);
|
||||
$product_category_id = '';
|
||||
|
||||
$product_category_data['type'] = $value->product_category;
|
||||
$product_category_data['description'] = $value->product_category;
|
||||
|
||||
if (count($product_category) == 0){
|
||||
$product_category_id = $this->product_details->storeProductCategory( $product_category_data );
|
||||
}else{
|
||||
$product_category_data['pc_id'] = $product_category[0]->pc_id;
|
||||
$product_category_id = $product_category_data['pc_id'];
|
||||
$this->product_details->updateProductCategory( $product_category_data );
|
||||
}
|
||||
|
||||
//product_details
|
||||
|
||||
$product_details = $this->product_details->getProductDetailsByField( "name", $value->product_name);
|
||||
$data['pc_id'] = $product_category_id;
|
||||
$data['name'] = $value->product_name;
|
||||
$data['code'] = '';
|
||||
$data['image'] = $value->image;
|
||||
$data['description'] = $value->product_description;
|
||||
$data['details'] = $value->product_specification;
|
||||
$data['is_active'] = 1;
|
||||
|
||||
if (count($product_details) == 0){
|
||||
$this->product_details->storeProductDetails( $data );
|
||||
}else{
|
||||
$data['pd_id'] = $product_details[0]->pd_id;
|
||||
$this->product_details->updateProductDetails( $data );
|
||||
}
|
||||
}
|
||||
return $this->format->success("Success",[]);
|
||||
}else{
|
||||
return $this->format->badRequest("Something went wrong",[]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*storeProductDetails
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(SystemPreferenceFormValidation $request)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*d
|
||||
* @param int $id
|
||||
* products@return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = [];
|
||||
$product_category = $this->product_details->getAllProductCategory( );
|
||||
$sort1 = [];
|
||||
$sort2 = [];
|
||||
$sort3 = [];
|
||||
foreach ($product_category as $key => $value){
|
||||
$datas["category_name"] = $value->type;
|
||||
$datas["category_uuid"] = $value->pc_uuid;
|
||||
$datas["products"] = [];
|
||||
foreach ($this->product_details->getProductsByCategory($value->pc_id) as $key => $values){
|
||||
|
||||
|
||||
|
||||
if ($value['type'] == 'Lubricants'){
|
||||
$returnValues['code'] = $values->code ;
|
||||
$returnValues['name'] = $values->name ;
|
||||
$returnValues['image'] = $values->image ;
|
||||
$returnValues['description'] = $values->description ;
|
||||
$returnValues['details'] = json_decode(json_encode($this->parseLubricant($values->details,$values->description ))) ;
|
||||
array_push($datas["products"], $returnValues);
|
||||
}else{
|
||||
|
||||
|
||||
if ($values->name == 'Euro 5 Gasoline 95' || $values->name == 'Euro 5 Gasoline 91' || $values->name == 'Euro 5 Gasoline 97'){
|
||||
$returnValues['code'] = $values->code ;
|
||||
$returnValues['name'] = $values->name ;
|
||||
$returnValues['image'] = $values->image ;
|
||||
$returnValues['description'] = $values->description ;
|
||||
$returnValues['details'] = json_decode(json_encode($this->parseFuel($values->details))) ;
|
||||
array_push($datas["products"], $returnValues);
|
||||
}
|
||||
|
||||
if ($values->name != 'Euro5 Gasoline' && $values->name != 'Euro 5 Gasoline 95' && $values->name != 'Euro 5 Gasoline 91' && $values->name != 'Euro 5 Gasoline 97' ){
|
||||
$returnValues['code'] = $values->code ;
|
||||
$returnValues['name'] = $values->name ;
|
||||
$returnValues['image'] = $values->image ;
|
||||
$returnValues['description'] = $values->description ;
|
||||
$returnValues['details'] = json_decode(json_encode($this->parseDetails($values->details))) ;
|
||||
array_push($datas["products"], $returnValues);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// $datas["products"] = [];
|
||||
|
||||
if($datas["category_name"] == 'Lubricants')
|
||||
$sort1 = $datas;
|
||||
|
||||
if($datas["category_name"] == 'Fuels')
|
||||
$sort2 = $datas;
|
||||
|
||||
if($datas["category_name"] == 'Asphalt')
|
||||
$sort3 = $datas;
|
||||
|
||||
// array_push($data, $datas);
|
||||
}
|
||||
|
||||
array_push($data, $sort1);
|
||||
array_push($data, $sort2);
|
||||
array_push($data, $sort3);
|
||||
|
||||
return $this->format->mobile_success('Success',$data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function removeNBSP($details)
|
||||
{
|
||||
|
||||
// $details = htmlentities($details, null, 'utf-8');
|
||||
$details = str_replace(" ", "", $details);
|
||||
$details = str_replace("nbsp", "", $details);
|
||||
$details = str_replace("&amp;", "", $details);
|
||||
$details = str_replace("&;", "", $details);
|
||||
$details = str_replace("&", "", $details);
|
||||
$details = str_replace(" ", " ", $details);
|
||||
return $details;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function products()
|
||||
{
|
||||
$cyware = new StratuscastLibrary();
|
||||
$cyware->getProducts();
|
||||
if ($cyware->response['status_code'] == "200"){
|
||||
return $this->format->success("curl success",$cyware->response['data']);
|
||||
}
|
||||
}
|
||||
|
||||
private function parseDetails($details)
|
||||
{
|
||||
$detailsReturn = [];
|
||||
$detailsArray = array_filter(explode(" ", $details));
|
||||
$title = '';
|
||||
$detail = '';
|
||||
foreach ($detailsArray as $key => $value){
|
||||
if ($key == 0){
|
||||
$title = $value;
|
||||
}else{
|
||||
$details = $this->checkDetails($value);
|
||||
|
||||
$detail .= empty($details['next-title']) ? $details." " : $details['details'];
|
||||
if (!empty($details['next-title'])){
|
||||
$detailArray = ["level"=>1, "details"=> $this->removeNBSP(str_replace("#39;","'",str_replace("'","'",$details['details'])) )];
|
||||
|
||||
$detailarray = ['level'=>0,'title' => $title, 'details' => [$detailArray]];
|
||||
array_push($detailsReturn , $detailarray);
|
||||
$title = $details['next-title'];
|
||||
$detail = null;
|
||||
}
|
||||
}
|
||||
$arraydetails = [];
|
||||
$detailArray = ["level"=>1, "details"=>$this->removeNBSP(str_replace("'","'",str_replace("#39;","'",$details)))];
|
||||
array_push($arraydetails , ['level'=>0,'title' => "Product description", 'details' => [$detailArray]]);
|
||||
}
|
||||
return count($detailsReturn) == 0 ? $arraydetails : $detailsReturn;
|
||||
}
|
||||
|
||||
private function checkDetails($details)
|
||||
{
|
||||
$detailsArray = array_filter(explode(".", $details));
|
||||
if (count($detailsArray) == 1){
|
||||
return $details;
|
||||
}else{
|
||||
$detailsHolder = '';
|
||||
$count = count($detailsArray) - 1;
|
||||
foreach ($detailsArray as $key => $value) {
|
||||
if ($count == $key ){
|
||||
$detail['details'] = $detailsHolder;
|
||||
$detail['next-title'] = $value;
|
||||
return $detail;
|
||||
}else{
|
||||
$detailsHolder .= $value.".";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $details;
|
||||
}
|
||||
|
||||
private function parseLubricant($details, $description)
|
||||
{
|
||||
$detailsReturn = [];
|
||||
$product_description = $this->delimitbyColon("Product description:".$this->get_string_between($details, 'Product description:', "Application:" ));
|
||||
$application = $this->delimitbyColon("Application:".$this->get_string_between($details, 'Application:', "Benefits:" ));
|
||||
$benefits = $this->delimitbyColon("Benefits:".$this->get_string_between($details, 'Benefits:', FALSE ));
|
||||
array_push($detailsReturn , $product_description);
|
||||
array_push($detailsReturn , $application);
|
||||
array_push($detailsReturn , $benefits);
|
||||
|
||||
return $detailsReturn;
|
||||
}
|
||||
|
||||
private function parseFuel($details)
|
||||
{
|
||||
$details2 = ["level"=>1, "details"=>$details];
|
||||
return [['level'=>0 ,'title'=> "Product description", "details"=> [$this->removeNBSP(str_replace("'","'",str_replace("#39;","'",$details2)))]]];
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function delimitbyColon($details)
|
||||
{
|
||||
$details = explode(":", $details);
|
||||
$details2 = [["level"=>1, "details"=>str_replace(" ",'',$details[1])]];
|
||||
return ['level'=>0 ,'title'=> $details[0], "details"=> $details2];
|
||||
}
|
||||
|
||||
|
||||
private function get_string_between($string, $start, $end){
|
||||
$string = ' ' . $string;
|
||||
$ini = strpos($string, $start);
|
||||
if ($ini == 0) return '';
|
||||
$ini += strlen($start);
|
||||
$len = strpos($string, $end, $ini) - $ini;
|
||||
|
||||
if ($end == false) {
|
||||
$len = strlen($string);
|
||||
}
|
||||
return substr($string, $ini, $len);
|
||||
}
|
||||
|
||||
public function get_fuels_from_products()
|
||||
{
|
||||
$fuel_category = $this->product_details->getProductCategoryByField('type','Fuels');
|
||||
if(count($fuel_category) > 0)
|
||||
{
|
||||
$products = $this->product_details->getProductsByCategory($fuel_category[0]->pc_id);
|
||||
|
||||
if(count($products) > 0)
|
||||
{
|
||||
$return = [];
|
||||
foreach ($products as $key => $value) {
|
||||
if($value['image'] != "") $return[] = $value['name'];
|
||||
// $return[] = $value['name'];
|
||||
}
|
||||
|
||||
return $this->format->mobile_success('Success', array_reverse($return));
|
||||
}
|
||||
}
|
||||
|
||||
return $this->format->mobile_success('No Records Found');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,676 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Libraries\S3;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Contracts\PromotionResourceInterface;
|
||||
use App\Contracts\AdminActionLogsInterface;
|
||||
use App\Contracts\PromotionStationsInterface;
|
||||
use App\Contracts\StationResourceInterface;
|
||||
use App\Contracts\LoyaltyCardResourceInterface;
|
||||
use App\Contracts\SystemPreferenceResourceInterface;
|
||||
use App\Http\Resources\PromotionResource;
|
||||
use App\Libraries\ParameterHelper;
|
||||
use App\Helpers\CurrentUserHelper;
|
||||
use App\Helpers\StringHelper;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use App\Http\Requests\PromotionValidation;
|
||||
use App\Libraries\StaticContents;
|
||||
use App\Promotions;
|
||||
|
||||
class PromotionController extends Controller
|
||||
{
|
||||
const MODULE = 'PROMOTIONS';
|
||||
|
||||
public $promotions;
|
||||
|
||||
public $station;
|
||||
|
||||
public $promotionStations;
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $module;
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $admin_logs;
|
||||
|
||||
protected $loyalty_card;
|
||||
|
||||
protected $system_preferences;
|
||||
|
||||
public function __construct(PromotionResourceInterface $promotions,
|
||||
HttpStatusCode $httpStatusCode,
|
||||
AdminActionLogsInterface $admin_logs,
|
||||
PromotionStationsInterface $promotionStations,
|
||||
StationResourceInterface $station,
|
||||
LoyaltyCardResourceInterface $loyalty_card,
|
||||
SystemPreferenceResourceInterface $system_preferences)
|
||||
{
|
||||
$this->promotions = $promotions;
|
||||
$this->format = $httpStatusCode;
|
||||
$this->module = "cardType";
|
||||
$this->model = "cardType";
|
||||
$this->admin_logs = $admin_logs;
|
||||
$this->station = $station;
|
||||
$this->loyalty_card = $loyalty_card;
|
||||
$this->promotionStations = $promotionStations;
|
||||
$this->system_preferences = $system_preferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$params = [
|
||||
'search' => ($request->has('_search') ? $request->get('_search') : NULL),
|
||||
'page_size' => ($request->has('page_size') ? $request->get('page_size') : 10),
|
||||
'page' => ($request->has('page') ? $request->get('page') : 10),
|
||||
'sorting' => ParameterHelper::prepareSortingParameter($request)
|
||||
];
|
||||
|
||||
// expire top two promotions if date is lapsed
|
||||
$this->promotions->expire_top_two();
|
||||
|
||||
$list = $this->promotions->listing($params);
|
||||
if(count($list))
|
||||
{
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = PromotionResource::collection($list)->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->success("No records found",[]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(PromotionValidation $request)
|
||||
{
|
||||
$id = $this->promotions->store($request);
|
||||
|
||||
if($id)
|
||||
{
|
||||
$station_uuids = json_decode($request->get('station_uuid'));
|
||||
if($station_uuids != null && count($station_uuids))
|
||||
{
|
||||
|
||||
$station_details = $this->station->getDetailsWhereIn('station_uuid',$station_uuids);
|
||||
$station_ids = array();
|
||||
foreach ($station_details as $key => $value) {
|
||||
$station_ids[] = $value['station_id'];
|
||||
}
|
||||
|
||||
$this->promotionStations->store($id, $station_ids);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->admin_logs->log($id,self::MODULE,'STORE');
|
||||
|
||||
return $this->format->created('Promotion has been added');
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->notFound();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($uuid)
|
||||
{
|
||||
$details = $this->promotions->getByField('promotion_uuid',$uuid,'promotionStations.station');
|
||||
|
||||
if($details->count())
|
||||
{
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = (new PromotionResource($details[0]))->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(PromotionValidation $request, $uuid)
|
||||
{
|
||||
$old_data = $this->promotions->getByField('promotion_uuid',$uuid);
|
||||
|
||||
if($old_data->count())
|
||||
{
|
||||
if($this->promotions->update($request,$uuid))
|
||||
{
|
||||
// delete existing stations
|
||||
$this->promotionStations->delete($old_data[0]['promotion_id']);
|
||||
|
||||
// replace new assigned stations -- regardless if changed or not
|
||||
$station_uuids = json_decode($request->get('station_uuid'));
|
||||
if($station_uuids != null && count($station_uuids))
|
||||
{
|
||||
$station_details = $this->station->getDetailsWhereIn('station_uuid',$station_uuids);
|
||||
$station_ids = array();
|
||||
foreach ($station_details as $key => $value) {
|
||||
$station_ids[] = $value['station_id'];
|
||||
}
|
||||
|
||||
$this->promotionStations->store($old_data[0]['promotion_id'], $station_ids);
|
||||
}
|
||||
|
||||
|
||||
$this->admin_logs->log($old_data[0]['promotion_id'],self::MODULE,'UPDATE');
|
||||
return $this->format->success("Promotion has been updated");
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->notFound('Something went wrong');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($uuid)
|
||||
{
|
||||
$details = $this->promotions->getByField('promotion_uuid',$uuid);
|
||||
if($details->count())
|
||||
{
|
||||
$details = $details[0];
|
||||
if($this->promotions->delete($uuid))
|
||||
{
|
||||
$this->admin_logs->log($details['promotion_id'],self::MODULE,'DELETE');
|
||||
return $this->format->success("Promotion Successfully Deleted");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
public function promo_types()
|
||||
{
|
||||
return $this->format->success('Success',StaticContents::promo_type());
|
||||
}
|
||||
|
||||
public function batch_delete(Request $request)
|
||||
{
|
||||
$uuid = $request->has('promotion_uuid') ? $request->get('promotion_uuid') : null;
|
||||
|
||||
if($uuid)
|
||||
{
|
||||
$details = $this->promotions->getDetailsWhereIn('promotion_uuid',$uuid);
|
||||
|
||||
|
||||
$id = array();
|
||||
|
||||
if($this->promotions->delete($uuid))
|
||||
{
|
||||
foreach ($details as $key => $value)
|
||||
{
|
||||
$this->admin_logs->log($value['promotion_id'],self::MODULE,'DELETE');
|
||||
}
|
||||
|
||||
return $this->format->success("Promotion Successfully Deleted");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->badRequest('Something went wrong');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['promotion_uuid'] = 'promotion_uuid is required';
|
||||
return $this->format->unprocessableEntity("Submit at least one item",$data);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_promotions(Request $request)
|
||||
{
|
||||
$selected_promotion_uuid = $request->has('selected_promotion') ? $request->selected_promotion : null;
|
||||
$list = $this->promotions->get_promotion($selected_promotion_uuid);
|
||||
|
||||
$data = array();
|
||||
|
||||
if($list->count())
|
||||
{
|
||||
foreach ($list as $key => $value) {
|
||||
$data[] = array(
|
||||
'promotion_uuid' => $value['promotion_uuid'],
|
||||
'title' => $value['title'],
|
||||
'date_start' => $value['date_start'],
|
||||
'date_end' => $value['date_end'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this->format->success('Success',$data);
|
||||
}
|
||||
|
||||
public function disable_toptwo()
|
||||
{
|
||||
$promotion_uuid = request('promotion_uuid');
|
||||
|
||||
if($promotion_uuid)
|
||||
{
|
||||
$details = $this->promotions->getByField('promotion_uuid',$promotion_uuid);
|
||||
if($details)
|
||||
{
|
||||
if($details[0]['is_toppromotion'] == 1)
|
||||
return $this->format->success('Enable Add in Top 2 Promos',['is_toppromotion' => 'enable']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$toptwo = Promotions::where('is_toppromotion',1)
|
||||
->where('is_active',1)
|
||||
->count();
|
||||
if($toptwo >= 2)
|
||||
{
|
||||
return $this->format->success('Disable Add in Top 2 Promos',['is_toppromotion' => 'disable']);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->success('Enable Add in Top 2 Promos',['is_toppromotion' => 'enable']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function mobile_promotions(Request $request)
|
||||
{
|
||||
if($request->has('lcard_uuid') && $request->lcard_uuid != '')
|
||||
{
|
||||
$member_details = $this->loyalty_card->getByField([
|
||||
'lcard_uuid' => $request->get('lcard_uuid'),
|
||||
'is_active' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$date_now = date('Y-m-d H:i:s');
|
||||
|
||||
$general = $this->promotions->get_promo_by_date_type($date_now, StaticContents::promo_type('General',true));
|
||||
|
||||
if(isset($member_details))
|
||||
{
|
||||
// loyalty exclusive & user specific
|
||||
|
||||
$loyalty_exclusive = $this->promotions->get_promo_by_date_type($date_now, StaticContents::promo_type('Loyalty Exclusive',true));
|
||||
|
||||
$birthday = date('Y-m-d H:i:s',strtotime($member_details[0]['birthdate']));
|
||||
|
||||
$user_specific = $this->promotions->get_promo_by_date_birthdate_type($date_now, $birthday,StaticContents::promo_type('User Specific',true));
|
||||
|
||||
$general = $general->merge($loyalty_exclusive);
|
||||
$general = $general->merge($user_specific);
|
||||
}
|
||||
|
||||
|
||||
$data = [];
|
||||
|
||||
if(count($general))
|
||||
{
|
||||
$general = $general->sortByDesc('date_end');
|
||||
|
||||
// check if latest have equal dates
|
||||
$same_start_dates = [];
|
||||
foreach ($general as $key => $value) {
|
||||
$same_start_dates[date('YmdHis',strtotime($value['date_start']))][] = $value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sorted_data = collect();
|
||||
foreach ($same_start_dates as $date => $promos) {
|
||||
$merge = collect($promos);
|
||||
$merge = $merge->sortBy('created_at');
|
||||
$sorted_data = $sorted_data->merge($merge);
|
||||
}
|
||||
|
||||
|
||||
foreach ($sorted_data as $key => $value) {
|
||||
$stations = [];
|
||||
foreach ($value['promotionStations'] as $k => $v) {
|
||||
$stations[] = [
|
||||
'station_uuid' => $v['station']['station_uuid'],
|
||||
'name' => $v['station']['description'],
|
||||
];
|
||||
}
|
||||
|
||||
$image_url = S3::public_path($value['image']);
|
||||
|
||||
$data[] = [
|
||||
'promotion_uuid' => $value['promotion_uuid'],
|
||||
'title' => $value['title'],
|
||||
'description' => $value['description'],
|
||||
'image' => $image_url,
|
||||
'date_start' => $value['date_start'],
|
||||
'date_end' => $value['date_end'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->format->mobile_success('Success',$data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function mobile_promotions_gps(Request $request)
|
||||
{
|
||||
// get stations within the radius
|
||||
$radius = $this->system_preferences->getByField('name','gps');
|
||||
|
||||
$station = $this->station->radius($radius[0]['value'], $request->longitude, $request->latitude);
|
||||
if($station)
|
||||
{
|
||||
|
||||
if($request->has('lcard_uuid') && $request->lcard_uuid != '')
|
||||
{
|
||||
$member_details = $this->loyalty_card->getByField([
|
||||
'lcard_uuid' => $request->get('lcard_uuid'),
|
||||
'is_active' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
$station_ids = [];
|
||||
|
||||
foreach ($station as $key => $value) {
|
||||
$station_ids[] = $value['station_id'];
|
||||
}
|
||||
|
||||
$date_now = date('Y-m-d H:i:s');
|
||||
|
||||
$all_branches = collect();
|
||||
if(count($station_ids))
|
||||
{
|
||||
$general = $this->promotions->get_promo_by_date_station_gps($station_ids, $date_now, StaticContents::promo_type('General',true));
|
||||
}
|
||||
|
||||
$all_branches_general = $this->promotions->get_all_branch_promo($date_now, StaticContents::promo_type('General',true));
|
||||
$all_branches = $all_branches->merge($all_branches_general);
|
||||
|
||||
if(isset($member_details) && count($member_details) > 0)
|
||||
{
|
||||
// loyalty exclusive & user specific
|
||||
|
||||
$loyalty_exclusive = $this->promotions->get_promo_by_date_station_gps($station_ids,$date_now, StaticContents::promo_type('Loyalty Exclusive',true));
|
||||
|
||||
$all_branches_loyalty = $this->promotions->get_all_branch_promo($date_now, StaticContents::promo_type('Loyalty Exclusive',true));
|
||||
$all_branches = $all_branches->merge($all_branches_loyalty);
|
||||
|
||||
$birthday = date('Y-m-d H:i:s',strtotime($member_details[0]['birthdate']));
|
||||
|
||||
$user_specific = $this->promotions->get_promo_by_birthdate_station_gps($station_ids,$date_now, $birthday,StaticContents::promo_type('User Specific',true));
|
||||
|
||||
if(count($station_ids))
|
||||
{
|
||||
// all branches promotions
|
||||
$all_branches_loyalty_exclusive = $this->promotions->get_all_branch_promo($date_now, StaticContents::promo_type('Loyalty Exclusive',true));
|
||||
$all_branches_user_specific = $this->promotions->get_all_branch_promo_by_birthdate($date_now,$birthday, StaticContents::promo_type('User Specific',true));
|
||||
|
||||
// $general = $general->merge($all_branches_loyalty_exclusive);
|
||||
// $general = $general->merge($all_branches_user_specific);
|
||||
$all_branches = $all_branches->merge($all_branches_loyalty_exclusive);
|
||||
$all_branches = $all_branches->merge($all_branches_user_specific);
|
||||
}
|
||||
|
||||
$general = $general->merge($loyalty_exclusive);
|
||||
$general = $general->merge($user_specific);
|
||||
}
|
||||
|
||||
$data = [];
|
||||
|
||||
/*
|
||||
SORTING RULE :
|
||||
1. nearest station
|
||||
2. date start (latest)
|
||||
3. if date start is the same creation date (latest) should be first
|
||||
*/
|
||||
|
||||
if(count($general) || count($all_branches))
|
||||
{
|
||||
// get from nearest station
|
||||
$nearest = [];
|
||||
if(count($station_ids))
|
||||
{
|
||||
for ($i=0; $i < count($station_ids); $i++)
|
||||
{
|
||||
foreach ($general as $key => $value)
|
||||
{
|
||||
foreach ($value['promotionStations'] as $k => $v)
|
||||
{
|
||||
if($v['station']['station_id'] == $station_ids[$i])
|
||||
$nearest[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if(count($nearest) > 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(count($all_branches))
|
||||
{
|
||||
$nearest = $general->merge($all_branches);
|
||||
}
|
||||
|
||||
$general = collect($nearest);
|
||||
$general = $general->sortByDesc('date_start');
|
||||
|
||||
// check if latest have equal dates
|
||||
$ctr = 1;
|
||||
$same_start_dates = [];
|
||||
foreach ($general as $key => $value) {
|
||||
if($ctr > 1)
|
||||
{
|
||||
if($previous_date_start == $value->date_start)
|
||||
$same_start_dates[] = $value;
|
||||
else
|
||||
break;
|
||||
}
|
||||
else
|
||||
$same_start_dates[] = $value;
|
||||
|
||||
$previous_date_start = $value->date_start;
|
||||
$ctr++;
|
||||
}
|
||||
|
||||
$general = collect($same_start_dates);
|
||||
$general = $general->sortByDesc('created_dt');
|
||||
|
||||
|
||||
foreach ($general as $key => $value) {
|
||||
$stations = [];
|
||||
foreach ($value['promotionStations'] as $k => $v) {
|
||||
$stations[] = [
|
||||
'station_uuid' => $v['station']['station_uuid'],
|
||||
'name' => $v['station']['description'],
|
||||
];
|
||||
}
|
||||
|
||||
$image_url = S3::public_path($value['image']);
|
||||
|
||||
$data[] = [
|
||||
'promotion_uuid' => $value['promotion_uuid'],
|
||||
'title' => $value['title'],
|
||||
'description' => $value['description'],
|
||||
'image' => $image_url,
|
||||
'date_start' => $value['date_start'],
|
||||
'date_end' => $value['date_end'],
|
||||
'station' => $stations,
|
||||
];
|
||||
|
||||
break; // one return only
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $this->format->mobile_success('Success',$data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getTopTwoPromotion(Request $request)
|
||||
{
|
||||
if($request->has('lcard_uuid') && $request->lcard_uuid != '')
|
||||
{
|
||||
$member_details = $this->loyalty_card->getByField([
|
||||
'lcard_uuid' => $request->get('lcard_uuid'),
|
||||
'is_active' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
$date_now = date('Y-m-d');
|
||||
|
||||
|
||||
$general = $this->promotions->getTopTwoPromotion(StaticContents::promo_type('General',true));
|
||||
if (isset($member_details)){
|
||||
if(count($member_details) == 1)
|
||||
{
|
||||
// loyalty exclusive & user specific
|
||||
$loyalty_exclusive = $this->promotions->getTopTwoPromotion(StaticContents::promo_type('Loyalty Exclusive',true));
|
||||
|
||||
$birthday = date('Y-m-d H:i:s',strtotime($member_details[0]['birthdate']));
|
||||
$birthdate = date('Y').'-'.date('m-d',strtotime($birthday));
|
||||
$general = $general->merge($loyalty_exclusive);
|
||||
if($date_now == $birthdate){
|
||||
$user_specific = $this->promotions->getTopTwoPromotion(StaticContents::promo_type('User Specific',true));
|
||||
$general = $general->merge($user_specific);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data = [];
|
||||
if(count($general))
|
||||
{
|
||||
|
||||
$general = collect($general);
|
||||
$general = $general->sortByDesc('date_start');
|
||||
|
||||
// check if latest have equal dates
|
||||
$ctr = 1;
|
||||
$same_start_dates = [];
|
||||
foreach ($general as $key => $value) {
|
||||
// if($ctr > 1)
|
||||
// {
|
||||
// if($previous_date_start == $value->date_start)
|
||||
// $same_start_dates[] = $value;
|
||||
// else
|
||||
// break;
|
||||
// }
|
||||
// else
|
||||
// $same_start_dates[] = $value;
|
||||
|
||||
// $previous_date_start = $value->date_start;
|
||||
// $ctr++;
|
||||
$same_start_dates[$value->date_start][] = $value;
|
||||
}
|
||||
|
||||
$sorted_start_dates = collect();
|
||||
foreach ($same_start_dates as $key => $value) {
|
||||
$v = collect($value);
|
||||
if(count($value) > 1)
|
||||
{
|
||||
$v_sort = $v->sortBy('created_at');
|
||||
$sorted_start_dates = $sorted_start_dates->merge($v_sort);
|
||||
}
|
||||
else
|
||||
$sorted_start_dates = $sorted_start_dates->merge($v);
|
||||
}
|
||||
|
||||
|
||||
$general = $sorted_start_dates;
|
||||
|
||||
|
||||
foreach ($general as $key => $value) {
|
||||
|
||||
$image_url = S3::public_path($value['image']);//S3::public_path($value['image']);
|
||||
|
||||
$data[] = [
|
||||
'promotion_uuid' => $value['promotion_uuid'],
|
||||
'title' => $value['title'],
|
||||
'description' => $value['description'],
|
||||
'image' => $image_url,
|
||||
'date_start' => $value['date_start'],
|
||||
'date_end' => $value['date_end'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->format->mobile_success('Success',$data);
|
||||
|
||||
}
|
||||
|
||||
public function mobile_promotions_details($uuid)
|
||||
{
|
||||
$details = $this->promotions->getByField('promotion_uuid',$uuid);
|
||||
|
||||
if(count($details) > 0)
|
||||
{
|
||||
$image_url = str_replace('/public/index.php','',secure_url('storage/app/'.$details[0]['image']));
|
||||
$image_url = str_replace('https','http',$image_url);
|
||||
|
||||
return $this->format->mobile_success('Success',[
|
||||
'image' => $image_url,
|
||||
'title' => $details[0]['title'],
|
||||
'description' => $details[0]['description'],
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->mobile_error('Incorrect promotion_uuid');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,215 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Contracts\RegistrationResourceInterface;
|
||||
use App\Exports\ReportRegistrationExport;
|
||||
use App\Http\Resources\RegistrationResource;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Contracts\PaymentResourceInterface;
|
||||
use App\Contracts\AdminActionLogsInterface;
|
||||
use App\Contracts\RatingsResourceInterface;
|
||||
use App\Contracts\MobileAnalyticsResourceInterface;
|
||||
use App\Http\Resources\ReportTopUpResource;
|
||||
use App\Http\Resources\ReportStationRatingsResource;
|
||||
use App\Http\Resources\ReportMobileUsageResource;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use App\Libraries\ParameterHelper;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\ReportTopUpExport;
|
||||
use App\Exports\ReportStationRatingsExport;
|
||||
use App\Exports\ReportMobileUsageExport;
|
||||
|
||||
class ReportsController extends Controller
|
||||
{
|
||||
public $payments;
|
||||
|
||||
public $ratings;
|
||||
|
||||
public $mobileAnalytics;
|
||||
|
||||
public $registration;
|
||||
|
||||
protected $format;
|
||||
|
||||
public function __construct(PaymentResourceInterface $payments, HttpStatusCode $httpStatusCode,AdminActionLogsInterface $admin_logs, RatingsResourceInterface $ratings, MobileAnalyticsResourceInterface $mobileAnalytics, RegistrationResourceInterface $registration)
|
||||
{
|
||||
$this->payments = $payments;
|
||||
$this->format = $httpStatusCode;
|
||||
$this->admin_logs = $admin_logs;
|
||||
$this->ratings = $ratings;
|
||||
$this->mobileAnalytics = $mobileAnalytics;
|
||||
$this->registration = $registration;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TOP UP REPORT
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public function top_up(Request $request)
|
||||
{
|
||||
$params = [
|
||||
'search' => ($request->has('_search') ? $request->get('_search') : NULL),
|
||||
'page_size' => ($request->has('page_size') ? $request->get('page_size') : 10),
|
||||
'page' => ($request->has('page') ? $request->get('page') : 10),
|
||||
'date_start' => ($request->has('date_start') ? $request->get('date_start') : null),
|
||||
'date_end' => ($request->has('date_end') ? $request->get('date_end') : null),
|
||||
'sorting' => ParameterHelper::prepareSortingParameter($request)
|
||||
];
|
||||
|
||||
if(ParameterHelper::validateStartEndDate($params))
|
||||
{
|
||||
return $this->format->unprocessableEntity('Start date must not be greater than end date');
|
||||
}
|
||||
|
||||
|
||||
$list = $this->payments->report_topUp($params);
|
||||
|
||||
|
||||
if(count($list))
|
||||
{
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = ReportTopUpResource::collection($list)->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->success("No records found",[]);
|
||||
}
|
||||
}
|
||||
|
||||
public function export_top_up()
|
||||
{
|
||||
$filename = "reports_top_up" . date("mdY") . ".csv";
|
||||
$this->admin_logs->log(0,'REPORT_TOPUP','EXPORT',$filename);
|
||||
return Excel::download(new ReportTopUpExport($this->payments), $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* STATION RATING REPORT
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public function station_rating(Request $request)
|
||||
{
|
||||
$params = [
|
||||
'search' => ($request->has('_search') ? $request->get('_search') : NULL),
|
||||
'page_size' => ($request->has('page_size') ? $request->get('page_size') : 10),
|
||||
'page' => ($request->has('page') ? $request->get('page') : 10),
|
||||
'date_start' => ($request->has('date_start') ? $request->get('date_start') : null),
|
||||
'date_end' => ($request->has('date_end') ? $request->get('date_end') : null),
|
||||
'sorting' => ParameterHelper::prepareSortingParameter($request)
|
||||
];
|
||||
|
||||
if(ParameterHelper::validateStartEndDate($params))
|
||||
{
|
||||
return $this->format->unprocessableEntity('Start date must not be greater than end date');
|
||||
}
|
||||
|
||||
$list = $this->ratings->report_stationRatings($params);
|
||||
|
||||
|
||||
if(count($list))
|
||||
{
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = ReportStationRatingsResource::collection($list)->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->success("No records found",[]);
|
||||
}
|
||||
}
|
||||
|
||||
public function export_station_rating()
|
||||
{
|
||||
$filename = "reports_station_rating" . date("mdY") . ".csv";
|
||||
$this->admin_logs->log(0,'REPORT_STATIONRATINGS','EXPORT',$filename);
|
||||
return Excel::download(new ReportStationRatingsExport($this->ratings), $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* MOBILE USAGE REPORT
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public function mobile_usage(Request $request)
|
||||
{
|
||||
$params = [
|
||||
'page_size' => ($request->has('page_size') ? $request->get('page_size') : 10),
|
||||
'page' => ($request->has('page') ? $request->get('page') : 10),
|
||||
'date_start' => ($request->has('date_start') ? $request->get('date_start') : null),
|
||||
'date_end' => ($request->has('date_end') ? $request->get('date_end') : null),
|
||||
'sorting' => ParameterHelper::prepareSortingParameter($request)
|
||||
];
|
||||
|
||||
|
||||
if(ParameterHelper::validateStartEndDate($params))
|
||||
{
|
||||
return $this->format->unprocessableEntity('Start date must not be greater than end date');
|
||||
}
|
||||
|
||||
$list = $this->mobileAnalytics->report_mobileUsage($params);
|
||||
|
||||
|
||||
if(count($list))
|
||||
{
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = ReportMobileUsageResource::collection($list)->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->success("No records found",[]);
|
||||
}
|
||||
}
|
||||
|
||||
public function export_mobile_usage()
|
||||
{
|
||||
$filename = "reports_mobile_usage" . date("mdY") . ".csv";
|
||||
$this->admin_logs->log(0,'REPORT_MOBILEUSAGE','EXPORT',$filename);
|
||||
return Excel::download(new ReportMobileUsageExport($this->mobileAnalytics), $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* REGISTRATION
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public function registration(Request $request)
|
||||
{
|
||||
$params = [
|
||||
'page_size' => ($request->has('page_size') ? $request->get('page_size') : 10),
|
||||
'page' => ($request->has('page') ? $request->get('page') : 10),
|
||||
'date_start' => ($request->has('date_start') ? $request->get('date_start') : null),
|
||||
'date_end' => ($request->has('date_end') ? $request->get('date_end') : null),
|
||||
'sorting' => ParameterHelper::prepareSortingParameter($request)
|
||||
];
|
||||
|
||||
$list = $this->registration->report_registration($params);
|
||||
|
||||
if(count($list)){
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = RegistrationResource::collection($list)->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}else{
|
||||
return $this->format->success("No records found",[]);
|
||||
}
|
||||
}
|
||||
|
||||
public function export_registration()
|
||||
{
|
||||
$filename = "registration" . date("mdY") . ".csv";
|
||||
$this->admin_logs->log(0,'REPORT_REGISTRATION','EXPORT',$filename);
|
||||
return Excel::download(new ReportRegistrationExport($this->registration), $filename);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Contracts\LcardActionLogsInterface;
|
||||
use App\Helpers\CurrentUserHelper;
|
||||
use App\SharedTreats;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Libraries\ParameterHelper;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class SharedTreatsController extends Controller
|
||||
{
|
||||
|
||||
public $shared_treats;
|
||||
public $admin_logs;
|
||||
|
||||
protected $format;
|
||||
protected $url_encryption;
|
||||
protected $url_gateway;
|
||||
private $lcard_logs;
|
||||
const MODULE = 'SHAREDTREATS';
|
||||
|
||||
public function __construct(HttpStatusCode $httpStatusCode, LcardActionLogsInterface $lcard_logs)
|
||||
{
|
||||
$this->format = $httpStatusCode;
|
||||
$this->lcard_logs = $lcard_logs;
|
||||
$this->module = "SharedTreats";
|
||||
$this->model = "SharedTreats";
|
||||
$this->url_encryption = Config::get('app.sharedtreatsEncryption');
|
||||
$this->url_gateway = Config::get('app.sharedtreatsGateway');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$return = [];
|
||||
|
||||
$member_details = CurrentUserHelper::get_currentMember();
|
||||
|
||||
if (empty($member_details->card_number)){
|
||||
return $this->format->mobile_error('Something went wrong');
|
||||
}
|
||||
if (empty($member_details->mobile)){
|
||||
return $this->format->mobile_error('Something went wrong');
|
||||
}
|
||||
if(!$this->checkMobileNumber($member_details->mobile)){
|
||||
return $this->format->mobile_error('Something went wrong');
|
||||
}
|
||||
|
||||
$card = $member_details->card_number."/1";
|
||||
$data = $this->create_request($card);
|
||||
$encrypted_uuid = $data->result_value;
|
||||
|
||||
$data = $this->create_request($member_details->mobile);
|
||||
$encrypted_mobile = $data->result_value;
|
||||
|
||||
$return['site'] = $this->url_gateway.$encrypted_uuid."/".$encrypted_mobile;
|
||||
|
||||
$this->lcard_logs->log("0",'SHAREDTREATS','VIEW');
|
||||
|
||||
return $this->format->mobile_success('Shared Treats',$return);
|
||||
}
|
||||
|
||||
public function checkMobileNumber($mobileNumber)
|
||||
{
|
||||
if (mb_substr($mobileNumber, 0, 2) == "63"){
|
||||
return $mobileNumber;
|
||||
}elseif(mb_substr($mobileNumber, 0, 2) == "09" ){
|
||||
return "63".substr($mobileNumber, -10);
|
||||
}elseif(mb_substr($mobileNumber, 0, 1) == "9"){
|
||||
return "63".substr($mobileNumber, -10);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function create_request($params)
|
||||
{
|
||||
$url = $this->url_encryption ;
|
||||
$this->uri = new Uri($url.$params);
|
||||
$client = new Client();
|
||||
$response = $client->request('GET', $this->uri,[]);
|
||||
return json_decode($response->getBody()->getContents()) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,457 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Libraries\CywareLibrary;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use App\Libraries\ParameterHelper;
|
||||
use App\Http\Requests\MobileSignupFormValidation;
|
||||
use App\Http\Requests\MobileSignupIDNumberValidation;
|
||||
use App\Http\Resources\MobileUserProfileResource;
|
||||
use App\Contracts\LoyaltyCardResourceInterface;
|
||||
use App\Contracts\CardTypeResourceInterface;
|
||||
use App\Contracts\PersonalDetailsResourceInterface;
|
||||
use App\Contracts\UserResourceInterface;
|
||||
use App\Contracts\MobileAnalyticsResourceInterface;
|
||||
use App\Contracts\LcardActionLogsInterface;
|
||||
use App\Contracts\SignUpAPICallsInterface;
|
||||
use App\Http\Resources\LoyaltyCardSignUpResource;
|
||||
use App\Http\Resources\LoyaltyCardSignUpCMSResource;
|
||||
use App\Libraries\StaticContents;
|
||||
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
class SignUpController extends Controller
|
||||
{
|
||||
const MODULE = 'SIGNUP';
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $module;
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $loyaltyCard;
|
||||
|
||||
protected $cardtype;
|
||||
|
||||
protected $personalDetails;
|
||||
|
||||
protected $user;
|
||||
|
||||
protected $mobile_usage;
|
||||
|
||||
protected $signupAPICalls;
|
||||
|
||||
public function __construct(LoyaltyCardResourceInterface $loyaltyCard,
|
||||
HttpStatusCode $httpStatusCode,
|
||||
CardTypeResourceInterface $cardtype,
|
||||
PersonalDetailsResourceInterface $personalDetails,
|
||||
UserResourceInterface $user,
|
||||
MobileAnalyticsResourceInterface $mobile_usage,
|
||||
LcardActionLogsInterface $lcard_logs,
|
||||
SignUpAPICallsInterface $signupAPICalls)
|
||||
{
|
||||
$this->loyaltyCard = $loyaltyCard;
|
||||
$this->cardtype = $cardtype;
|
||||
$this->personalDetails = $personalDetails;
|
||||
$this->mobile_usage = $mobile_usage;
|
||||
$this->user = $user;
|
||||
$this->lcard_logs = $lcard_logs;
|
||||
$this->signupAPICalls = $signupAPICalls;
|
||||
$this->format = $httpStatusCode;
|
||||
$this->module = "SignUp";
|
||||
$this->model = "LoyaltyCardSignUp";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
|
||||
/*
|
||||
NOTE: THIS FEATURE IS FROM THE INITIAL PLAN FOR CR1
|
||||
*/
|
||||
// public function index(Request $request)
|
||||
// {
|
||||
// $params = [
|
||||
// 'search' => ($request->has('_search') ? $request->get('_search') : NULL),
|
||||
// 'page_size' => ($request->has('page_size') ? $request->get('page_size') : 10),
|
||||
// 'page' => ($request->has('page') ? $request->get('page') : 10),
|
||||
// 'sorting' => ParameterHelper::prepareSortingParameter($request),
|
||||
// 'status' => ($request->has('status') ? $request->status : NULL),
|
||||
// ];
|
||||
|
||||
// if(count($params['status']))
|
||||
// {
|
||||
// foreach ($params['status'] as $key => $value) {
|
||||
// $params['status'][$key] = StaticContents::loyalty_card_signup_status($value,true);
|
||||
// }
|
||||
// }
|
||||
|
||||
// $list = $this->signup->listing($params);
|
||||
|
||||
// // dd($list);
|
||||
|
||||
// if(count($list))
|
||||
// {
|
||||
// $additionals = $this->format->success("Success",[],false);
|
||||
// $data = LoyaltyCardSignUpCMSResource::collection($list)->additional($additionals);
|
||||
// return $data->response()->setStatusCode(200);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return $this->format->success("No records found",[]);
|
||||
// }
|
||||
// }
|
||||
|
||||
public function check_id_number(MobileSignupIDNumberValidation $request)
|
||||
{
|
||||
$card_details = $this->cardtype->getByField(['cardtype_uuid' => $request->cardtype_uuid]);
|
||||
|
||||
if(count($card_details) > 0)
|
||||
{
|
||||
$card_details = $card_details[0];
|
||||
if($card_details->id_number == 1)
|
||||
{
|
||||
$cyware = new CywareLibrary();
|
||||
$cyware->setCardTypeCode($card_details->code);
|
||||
$cyware->setIDNumber($request->id_number);
|
||||
$cyware->state_id_entry();
|
||||
|
||||
if(isset($cyware->response['result']))
|
||||
{
|
||||
|
||||
// NOTE : cyware returns sql:success for unused and used id numbers
|
||||
|
||||
if($cyware->response['status_code'] == "200" && $cyware->response['message'] == "success" && $cyware->response['result'] == "Valid ID Number")
|
||||
{
|
||||
return $this->format->mobile_success($cyware->response['result'],[]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->mobile_error($cyware->response['result'],[]);
|
||||
}
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error($cyware->response['message'],[]);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->mobile_success('Card Type doesn\'t require ID Number');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->mobile_error('Card Type doesn\'t exists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* Accessed by MOBILE
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
/*
|
||||
NOTE: THIS FEATURE IS FROM THE INITIAL PLAN FOR CR1
|
||||
*/
|
||||
public function store(MobileSignupFormValidation $request)
|
||||
{
|
||||
$card_details = $this->cardtype->getByField(['cardtype_uuid' => $request->cardtype_uuid]);
|
||||
if(count($card_details) > 0)
|
||||
{
|
||||
$card_details = $card_details[0];
|
||||
$user_id = env("USER_ID_PRE_IDENTIFIER", '').date('Ymd').($this->signupAPICalls->count() + 1);
|
||||
$signup_api_id = $this->signupAPICalls->log($user_id);
|
||||
|
||||
$cyware = new CywareLibrary();
|
||||
$cyware->setCardTypeCode($card_details->code);
|
||||
$cyware->setIDNumber($request->id_number);
|
||||
$cyware->setFirstName($request->firstname);
|
||||
$cyware->setLastName($request->lastname);
|
||||
$cyware->setBirthday(date('Ymd',strtotime($request->birthdate)));
|
||||
$mobile = strlen($request->mobile) == 12 ? $request->mobile : '63'.$request->mobile;
|
||||
$cyware->setMobile($mobile);
|
||||
$cyware->setEmail($request->email);
|
||||
$cyware->setUserID($user_id);
|
||||
$cyware->state_app_entry();
|
||||
|
||||
if($cyware->response['status_code'] == "200" && $cyware->response['message'] == "success")
|
||||
{
|
||||
// save on personal details
|
||||
$pd_id = $this->personalDetails->store_signup($request);
|
||||
|
||||
// save on loyalty card
|
||||
$lcard_det = $this->loyaltyCard->store_signup($pd_id,(object)[
|
||||
'card_number' => $cyware->response['card_number'],
|
||||
'pin' => $cyware->response['pin'],
|
||||
'birthdate' => $request->birthdate,
|
||||
'mobile' => $mobile,
|
||||
'email' => $request->email,
|
||||
'card_id' => $card_details->cardtype_id
|
||||
]);
|
||||
|
||||
// log user in
|
||||
$this->user->store_member((object)[
|
||||
'first_name' => $request->firstname,
|
||||
'last_name' => $request->lastname,
|
||||
'card_number' => $cyware->response['card_number'],
|
||||
'birthdate' => $request->birthdate,
|
||||
]);
|
||||
|
||||
$this->mobile_usage->add_active();
|
||||
$this->signupAPICalls->success($signup_api_id,$lcard_det['lcard_id']);
|
||||
|
||||
if(Auth::attempt([ 'username' => $cyware->response['card_number'], 'password' => $request->birthdate ]))
|
||||
{
|
||||
$getuserDetails = $this->loyaltyCard->show($lcard_det['lcard_uuid'],['personalDetails','codeVehicleOwn','codeCivilStatus','codeGender','codeCardType','codeCity','codeFuelType']);
|
||||
$data = new MobileUserProfileResource($getuserDetails);
|
||||
$userDetails = null;
|
||||
if($data != null){
|
||||
$userDetails = $data->toArray($getuserDetails);
|
||||
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
$success['is_valid'] = 1;
|
||||
// $success['lcard_uuid'] = $lcard_det['lcard_uuid'];
|
||||
// $success['birthdate'] = $request->birthdate;
|
||||
// $success['mobile'] = $request->mobile;
|
||||
// $success['card_number'] = $cyware->response['card_number'];
|
||||
// $success['user_id'] = $user['id'];
|
||||
|
||||
// ---------------------------------------------------------------- new login start
|
||||
|
||||
$data = [
|
||||
'grant_type' => 'password',
|
||||
'client_id' => env("PASSPORT_ADMIN_CLIENT_ID", 2),
|
||||
'client_secret' => env("PASSPORT_ADMIN_CLIENT_SECRET", "test"),
|
||||
'username' => $cyware->response['card_number'],
|
||||
'password' => $request->birthdate,
|
||||
'scope' => ''
|
||||
];
|
||||
|
||||
$request = Request::create('/oauth/token', 'POST', $data);
|
||||
$result = app()->handle($request)->getContent();
|
||||
$result = json_decode($result);
|
||||
|
||||
$success['token'] = $result->access_token;
|
||||
$userDetails['customer_number'] = $cyware->response['customer_number'];
|
||||
$success['userDetails'] = $userDetails;
|
||||
// ---------------------------------------------------------------- new login end
|
||||
|
||||
$this->lcard_logs->log($lcard_det['lcard_id'],'SIGNUP','LOGIN','Member successfully signs up');
|
||||
return $this->format->mobile_success('Success',$success);
|
||||
}
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error($cyware->response['message']);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->mobile_error('Card Type doesn\'t exists');
|
||||
}
|
||||
}
|
||||
|
||||
// public function store(MobileSignupFormValidation $request)
|
||||
// {
|
||||
// $uuid = $this->signup->store($request);
|
||||
|
||||
// return $this->format->mobile_success('Success',[
|
||||
// 'lcard_s_uuid' => $uuid,
|
||||
// ]);
|
||||
// }
|
||||
|
||||
/*
|
||||
NOTE: THIS FEATURE IS FROM THE INITIAL PLAN FOR CR1
|
||||
*/
|
||||
// public function upload(Request $request)
|
||||
// {
|
||||
// if($this->signup->upload_document($request))
|
||||
// return $this->format->mobile_success('Successfully Updated');
|
||||
// else
|
||||
// return $this->format->mobile_errror('Something went wrong');
|
||||
// }
|
||||
|
||||
/*
|
||||
NOTE: THIS FEATURE IS FROM THE INITIAL PLAN FOR CR1
|
||||
*/
|
||||
// public function signupSubmit($uuid)
|
||||
// {
|
||||
// // check if there's already a reference number
|
||||
// $details = $this->signup->getByField([
|
||||
// 'lcard_s_uuid' => $uuid
|
||||
// ]);
|
||||
|
||||
// if($details)
|
||||
// {
|
||||
// if($details[0]->ref_no == '')
|
||||
// {
|
||||
// // create reference number
|
||||
// $count = $this->signup->count_between(date('Y-m-d 00:00:00'), date('Y-m-d 23:59:59'));
|
||||
// $ref_no = 'REF-'.date('Ymd').'-'.str_pad($count, 5, "0", STR_PAD_LEFT);
|
||||
|
||||
|
||||
// // send email to Super Admin -- TODO!
|
||||
|
||||
// if($this->signup->assign_ref_no($uuid,$ref_no))
|
||||
// return $this->format->mobile_success('Success',['ref_no' => $ref_no]);
|
||||
// else
|
||||
// return $this->format->mobile_errror('Something went wrong');
|
||||
// }
|
||||
// else
|
||||
// return $this->format->mobile_success('Success',['ref_no' => $details[0]->ref_no]);
|
||||
// }
|
||||
// else
|
||||
// return $this->format->mobile_errror('User does not exists');
|
||||
// }
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
|
||||
/*
|
||||
NOTE: THIS FEATURE IS FROM THE INITIAL PLAN FOR CR1
|
||||
*/
|
||||
// public function show($uuid)
|
||||
// {
|
||||
// $details = $this->signup->getByField(['lcard_s_uuid' => $uuid],['codeCardType','idNumberType']);
|
||||
|
||||
// if($details)
|
||||
// {
|
||||
// $additionals = $this->format->success("Success",[],false);
|
||||
// $data = (new LoyaltyCardSignUpCMSResource($details[0]))->additional($additionals);
|
||||
// return $data->response()->setStatusCode(200);
|
||||
// }
|
||||
// else
|
||||
// return $this->format->notFound();
|
||||
// }
|
||||
|
||||
/*
|
||||
NOTE: THIS FEATURE IS FROM THE INITIAL PLAN FOR CR1
|
||||
*/
|
||||
// public function review($uuid)
|
||||
// {
|
||||
// $details = $this->signup->getByField(['lcard_s_uuid' => $uuid],['codeCardType','idNumberType']);
|
||||
|
||||
// if($details->count())
|
||||
// {
|
||||
// $additionals = $this->format->mobile_success("Success",[],false);
|
||||
// $data = (new LoyaltyCardSignUpResource($details[0]))->additional($additionals);
|
||||
// return $data->response()->setStatusCode(200);
|
||||
// }
|
||||
// else
|
||||
// return $this->format->mobile_error('User not found');
|
||||
// }
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/*
|
||||
NOTE: THIS FEATURE IS FROM THE INITIAL PLAN FOR CR1
|
||||
*/
|
||||
// public function reject(Request $request)
|
||||
// {
|
||||
// // reject application
|
||||
|
||||
// // replace mark ups on SELECTED template
|
||||
|
||||
// // sms and email
|
||||
// }
|
||||
|
||||
/*
|
||||
NOTE: THIS FEATURE IS FROM THE INITIAL PLAN FOR CR1
|
||||
*/
|
||||
// public function approve($uuid)
|
||||
// {
|
||||
// // submit to cyware
|
||||
|
||||
// // if okay -- approve application
|
||||
|
||||
// // replace mark ups on FIXED approve template
|
||||
|
||||
// // sms and email
|
||||
|
||||
// // return token
|
||||
// }
|
||||
|
||||
/*
|
||||
NOTE: THIS FEATURE IS FROM THE INITIAL PLAN FOR CR1
|
||||
*/
|
||||
// public function test()
|
||||
// {
|
||||
// $mail = new PHPMailer(true);
|
||||
|
||||
// try {
|
||||
|
||||
// $mail->SMTPDebug = 2; // Enable verbose debug output
|
||||
// $mail->isSMTP(); // Set mailer to use SMTP
|
||||
// // $mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
|
||||
// $mail->Host = 'smtp.gmail.com';
|
||||
// $mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
// $mail->Username = 'yondutesting@gmail.com'; // SMTP username
|
||||
// $mail->Password = 'myY0nduP@ssword01'; // SMTP password
|
||||
// $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
|
||||
// $mail->Port = 587; // TCP port to connect to
|
||||
|
||||
// }
|
||||
|
||||
// echo "here";
|
||||
// }
|
||||
|
||||
}
|
|
@ -1,887 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Contracts\StationResourceInterface;
|
||||
use App\Contracts\AdminActionLogsInterface;
|
||||
use App\Contracts\LcardActionLogsInterface;
|
||||
use App\Contracts\StationFuelPricesInterface;
|
||||
use App\Contracts\StationFavoriteResourceInterface;
|
||||
// use App\Http\Resources\StationResource;
|
||||
use App\Libraries\ParameterHelper;
|
||||
use App\Helpers\CurrentUserHelper;
|
||||
use App\Helpers\StringHelper;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use App\Http\Resources\StationLocatorResource;
|
||||
use App\Http\Resources\StationSearchResource;
|
||||
use App\Libraries\StratuscastLibrary;
|
||||
use App\Libraries\RNRPHLibrary;
|
||||
use App\Libraries\StaticContents;
|
||||
use App\Station;
|
||||
use App\CodeCity;
|
||||
|
||||
class StationController extends Controller
|
||||
{
|
||||
const MODULE = 'STATION';
|
||||
|
||||
public $station;
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $module;
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $admin_logs;
|
||||
|
||||
protected $lcard_logs;
|
||||
|
||||
protected $station_favorite;
|
||||
|
||||
protected $station_fuel_prices;
|
||||
|
||||
public function __construct(StationResourceInterface $station,
|
||||
HttpStatusCode $httpStatusCode,
|
||||
AdminActionLogsInterface $admin_logs,
|
||||
LcardActionLogsInterface $lcard_logs,
|
||||
StationFavoriteResourceInterface $station_favorite,
|
||||
StationFuelPricesInterface $station_fuel_prices)
|
||||
{
|
||||
$this->station = $station;
|
||||
$this->format = $httpStatusCode;
|
||||
$this->module = "station";
|
||||
$this->model = "station";
|
||||
$this->admin_logs = $admin_logs;
|
||||
$this->lcard_logs = $lcard_logs;
|
||||
$this->station_favorite = $station_favorite;
|
||||
$this->station_fuel_prices = $station_fuel_prices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function get_viewable()
|
||||
{
|
||||
$details = $this->station->getByField('is_viewable',1);
|
||||
|
||||
if(count($details) > 0)
|
||||
{
|
||||
$parsed = array();
|
||||
foreach ($details as $key => $value)
|
||||
{
|
||||
if($value['is_active'] == 1)
|
||||
{
|
||||
$parsed[] = array(
|
||||
'station_uuid' => $value['station_uuid'],
|
||||
'code' => $value['code'],
|
||||
'description' => $value['description'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->format->success('Success',$parsed);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->noContent('No stations saved');
|
||||
}
|
||||
}
|
||||
|
||||
public function nearby(Request $request)
|
||||
{
|
||||
$this->lcard_logs->log(0,'STATIONLOCATOR','VIEW','Member views nearby stations');
|
||||
$station = $this->station->nearby($request->longitude, $request->latitude);
|
||||
|
||||
if(count($station))
|
||||
{
|
||||
$additionals = $this->format->mobile_success("Success",[],false);
|
||||
$data = StationLocatorResource::collection($station)->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->mobile_success("Empty");
|
||||
}
|
||||
}
|
||||
|
||||
public function favorites()
|
||||
{
|
||||
$this->lcard_logs->log(0,'STATIONLOCATOR','VIEW','Member views favorite stations');
|
||||
$station = $this->station->favorites();
|
||||
|
||||
if(count($station))
|
||||
{
|
||||
$additionals = $this->format->mobile_success("Success",[],false);
|
||||
$data = StationLocatorResource::collection($station)->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->mobile_success("Empty",[]);
|
||||
}
|
||||
}
|
||||
|
||||
public function search(Request $request)
|
||||
{
|
||||
if($request->has('keyword'))
|
||||
{
|
||||
$this->lcard_logs->log(0,'STATIONLOCATOR','SEARCH','Member searches for keyword '.$request->search);
|
||||
$city = $this->station->search_by_keyword($request->keyword);
|
||||
}
|
||||
elseif ($request->has('province_uuid'))
|
||||
{
|
||||
$this->lcard_logs->log(0,'STATIONLOCATOR','SEARCH','Member searches station via province ');
|
||||
$city = $this->station->search_by_province($request->province_uuid);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->lcard_logs->log(0,'STATIONLOCATOR','SEARCH','Member searches station');
|
||||
$city = $this->station->search_all();
|
||||
}
|
||||
|
||||
if($city)
|
||||
{
|
||||
return $this->format->mobile_success("Success",$city);
|
||||
// $data = StationSearchResource::collection($city)->additional($additionals);
|
||||
// return $data->response()->setStatusCode(200);
|
||||
// return $additionals;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->mobile_success("Empty");
|
||||
}
|
||||
}
|
||||
|
||||
public function by_province(Request $request)
|
||||
{
|
||||
$this->lcard_logs->log(0,'STATIONLOCATOR','SEARCH','Member searches station via province ');
|
||||
$city = $this->station->search_by_province($request->province_uuid);
|
||||
|
||||
if($city)
|
||||
{
|
||||
$additionals = $this->format->mobile_success("Success",[],false);
|
||||
$data = StationSearchResource::collection($city)->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->mobile_success("Empty");
|
||||
}
|
||||
}
|
||||
|
||||
public function by_city($uuid)
|
||||
{
|
||||
$this->lcard_logs->log(0,'STATIONLOCATOR','SEARCH','Member searches station via city');
|
||||
$station = $this->station->search_by_city($uuid);
|
||||
if(count($station))
|
||||
{
|
||||
$additionals = $this->format->mobile_success("Success",[],false);
|
||||
$data = StationLocatorResource::collection($station)->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->mobile_success("Empty",[]);
|
||||
}
|
||||
}
|
||||
|
||||
public function fuel_prices($uuid)
|
||||
{
|
||||
$station = $this->station->search_by_uuid($uuid);
|
||||
|
||||
if($station)
|
||||
{
|
||||
$this->lcard_logs->log($station[0]['sid'],'STATIONLOCATOR','VIEW','Member views station details');
|
||||
$stratuscast = new StratuscastLibrary();
|
||||
$stratuscast->getFuelPriceBystation($station[0]['code']);
|
||||
$db_fuel_prices = $this->station_fuel_prices->getByField([
|
||||
'station_id' => $station[0]['sid'],
|
||||
'is_active' => 1,
|
||||
],
|
||||
null,
|
||||
[
|
||||
'field' => 'updated_at',
|
||||
'value' => 'asc'
|
||||
]);
|
||||
|
||||
$db = [];
|
||||
$latest_update = date('M d, Y');
|
||||
if(count($db_fuel_prices))
|
||||
{
|
||||
foreach ($db_fuel_prices as $k => $v)
|
||||
{
|
||||
$db[$v['fuel_code']] = $v;
|
||||
$latest_update = date('M d, Y',strtotime($v['updated_at']));
|
||||
}
|
||||
}
|
||||
|
||||
$fuel_type = StaticContents::fuelType_code();
|
||||
|
||||
$fuel_prices = [];
|
||||
$except_where_in = []; // delete fuel prices that are not returned by stratuscast
|
||||
if(count($stratuscast->response['data']))
|
||||
{
|
||||
foreach ($stratuscast->response['data'] as $key => $value) {
|
||||
if($value->price != '')
|
||||
{
|
||||
if(isset($db[$value->fuel_code]))
|
||||
{
|
||||
if($db[$value->fuel_code]['price'] != $value->price)
|
||||
$this->station_fuel_prices->update_price($db[$value->fuel_code]['fuel_price_uuid'],$value->price);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->station_fuel_prices->store($station[0]['sid'],[
|
||||
'fuel_code' => $value->fuel_code,
|
||||
'fuel_name' => isset($fuel_type[$value->fuel_code]) ? $fuel_type[$value->fuel_code] : '',
|
||||
'price' => $value->price,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$fuel_prices[] = [
|
||||
'fuel_code' => $value->fuel_code,
|
||||
'fuel_name' => isset($fuel_type[$value->fuel_code]) ? $fuel_type[$value->fuel_code] : '',
|
||||
'price' => $value->price,
|
||||
];
|
||||
|
||||
$except_where_in[] = $value->fuel_code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// delete others
|
||||
$this->station_fuel_prices->delete($station[0]['sid'],$except_where_in);
|
||||
|
||||
return $this->format->mobile_success('Success',[
|
||||
'name' => $station[0]['description'],
|
||||
'address' => $station[0]['address'],
|
||||
'longitude' => $station[0]['longitude'],
|
||||
'latitude' => $station[0]['latitude'],
|
||||
'favorite' => $station[0]['favorite'] > 0 ? true : false,
|
||||
'contact_numbers' => explode("/", $station[0]['contact_number']),
|
||||
'stars' => round($station[0]['average']),
|
||||
'fuel_prices' => $fuel_prices,
|
||||
'latest_update' => $latest_update
|
||||
]);
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error('Station Not Found');
|
||||
}
|
||||
|
||||
public function set_favorite($uuid)
|
||||
{
|
||||
$station = $this->station->getByField('station_uuid',$uuid);
|
||||
|
||||
if(count($station))
|
||||
{
|
||||
$member_details = CurrentUserHelper::get_currentMember();
|
||||
if($this->station_favorite->store($station[0]['station_id'], $member_details->lcard_id))
|
||||
{
|
||||
$this->lcard_logs->log($station[0]['station_id'],'STATIONLOCATOR','STORE','Member added station to favorites');
|
||||
return $this->format->mobile_success('Station added to favorites');
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error('Error on save');
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error('Station Not Found');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function delete_favorite($uuid)
|
||||
{
|
||||
$station = $this->station->getByField('station_uuid',$uuid);
|
||||
|
||||
if(count($station))
|
||||
{
|
||||
$member_details = CurrentUserHelper::get_currentMember();
|
||||
if($this->station_favorite->delete($station[0]['station_id'], $member_details->lcard_id))
|
||||
{
|
||||
$this->lcard_logs->log($station[0]['station_id'],'STATIONLOCATOR','DELETE','Member deleted a station to favorites');
|
||||
return $this->format->mobile_success('Station deleted to favorites');
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error('Error on delete');
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error('Station Not Found');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
note : execute to sync details from stratuscast
|
||||
|
||||
*/
|
||||
public function manual_overide()
|
||||
{
|
||||
$stratuscast = new StratuscastLibrary();
|
||||
$stratuscast->getAllFuelPrice();
|
||||
|
||||
if(isset($stratuscast->response['data']))
|
||||
{
|
||||
foreach ($stratuscast->response['data'] as $key => $value) {
|
||||
$searched = $this->station->search_by_code($value->station_code);
|
||||
|
||||
if(count($searched) > 0)
|
||||
{
|
||||
$this->station->update_content($value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$this->station->store($value))
|
||||
{
|
||||
return $this->format->badRequest('Something went wrong');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->format->success('Success');
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->badRequest('Something went wrong');
|
||||
}
|
||||
}
|
||||
|
||||
//RNRPH Library
|
||||
|
||||
public function get_provinces(){
|
||||
try {
|
||||
$rnrph = new RNRPHLibrary();
|
||||
$rnrph->getAllProvinces();
|
||||
$return = [];
|
||||
$previous_province = '';
|
||||
$ctr = 0;
|
||||
$current_array = [];
|
||||
|
||||
foreach ($rnrph->response['data'] as $key => $province)
|
||||
{
|
||||
if($previous_province != $province->name)
|
||||
{
|
||||
if($ctr != 0)
|
||||
$return[] = $current_array;
|
||||
|
||||
$current_array = [];
|
||||
|
||||
$current_array['name'] = $province->name;
|
||||
$current_array['city'][] = [
|
||||
'name' => $province->city_name,
|
||||
'city_uuid' => $province->city_uuid,
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
$current_array['city'][] = [
|
||||
'name' => $province->city_name,
|
||||
'city_uuid' => $province->city_uuid,
|
||||
];
|
||||
}
|
||||
$previous_province = $province->name;
|
||||
$ctr++;
|
||||
}
|
||||
|
||||
return $this->format->mobile_success('Success',$return);
|
||||
} catch (Exception $e) {
|
||||
return $this->format->mobile_error('Something went wrong');
|
||||
}
|
||||
}
|
||||
|
||||
public function get_stations(){
|
||||
try {
|
||||
$rnrph = new RNRPHLibrary();
|
||||
$rnrph->getAllStations();
|
||||
$details = $rnrph->response['data'];
|
||||
|
||||
if(count($details) > 0)
|
||||
{
|
||||
$parsed = array();
|
||||
foreach ($details as $key => $value)
|
||||
{
|
||||
$parsed[] = array(
|
||||
'station_uuid' => $value->station_uuid,
|
||||
'code' => $value->code,
|
||||
'description' => $value->description,
|
||||
);
|
||||
}
|
||||
|
||||
return $this->format->success('Success',$parsed);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->noContent('No stations saved');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return $this->format->mobile_error('Something went wrong');
|
||||
}
|
||||
}
|
||||
|
||||
public function get_cities(){
|
||||
try {
|
||||
$rnrph = new RNRPHLibrary();
|
||||
$rnrph->getAllBranches();
|
||||
$details = $rnrph->response['data'];
|
||||
|
||||
if(count($details) > 0)
|
||||
{
|
||||
|
||||
return $this->format->success('Success',$details);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->noContent('No stations saved');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return $this->format->mobile_error('Something went wrong');
|
||||
}
|
||||
}
|
||||
|
||||
public function db_get_station_fuel_prices($id) {
|
||||
try{
|
||||
$fuel_prices = [];
|
||||
$db_fuel_prices = $this->station_fuel_prices->getByField([
|
||||
'station_id' => $id,
|
||||
'is_active' => 1,
|
||||
],
|
||||
null,
|
||||
[
|
||||
'field' => 'updated_at',
|
||||
'value' => 'asc'
|
||||
]);
|
||||
$db = [];
|
||||
$latest_update = date('M d, Y');
|
||||
if(count($db_fuel_prices))
|
||||
{
|
||||
foreach ($db_fuel_prices as $k => $v)
|
||||
{
|
||||
// $db[$v['fuel_code']] = array(
|
||||
// 'fuel_code' => $v->fuel_code,
|
||||
// 'fuel_name' => $v->fuel_name,
|
||||
// 'price' => $v->price
|
||||
// );
|
||||
$db[] = array(
|
||||
'fuel_code' => $v->fuel_code,
|
||||
'fuel_name' => $v->fuel_name,
|
||||
'price' => $v->price
|
||||
);
|
||||
// $db[] = $v;
|
||||
$latest_update = date('M d, Y',strtotime($v['updated_at']));
|
||||
}
|
||||
return array(
|
||||
'latest_update' => $latest_update,
|
||||
'list' => $db
|
||||
);
|
||||
}else{
|
||||
return array(
|
||||
'latest_update' => "",
|
||||
'list' => []
|
||||
);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
return array(
|
||||
'latest_update' => "",
|
||||
'list' => []
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function sort_fuels($fuels){
|
||||
|
||||
}
|
||||
|
||||
public function get_station_fuels(){
|
||||
try {
|
||||
$rnrph = new RNRPHLibrary();
|
||||
$rnrph->getAllStations();
|
||||
$details = $rnrph->response['data'];
|
||||
|
||||
if(count($details) > 0)
|
||||
{
|
||||
$stations = array();
|
||||
foreach ($details as $key => $value)
|
||||
{
|
||||
|
||||
$fuelFromDB = $this->parse_fuels($value->StationFuels);
|
||||
$stations[] = array(
|
||||
'name' => $value->description,
|
||||
'address' => $value->address,
|
||||
'longitude' => $value->longitude,
|
||||
'latitude' => $value->latitude,
|
||||
// 'favorite' => $value->favorite && $value->favorite > 0 ? true : false,
|
||||
'favorite' => false,
|
||||
'contact_numbers' => $value->contact_number,
|
||||
// 'stars' => round($value->rating || 0),
|
||||
'stars' => 0,
|
||||
'fuel_prices' => $fuelFromDB['list'],
|
||||
'latest_update' => $fuelFromDB['latest_update'],
|
||||
'full' => $value
|
||||
);
|
||||
|
||||
}
|
||||
return $this->format->success('Success', $stations);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->noContent('No stations saved');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return $this->format->mobile_error('Something went wrong');
|
||||
}
|
||||
}
|
||||
|
||||
public function manual_update()
|
||||
{
|
||||
$stratuscast = new RNRPHLibrary();
|
||||
$stratuscast->getAllStations();
|
||||
|
||||
if(isset($stratuscast->response['data']))
|
||||
{
|
||||
$ids = [];
|
||||
$st = $this->station->get_active_stations();
|
||||
foreach ($st as $key => $value) {
|
||||
array_push($ids,$value->station_id);
|
||||
}
|
||||
$this->station->disbale_stations($ids);
|
||||
foreach ($stratuscast->response['data'] as $key => $value) {
|
||||
$searched = $this->station->search_by_code($value->code);
|
||||
|
||||
if(count($searched) > 0)
|
||||
{
|
||||
$this->station->update_stations($value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$this->station->store($value))
|
||||
{
|
||||
return $this->format->badRequest('Something went wrong');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->format->success('Success');
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->badRequest('Something went wrong');
|
||||
}
|
||||
}
|
||||
|
||||
public function parse_fuels($fuels) {
|
||||
try{
|
||||
$fuel_prices = [];
|
||||
$db = [];
|
||||
$latest_update = date('M d, Y');
|
||||
if(count($fuels))
|
||||
{
|
||||
foreach ($fuels as $k => $v)
|
||||
{
|
||||
$db[] = array(
|
||||
'fuel_code' => $v->Fuel->code,
|
||||
'fuel_name' => $v->Fuel->name,
|
||||
'price' => $v->price
|
||||
);
|
||||
$latest_update = date('M d, Y',strtotime($v->updatedAt));
|
||||
}
|
||||
return array(
|
||||
'latest_update' => $latest_update,
|
||||
'list' => $db
|
||||
);
|
||||
}else{
|
||||
return array(
|
||||
'latest_update' => "",
|
||||
'list' => []
|
||||
);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
return array(
|
||||
'latest_update' => "",
|
||||
'list' => []
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function sortByField($multArray,$sortField,$desc=true){
|
||||
$tmpKey='';
|
||||
$ResArray=array();
|
||||
|
||||
$maIndex=array_keys($multArray);
|
||||
$maSize=count($multArray)-1;
|
||||
|
||||
for($i=0; $i < $maSize ; $i++) {
|
||||
|
||||
$minElement=$i;
|
||||
$tempMin=$multArray[$maIndex[$i]][$sortField];
|
||||
$tmpKey=$maIndex[$i];
|
||||
|
||||
for($j=$i+1; $j <= $maSize; $j++)
|
||||
if($multArray[$maIndex[$j]][$sortField] < $tempMin ) {
|
||||
$minElement=$j;
|
||||
$tmpKey=$maIndex[$j];
|
||||
$tempMin=$multArray[$maIndex[$j]][$sortField];
|
||||
|
||||
}
|
||||
$maIndex[$minElement]=$maIndex[$i];
|
||||
$maIndex[$i]=$tmpKey;
|
||||
}
|
||||
|
||||
if($desc)
|
||||
for($j=0;$j<=$maSize;$j++)
|
||||
// $ResArray[$maIndex[$j]]=$multArray[$maIndex[$j]];
|
||||
$ResArray[] = $multArray[$maIndex[$j]];
|
||||
else
|
||||
for($j=$maSize;$j>=0;$j--)
|
||||
// $ResArray[$maIndex[$j]]=$multArray[$maIndex[$j]];
|
||||
$ResArray[] = $multArray[$maIndex[$j]];
|
||||
|
||||
return array_reverse($ResArray);
|
||||
}
|
||||
|
||||
public function get_station_fuel_details($uuid){
|
||||
try {
|
||||
$station = $this->station->search_by_uuid($uuid);
|
||||
if($station && $station[0])
|
||||
{
|
||||
// $this->lcard_logs->log($station[0]['sid'],'STATIONLOCATOR','VIEW','Member views station details');
|
||||
$rnrph = new RNRPHLibrary();
|
||||
$rnrph->getStationDetails($station[0]['code']);
|
||||
|
||||
|
||||
$details = $rnrph->response['data'];
|
||||
$db_fuel_prices = $this->station_fuel_prices->getByField([
|
||||
'station_id' => $station[0]['sid'],
|
||||
'is_active' => 1,
|
||||
],
|
||||
null,
|
||||
[
|
||||
'field' => 'updated_at',
|
||||
'value' => 'asc'
|
||||
]);
|
||||
$db = [];
|
||||
$latest_update = date('M d, Y');
|
||||
if(count($db_fuel_prices))
|
||||
{
|
||||
foreach ($db_fuel_prices as $k => $v)
|
||||
{
|
||||
$db[$v['fuel_code']] = $v;
|
||||
$latest_update = date('M d, Y',strtotime($details->StationFuels[0]->updatedAt));
|
||||
}
|
||||
}
|
||||
|
||||
$fuel_type = StaticContents::fuelType_code();
|
||||
$fuel_prices = [];
|
||||
$except_where_in = []; // delete fuel prices that are not returned by stratuscast
|
||||
if(count($details->StationFuels))
|
||||
{
|
||||
foreach ($details->StationFuels as $key => $value) {
|
||||
if(isset($db[$value->Fuel->code]))
|
||||
{
|
||||
if($db[$value->Fuel->code]['price'] != $value->price)
|
||||
$this->station_fuel_prices->update_price($db[$value->Fuel->code]['fuel_price_uuid'],$value->price);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->station_fuel_prices->store($station[0]['sid'],[
|
||||
'fuel_code' => $value->Fuel->code,
|
||||
'fuel_name' => isset($fuel_type[$value->Fuel->code]) ? $fuel_type[$value->Fuel->code] : '',
|
||||
'price' => $value->price,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$fuel_prices[] = [
|
||||
'fuel_code' => $value->Fuel->code,
|
||||
'fuel_name' => isset($fuel_type[$value->Fuel->code]) ? $fuel_type[$value->Fuel->code] : '',
|
||||
'price' => $value->price,
|
||||
];
|
||||
|
||||
$except_where_in[] = $value->Fuel->code;
|
||||
}
|
||||
}
|
||||
|
||||
// delete others
|
||||
$this->station_fuel_prices->delete($station[0]['sid'],$except_where_in);
|
||||
|
||||
return $this->format->mobile_success('Success',[
|
||||
'name' => $station[0]['description'],
|
||||
'address' => $station[0]['address'],
|
||||
'longitude' => $station[0]['longitude'],
|
||||
'latitude' => $station[0]['latitude'],
|
||||
'favorite' => $station[0]['favorite'] > 0 ? true : false,
|
||||
'contact_numbers' => explode("/", $station[0]['contact_number']),
|
||||
'stars' => round($station[0]['average']),
|
||||
'fuel_prices' => $this->sortByField($fuel_prices, "fuel_code"),
|
||||
'latest_update' => $latest_update
|
||||
]);
|
||||
|
||||
}
|
||||
else
|
||||
return $this->format->mobile_error('Station Not Found');
|
||||
} catch (Exception $e) {
|
||||
return $this->format->mobile_error('Something went wrong');
|
||||
}
|
||||
}
|
||||
|
||||
// public function get_station_fuel_details2($uuid){
|
||||
// try {
|
||||
// $station = $this->station->search_by_uuid($uuid);
|
||||
// if($station && $station[0])
|
||||
// {
|
||||
// $this->lcard_logs->log($station[0]['sid'],'STATIONLOCATOR','VIEW','Member views station details');
|
||||
// $rnrph = new RNRPHLibrary();
|
||||
// $rnrph->getStationDetails($station[0]['code']);
|
||||
|
||||
// $details = $rnrph->response['data'];
|
||||
// $db_fuel_prices = $this->station_fuel_prices->getByField([
|
||||
// 'station_id' => $station[0]['sid'],
|
||||
// 'is_active' => 1,
|
||||
// ],
|
||||
// null,
|
||||
// [
|
||||
// 'field' => 'updated_at',
|
||||
// 'value' => 'asc'
|
||||
// ]);
|
||||
// $db = [];
|
||||
// $latest_update = date('M d, Y');
|
||||
// if(count($db_fuel_prices))
|
||||
// {
|
||||
// foreach ($db_fuel_prices as $k => $v)
|
||||
// {
|
||||
// $db[$v['fuel_code']] = $v;
|
||||
// $latest_update = date('M d, Y',strtotime($details->StationFuels[0]->updatedAt));
|
||||
// }
|
||||
// }
|
||||
|
||||
// $fuel_type = StaticContents::fuelType_code();
|
||||
// $fuel_prices = [];
|
||||
// $except_where_in = []; // delete fuel prices that are not returned by stratuscast
|
||||
// if(count($details->StationFuels))
|
||||
// {
|
||||
// foreach ($details->StationFuels as $key => $value) {
|
||||
// if(isset($db[$value->Fuel->code]))
|
||||
// {
|
||||
// if($db[$value->Fuel->code]['price'] != $value->price)
|
||||
// $this->station_fuel_prices->update_price($db[$value->Fuel->code]['fuel_price_uuid'],$value->price);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $this->station_fuel_prices->store($station[0]['sid'],[
|
||||
// 'fuel_code' => $value->Fuel->code,
|
||||
// 'fuel_name' => isset($fuel_type[$value->Fuel->code]) ? $fuel_type[$value->Fuel->code] : '',
|
||||
// 'price' => $value->price,
|
||||
// ]);
|
||||
// }
|
||||
|
||||
|
||||
// $fuel_prices[] = [
|
||||
// 'fuel_code' => $value->Fuel->code,
|
||||
// 'fuel_name' => isset($fuel_type[$value->Fuel->code]) ? $fuel_type[$value->Fuel->code] : '',
|
||||
// 'price' => $value->price,
|
||||
// ];
|
||||
|
||||
// $except_where_in[] = $value->Fuel->code;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // delete others
|
||||
// $this->station_fuel_prices->delete($station[0]['sid'],$except_where_in);
|
||||
|
||||
// return $this->format->mobile_success('Success',[
|
||||
// 'name' => $station[0]['description'],
|
||||
// 'address' => $station[0]['address'],
|
||||
// 'longitude' => $station[0]['longitude'],
|
||||
// 'latitude' => $station[0]['latitude'],
|
||||
// 'favorite' => $station[0]['favorite'] > 0 ? true : false,
|
||||
// 'contact_numbers' => explode("/", $station[0]['contact_number']),
|
||||
// 'stars' => round($station[0]['average']),
|
||||
// 'fuel_prices' => $this->sortByField($fuel_prices, "fuel_code"),
|
||||
// 'latest_update' => $latest_update
|
||||
// ]);
|
||||
|
||||
// }
|
||||
// else
|
||||
// return $this->format->mobile_error('Station Not Found');
|
||||
// } catch (Exception $e) {
|
||||
// return $this->format->mobile_error('Something went wrong');
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
|
@ -1,318 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Contracts\AdminResourceInterface;
|
||||
use App\Helpers\CurrentUserHelper;
|
||||
use App\Http\Requests\SystemPreferenceFormValidation;
|
||||
use App\Http\Resources\SystemPreferencesResource;
|
||||
use App\Libraries\S3;
|
||||
use App\Libraries\StratuscastLibrary;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use App\Contracts\SystemPreferenceResourceInterface;
|
||||
|
||||
use Illuminate\Routing\UrlGenerator;
|
||||
|
||||
class SystemPreferenceController extends Controller
|
||||
{
|
||||
|
||||
public $systemPreference;
|
||||
|
||||
protected $format;
|
||||
|
||||
protected $module;
|
||||
|
||||
protected $model;
|
||||
|
||||
public $admin;
|
||||
|
||||
|
||||
public function __construct(SystemPreferenceResourceInterface $systemPreference,HttpStatusCode $httpStatusCode, UrlGenerator $url, AdminResourceInterface $admin)
|
||||
{
|
||||
|
||||
$this->systemPreference = $systemPreference;
|
||||
$this->format = $httpStatusCode;
|
||||
$this->module = "SystemPreference";
|
||||
$this->model = "SystemPreference";
|
||||
$this->url = $url;
|
||||
$this->admin = $admin;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$rpreference = $this->systemPreference->getAll();
|
||||
$data = [];
|
||||
foreach ($rpreference as $key => $value) {
|
||||
$data[$value['name']] = $value['value'] ;
|
||||
}
|
||||
|
||||
return $this->format->success("SUCCESS",$data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(SystemPreferenceFormValidation $request)
|
||||
{
|
||||
|
||||
$currentUser = CurrentUserHelper::get_currentAdmin();
|
||||
|
||||
$admin = $this->admin->show($currentUser->admin_uuid);
|
||||
|
||||
$value['updated_by'] = $admin->admin_id;
|
||||
|
||||
if ($request['logo'] != null && !empty($request['logo'])){
|
||||
$s3 = new S3;
|
||||
$path = $s3->upload($request->file('logo'),'systemPreferences');
|
||||
$value['name'] = 'logo';
|
||||
$value['value'] = S3::public_path($path);
|
||||
$this->systemPreference->store($request, $value );
|
||||
}
|
||||
|
||||
if ($request->gps != null && !empty($request->gps)){
|
||||
$value['name'] = 'gps';
|
||||
$value['value'] = $request->gps;
|
||||
$this->systemPreference->store($request, $value );
|
||||
|
||||
}
|
||||
|
||||
if ($request->contact_email_address_mobile != null && !empty($request->contact_email_address_mobile)){
|
||||
$value['name'] = 'contact_email_address_mobile';
|
||||
$value['value'] = $request->contact_email_address_mobile;
|
||||
$this->systemPreference->store($request, $value );
|
||||
}
|
||||
|
||||
if ($request->contact_number_mobile != null && !empty($request->contact_number_mobile)){
|
||||
$value['name'] = 'contact_number_mobile';
|
||||
$value['value'] = $request->contact_number_mobile;
|
||||
$this->systemPreference->store($request, $value );
|
||||
}
|
||||
|
||||
if ($request->contact_details != null && !empty($request->contact_details)){
|
||||
$value['name'] = 'contact_details';
|
||||
$value['value'] = $request->contact_details;
|
||||
$this->systemPreference->store($request, $value );
|
||||
|
||||
}
|
||||
|
||||
// if ($request->information_guide_details != null && !empty($request->information_guide_details)){
|
||||
if ($request->has("information_guide_details")){ // allow empty
|
||||
$value['name'] = 'information_guide_details';
|
||||
$value['value'] = $request->information_guide_details;
|
||||
$this->systemPreference->store($request, $value );
|
||||
|
||||
}
|
||||
|
||||
if ($request->has("android_version")){ // allow empty
|
||||
$value['name'] = 'android_version';
|
||||
$value['value'] = $request->android_version;
|
||||
$this->systemPreference->store($request, $value );
|
||||
|
||||
}
|
||||
|
||||
if ($request->has("android_update_message")){ // allow empty
|
||||
$value['name'] = 'android_update_message';
|
||||
$value['value'] = $request->android_update_message;
|
||||
$this->systemPreference->store($request, $value );
|
||||
|
||||
}
|
||||
|
||||
if ($request->has("android_action")){ // allow empty
|
||||
$value['name'] = 'android_action';
|
||||
$value['value'] = $request->android_action;
|
||||
$this->systemPreference->store($request, $value );
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ($request->has("ios_version")){ // allow empty
|
||||
$value['name'] = 'ios_version';
|
||||
$value['value'] = $request->ios_version;
|
||||
$this->systemPreference->store($request, $value );
|
||||
|
||||
}
|
||||
|
||||
if ($request->has("ios_update_message")){ // allow empty
|
||||
$value['name'] = 'ios_update_message';
|
||||
$value['value'] = $request->ios_update_message;
|
||||
$this->systemPreference->store($request, $value );
|
||||
|
||||
}
|
||||
|
||||
if ($request->has("ios_action")){ // allow empty
|
||||
$value['name'] = 'ios_action';
|
||||
$value['value'] = $request->ios_action;
|
||||
$this->systemPreference->store($request, $value );
|
||||
|
||||
}
|
||||
|
||||
return $this->format->success("SUCCESS");
|
||||
|
||||
}
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
$rpreference = $this->systemPreference->getByField('name', $id);
|
||||
|
||||
if (!$rpreference){
|
||||
return $this->format->success("No records found",[]);
|
||||
}
|
||||
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = (new SystemPreferencesResource($rpreference['0']))->additional($additionals);
|
||||
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
|
||||
public function show_mobile($id)
|
||||
{
|
||||
|
||||
$rpreference = $this->systemPreference->getByField('name', $id);
|
||||
|
||||
if (!$rpreference){
|
||||
return $this->format->mobile_success("No records found",[]);
|
||||
}
|
||||
|
||||
|
||||
return $this->format->mobile_success('Success',[
|
||||
'name' => $rpreference[0]->name,
|
||||
'value' => $rpreference[0]->value,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function mobile_system_preference()
|
||||
{
|
||||
$rpreference = $this->systemPreference->getAll();
|
||||
$data = [];
|
||||
foreach ($rpreference as $key => $value) {
|
||||
$data[$value['name']] = $value['value'] ;
|
||||
}
|
||||
|
||||
if (empty($data)){
|
||||
return $this->format->mobile_error('please contact us');
|
||||
}
|
||||
return $this->format->mobile_success('Success',$data);
|
||||
|
||||
}
|
||||
|
||||
public function about_us()
|
||||
{
|
||||
$stratuscast = new StratuscastLibrary();
|
||||
$stratuscast->getAboutUs();
|
||||
|
||||
if(isset($stratuscast->response['data']))
|
||||
{
|
||||
$response = $stratuscast->response['data'];
|
||||
|
||||
$what_we_do_content = explode(' ', $response->what_we_do_content);
|
||||
unset($what_we_do_content[0]);
|
||||
|
||||
$why_unioil_content = explode(' ', $response->why_unioil_content);
|
||||
unset($why_unioil_content[0]);
|
||||
|
||||
if(
|
||||
$this->systemPreference->update('who_we_are_content',$response->who_we_are_content) &&
|
||||
$this->systemPreference->update('what_we_do_content',serialize($what_we_do_content)) &&
|
||||
$this->systemPreference->update('why_unioil_content',serialize($why_unioil_content))
|
||||
)
|
||||
{
|
||||
return $this->format->success('Success');
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->badRequest('Something went wrong');
|
||||
}
|
||||
}
|
||||
else
|
||||
return $this->format->badRequest('Something went wrong');
|
||||
}
|
||||
|
||||
|
||||
public function mobile_version($platform)
|
||||
{
|
||||
$data = [];
|
||||
if($platform != "android" && $platform != "ios"){
|
||||
return $this->format->mobile_error('please contact us');
|
||||
}
|
||||
|
||||
$rpreference = $this->systemPreference->getByField('name', $platform."_version");
|
||||
|
||||
if (!$rpreference){
|
||||
return $this->format->success("No records found",[]);
|
||||
}
|
||||
|
||||
$updateMsg = $this->systemPreference->getByField('name', $platform."_update_message");
|
||||
$updateAct = $this->systemPreference->getByField('name', $platform."_action");
|
||||
|
||||
$data['version'] = $rpreference[0]->value;
|
||||
$data['update_action'] = !$updateAct?"0":$updateAct[0]->value;
|
||||
$data['update_message'] = !$updateMsg?"A new update is available to provide you with a more secure, stable and seamless user experience.":$updateMsg[0]->value;
|
||||
|
||||
return $this->format->mobile_success('Success',$data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,213 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Contracts\AdminActionLogsInterface;
|
||||
use App\Contracts\TermsAndPrivacyResourceInterface;
|
||||
use App\Helpers\CurrentUserHelper;
|
||||
use App\Http\Requests\TermsAndPrivacyFormValidation;
|
||||
use App\Http\Resources\TermsAndPrivacyResource;
|
||||
use App\Libraries\ParameterHelper;
|
||||
use App\TermsAndPrivacy;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
|
||||
class TermsAndPrivacyController extends Controller
|
||||
{
|
||||
|
||||
public $terms_and_privacy;
|
||||
public $admin_logs;
|
||||
|
||||
protected $format;
|
||||
const MODULE = 'TERMSANDPRIVACY';
|
||||
|
||||
public function __construct(TermsAndPrivacyResourceInterface $terms_and_privacy, HttpStatusCode $httpStatusCode, AdminActionLogsInterface $admin_logs)
|
||||
{
|
||||
$this->terms_and_privacy = $terms_and_privacy;
|
||||
$this->admin_logs = $admin_logs;
|
||||
$this->format = $httpStatusCode;
|
||||
$this->module = "TermsAndPrivacy";
|
||||
$this->model = "TermsAndPrivacy";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
//
|
||||
$params = [
|
||||
'search' => ($request->has('_search') ? $request->get('_search') : NULL),
|
||||
'page_size' => ($request->has('page_size') ? $request->get('page_size') : 10),
|
||||
'page' => ($request->has('page') ? $request->get('page') : 10),
|
||||
'sorting' => ParameterHelper::prepareSortingParameter($request)
|
||||
];
|
||||
|
||||
$list = $this->terms_and_privacy->listing($params);
|
||||
|
||||
if(count($list)){
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = TermsAndPrivacyResource::collection($list)->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}else{
|
||||
return $this->format->success("No records found",[]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(TermsAndPrivacyFormValidation $request)
|
||||
{
|
||||
|
||||
if ($request->type != 1 && $request->type != 2){
|
||||
return $this->format->badRequest();
|
||||
}
|
||||
|
||||
$termsorprivacy = $request->type==1 ? "Terms" : "Privacy";
|
||||
|
||||
$id = $this->terms_and_privacy->store($request);
|
||||
|
||||
if($id){
|
||||
$this->admin_logs->log($id,self::MODULE,'STORE');
|
||||
return $this->format->created($termsorprivacy.' has been added');
|
||||
}else{
|
||||
return $this->format->badRequest();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($uuid)
|
||||
{
|
||||
$details = TermsAndPrivacy::where(['tp_uuid' => $uuid,'is_active' => 1])->first();
|
||||
if($details)
|
||||
{
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = (new TermsAndPrivacyResource($details))->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else{
|
||||
return $this->format->notFound('Term And Privacy doesn\'t exists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(TermsAndPrivacyFormValidation $request, $id)
|
||||
{
|
||||
$currentUser = CurrentUserHelper::get_currentAdmin();
|
||||
|
||||
|
||||
if ($id == null && empty($id)) {
|
||||
return $this->format->badRequest();
|
||||
|
||||
}
|
||||
|
||||
$termsAndPrivacy = $this->terms_and_privacy->check($id);
|
||||
|
||||
if(!$termsAndPrivacy){
|
||||
return $this->format->badRequest();
|
||||
}
|
||||
|
||||
$termsAndPrivacy->update_by = $currentUser->admin_id;
|
||||
$termsAndPrivacy->title = $request->title;
|
||||
$termsAndPrivacy->details = $request->details;
|
||||
|
||||
$details = $this->terms_and_privacy->update($termsAndPrivacy);
|
||||
|
||||
if (!$details){
|
||||
return $this->format->badRequest();
|
||||
}
|
||||
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = (new TermsAndPrivacyResource($details))->additional($additionals);
|
||||
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($uuid)
|
||||
{
|
||||
$details = $this->terms_and_privacy->getByField('tp_uuid',$uuid);
|
||||
if(isset($details['0']))
|
||||
{
|
||||
$details = $details['0'];
|
||||
if($this->terms_and_privacy->delete($uuid))
|
||||
{
|
||||
$this->admin_logs->log($details['tp_id'],self::MODULE,'DELETE');
|
||||
$termsorprivacy = $details->type==1 ? "Terms" : "Privacy";
|
||||
return $this->format->success($termsorprivacy." Successfully Deleted");
|
||||
}
|
||||
}
|
||||
|
||||
return $this->format->badRequest();
|
||||
}
|
||||
|
||||
public function batch_delete(Request $request)
|
||||
{
|
||||
$uuid = $request->has('tp_uuid') ? $request->get('tp_uuid') : null;
|
||||
|
||||
if($uuid)
|
||||
{
|
||||
$details = $this->terms_and_privacy->getDetailsWhereIn('tp_uuid',$uuid);
|
||||
|
||||
if($this->terms_and_privacy->delete($uuid))
|
||||
{
|
||||
foreach ($details as $key => $value)
|
||||
{
|
||||
$this->admin_logs->log($value['tp_id'],self::MODULE,'DELETE');
|
||||
}
|
||||
|
||||
return $this->format->success("Terms and Privacy Successfully Deleted");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->badRequest();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['tp_uuid'] = 'tp_uuid is required';
|
||||
return $this->format->unprocessableEntity("Submit at least one item",$data);
|
||||
}
|
||||
}
|
||||
|
||||
public function mobile_terms_privacy()
|
||||
{
|
||||
$details = $this->terms_and_privacy->getAllActive();
|
||||
|
||||
if (empty($details)){
|
||||
return $this->format->mobile_error('please contact us');
|
||||
}
|
||||
|
||||
$details = nl2br($details);
|
||||
|
||||
return $this->format->mobile_success('Sucess',$details);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,237 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Contracts\AdminActionLogsInterface;
|
||||
use App\Contracts\TopUpResourceInterface;
|
||||
//use App\Helpers\CurrentUserHelper;
|
||||
use App\Helpers\CurrentUserHelper;
|
||||
use App\Http\Requests\TopUpFormValidation;
|
||||
use App\TopUp;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Libraries\ParameterHelper;
|
||||
use App\Helpers\HttpStatusCode;
|
||||
use App\Http\Resources\TopUpResource;
|
||||
use DateInterval;
|
||||
|
||||
class TopUpController extends Controller
|
||||
{
|
||||
|
||||
public $top_up;
|
||||
public $admin_logs;
|
||||
|
||||
protected $format;
|
||||
const MODULE = 'TOPUP';
|
||||
|
||||
public function __construct(TopUpResourceInterface $top_up, HttpStatusCode $httpStatusCode, AdminActionLogsInterface $admin_logs)
|
||||
{
|
||||
$this->top_up = $top_up;
|
||||
$this->admin_logs = $admin_logs;
|
||||
$this->format = $httpStatusCode;
|
||||
$this->module = "TopUp";
|
||||
$this->model = "TopUp";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$params = [
|
||||
'search' => ($request->has('_search') ? $request->get('_search') : NULL),
|
||||
'page_size' => ($request->has('page_size') ? $request->get('page_size') : 10),
|
||||
'page' => ($request->has('page') ? $request->get('page') : 10),
|
||||
'sorting' => ParameterHelper::prepareSortingParameter($request)
|
||||
];
|
||||
|
||||
$list = $this->top_up->listing($params);
|
||||
|
||||
if(count($list)){
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = TopUpResource::collection($list)->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}else{
|
||||
return $this->format->success("No records found",[]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
return "create";
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(TopUpFormValidation $request)
|
||||
{
|
||||
$id = $this->top_up->store($request);
|
||||
if($id){
|
||||
$this->admin_logs->log($id,self::MODULE,'STORE');
|
||||
return $this->format->created('TopUp has been added');
|
||||
}else{
|
||||
return $this->format->notFound();
|
||||
}
|
||||
}
|
||||
|
||||
// Count the total number of data in the top_up table
|
||||
public function get_count(){
|
||||
$listCount = TopUp::where('created_at', '>=' ,date('Y-m-d').' 00:00:00')->where('created_at', '<=' ,date('Y-m-d').' 23:59:59')->count();
|
||||
if($listCount <= 5){
|
||||
return $this->format->mobile_success("Success",$listCount,false);
|
||||
}
|
||||
return $this->format->unprocessableEntity("You have reached today's top up limit",$listCount);
|
||||
}
|
||||
|
||||
public function generate_fee_code(Request $request)
|
||||
{
|
||||
$fee_code = "0001";
|
||||
$details = TopUp::orderBy('created_at', 'desc')->first();
|
||||
|
||||
if($details){
|
||||
$fee_code = ltrim($details->fee_code, '0') + 1;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'fee_code' => str_pad($fee_code, 4, '0', STR_PAD_LEFT)
|
||||
];
|
||||
|
||||
if ($data){
|
||||
return $this->format->success("SUCCESS",$data);
|
||||
}else{
|
||||
return $this->format->notFound();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($uuid)
|
||||
{
|
||||
$details = TopUp::where(['topup_uuid' => $uuid,'is_active' => 1])->first();
|
||||
if($details)
|
||||
{
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = (new TopUpResource($details))->additional($additionals);
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
else{
|
||||
return $this->format->notFound('Top Up doesn\'t exists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
return "edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(TopUpFormValidation $request, $id)
|
||||
{
|
||||
$currentUser = CurrentUserHelper::get_currentAdmin();
|
||||
|
||||
if ($id == null && empty($id)) {
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
if(!$this->top_up->check($id)){
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
$request->topup_uuid = $id;
|
||||
$request->update_by = $currentUser->admin_id;
|
||||
$details = $this->top_up->update($request);
|
||||
|
||||
if (!$details){
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
$additionals = $this->format->success("Success",[],false);
|
||||
$data = (new TopUpResource($details))->additional($additionals);
|
||||
|
||||
return $data->response()->setStatusCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($uuid)
|
||||
{
|
||||
$details = $this->top_up->getByField('topup_uuid',$uuid);
|
||||
|
||||
if(isset($details['0']))
|
||||
{
|
||||
$details = $details['0'];
|
||||
if($this->top_up->delete($uuid))
|
||||
{
|
||||
$this->admin_logs->log($details['topup_id'],self::MODULE,'DELETE');
|
||||
return $this->format->success("TopUp Successfully Deleted");
|
||||
}
|
||||
}
|
||||
|
||||
return $this->format->notFound();
|
||||
}
|
||||
|
||||
public function batch_delete(Request $request)
|
||||
{
|
||||
$uuid = $request->has('topup_uuid') ? $request->get('topup_uuid') : null;
|
||||
|
||||
if($uuid)
|
||||
{
|
||||
$details = $this->top_up->getDetailsWhereIn('topup_uuid',$uuid);
|
||||
|
||||
if($this->top_up->delete($uuid))
|
||||
{
|
||||
foreach ($details as $key => $value)
|
||||
{
|
||||
$this->admin_logs->log($value['topup_id'],self::MODULE,'DELETE');
|
||||
}
|
||||
|
||||
return $this->format->success("TopUp Successfully Deleted");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->format->notFound();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['topup_uuid'] = 'topup_uuid is required';
|
||||
return $this->format->unprocessableEntity("Submit at least one item",$data);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => Hash::make($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||
|
||||
class VerificationController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Email Verification Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling email verification for any
|
||||
| user that recently registered with the application. Emails may also
|
||||
| be resent if the user did not receive the original email message.
|
||||
|
|
||||
*/
|
||||
|
||||
use VerifiesEmails;
|
||||
|
||||
/**
|
||||
* Where to redirect users after verification.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('signed')->only('verify');
|
||||
$this->middleware('throttle:6,1')->only('verify', 'resend');
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('home');
|
||||
}
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
\App\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Barryvdh\Cors\HandleCors::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'throttle:60,1',
|
||||
'bindings',
|
||||
\Barryvdh\Cors\HandleCors::class,
|
||||
\App\Http\Middleware\BeforeMiddleware::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The priority-sorted list of middleware.
|
||||
*
|
||||
* This forces the listed middleware to always be in the given order.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middlewarePriority = [
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\Authenticate::class,
|
||||
\Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\Illuminate\Auth\Middleware\Authorize::class,
|
||||
];
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue