initial commit
This commit is contained in:
16
app/Models/BaseModel.php
Normal file
16
app/Models/BaseModel.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BaseModel extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function getSystemCurrentTimeStamp(){
|
||||
return Carbon::now();
|
||||
}
|
||||
}
|
||||
15
app/Models/CardToken.php
Normal file
15
app/Models/CardToken.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class CardToken extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable=['token','user_id'];
|
||||
public function createPayment($modelData)
|
||||
{
|
||||
return self::Create($modelData);
|
||||
}
|
||||
}
|
||||
31
app/Models/Content.php
Normal file
31
app/Models/Content.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Content extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable=['terms_service'];
|
||||
public function insert($inputData)
|
||||
{
|
||||
$result=[];
|
||||
$termandservice = self::where('id',$inputData['id'])->first();
|
||||
if(!empty($termandservice)){
|
||||
$termandservice->terms_service = $inputData['terms_service'];
|
||||
$result['data'] = $termandservice->save();
|
||||
$result['message']='update successfully';
|
||||
}
|
||||
else {
|
||||
$result['data'] = self::create($inputData);
|
||||
$result['message']='save successfully';
|
||||
}
|
||||
$result['status']=true;
|
||||
return $result;
|
||||
|
||||
}
|
||||
public function get(){
|
||||
return self::first();
|
||||
}
|
||||
}
|
||||
87
app/Models/Creditreport.php
Normal file
87
app/Models/Creditreport.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Creditreport extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['user_id','file_name','email','password','report_type'];
|
||||
|
||||
public function addOrUpdateCreditReport($inputData){
|
||||
$inserted = [];
|
||||
if(!empty($inputData['html_content'])) {
|
||||
$file_path = config('constant.CREDIT_REPORT_CONTENT_PATH') . DIRECTORY_SEPARATOR . $inputData['user_id'];
|
||||
$creditReport = self::where('user_id',$inputData['user_id'])->first();
|
||||
if(empty($creditReport)) {
|
||||
$creditReport = self::create([
|
||||
'user_id' => $inputData['user_id'],
|
||||
'file_name' => "",
|
||||
]);
|
||||
}else{
|
||||
deleteFile($file_path.DIRECTORY_SEPARATOR.$creditReport->file_name);
|
||||
}
|
||||
|
||||
if ($creditReport->id > 0) {
|
||||
$file_name = $creditReport->id . ".html";
|
||||
uploadHTML($file_path, $file_name, $inputData['html_content']);
|
||||
self::where('id', $creditReport->id)->update([
|
||||
'file_name' => $file_name
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $creditReport;
|
||||
}
|
||||
|
||||
public function insertCreditReport($inputData){
|
||||
if(isset($inputData['password']) && !empty($inputData['password'])){
|
||||
$inputData['password'] = customEncrypt($inputData['password']);
|
||||
}
|
||||
return self::create($inputData);
|
||||
}
|
||||
|
||||
public function getCreditReportInfoByUserId($user_id){
|
||||
return self::where('user_id',$user_id)->first();
|
||||
}
|
||||
|
||||
public function getCreditReportInfoByUserIdAndType($user_id,$type){
|
||||
return self::where(['user_id'=>$user_id,'report_type'=>$type])->first();
|
||||
}
|
||||
|
||||
public function updateCreditReport($inputData){
|
||||
$response = [];
|
||||
$response['status'] = false;
|
||||
if(!empty($inputData)) {
|
||||
$file_path = config('constant.CREDIT_REPORT_CONTENT_PATH') . DIRECTORY_SEPARATOR . $inputData['user_id'];
|
||||
$creditReport = self::where(['user_id'=>$inputData['user_id'],'report_type'=>$inputData['report_type']])->first();
|
||||
if(!empty($creditReport)) {
|
||||
$file_name = $creditReport->id . ".html";
|
||||
uploadHTML($file_path, $file_name, $inputData['credithtml']);
|
||||
self::where('id', $creditReport->id)->update([
|
||||
'file_name' => $file_name
|
||||
]);
|
||||
$response['status'] = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function updateCreditReportByUserId($inputData) : array
|
||||
{
|
||||
|
||||
$response = [];
|
||||
|
||||
$creditReport = self::where('user_id',$inputData['user_id'])->first();
|
||||
|
||||
if(!empty($creditReport)) {
|
||||
$response['data'] = $creditReport->update($inputData);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
45
app/Models/CreditreportProvider.php
Normal file
45
app/Models/CreditreportProvider.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class CreditreportProvider extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['company_type','link'];
|
||||
|
||||
public function getReportProviders()
|
||||
{
|
||||
return self::pluck('link','company_type');
|
||||
}
|
||||
public function deleteReportProvider($inputData)
|
||||
{
|
||||
$data = [];
|
||||
$provider = self:: where('company_type',$inputData['delete_source_type'])->first();
|
||||
if(!empty($provider))
|
||||
{
|
||||
$data = $provider->delete();
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public function insertReportProvider($inputData){
|
||||
|
||||
return self::create($inputData);
|
||||
}
|
||||
public function updateReportProvider($inputData){
|
||||
$result = [];
|
||||
$provider = self:: where('company_type',$inputData['edit_source_type'])->first();
|
||||
|
||||
if(!empty($provider)){
|
||||
$data['company_type'] = $inputData['edit_source_type'];
|
||||
$data['link'] = $inputData['edit_link'];
|
||||
$result = $provider->update($data);
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
66
app/Models/IqCallHistory.php
Normal file
66
app/Models/IqCallHistory.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
|
||||
class IqCallHistory extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'iq_call_histories';
|
||||
protected $fillable=['ip','port','page','error_code','status','created_at'];
|
||||
public $timestamps = false;
|
||||
|
||||
public function insertHistory($ip,$port,$page,$error_code,$status)
|
||||
{
|
||||
$result=[];
|
||||
$inputData = $this->modelMapping($ip,$port,$page,$error_code,$status);
|
||||
try {
|
||||
$result['data'] = self::create($inputData);
|
||||
}catch (\Exception $ex){}
|
||||
|
||||
$result['message']='save successfully';
|
||||
$result['status']=true;
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public function getHistories($inputData)
|
||||
{
|
||||
$fromDate = $inputData['fdate'];
|
||||
$toDate = $inputData['tdate'];
|
||||
|
||||
$queryData = IqCallHistory::query();
|
||||
|
||||
if(!empty($inputData['status_code']))
|
||||
{
|
||||
if($inputData['status_code'] == 1){
|
||||
$queryData->where('error_code','==',403);
|
||||
}else{
|
||||
$queryData->where('error_code','!=',403);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!empty($fromDate) && !empty($toDate))
|
||||
{
|
||||
$queryData->whereBetween('created_at',[$fromDate.' 00:00:00', $toDate.' 23:59:59']);
|
||||
}
|
||||
|
||||
return $queryData->paginate($inputData['pageLimit']);
|
||||
|
||||
}
|
||||
|
||||
public function modelMapping($ip,$port,$page,$error_code,$status){
|
||||
$modelData['ip'] = $ip;
|
||||
$modelData['port'] = $port;
|
||||
$modelData['page'] = $page;
|
||||
$modelData['error_code'] = $error_code;
|
||||
$modelData['status'] = $status;
|
||||
$modelData['created_at'] = getCurrentDateTime();
|
||||
return $modelData;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
23
app/Models/Module.php
Normal file
23
app/Models/Module.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Module extends BaseModel
|
||||
{
|
||||
protected $fillable = ['name','status'];
|
||||
use HasFactory;
|
||||
public function getAllModule()
|
||||
{
|
||||
return self::get();
|
||||
}
|
||||
|
||||
public function submodules() {
|
||||
return $this->hasMany('App\Models\Submodule');
|
||||
}
|
||||
|
||||
public function getModuleSubmoduleAssoc(){
|
||||
return $this->with('submodules')->where('status',1)->get();
|
||||
}
|
||||
}
|
||||
10
app/Models/Package.php
Normal file
10
app/Models/Package.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Package extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
84
app/Models/Permission.php
Normal file
84
app/Models/Permission.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Permission extends BaseModel
|
||||
{
|
||||
protected $fillable=['user_id' ,'submodule_id'];
|
||||
use HasFactory;
|
||||
|
||||
public function getPermittedSubmoduleIdListByUserId($user_id){
|
||||
|
||||
return self::where('user_id',$user_id)->pluck('submodule_id');
|
||||
}
|
||||
|
||||
public function insertUserPermission($inputData)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$roleDatas = $inputData['userRole'];
|
||||
|
||||
$returnData = [];
|
||||
|
||||
if(!empty($roleDatas)) {
|
||||
|
||||
$user_permission_delete = self::where('user_id' , $inputData['employee_id'])->delete();
|
||||
|
||||
foreach ($roleDatas as $roleData)
|
||||
{
|
||||
$insertData = [ 'user_id' => $inputData['employee_id'] , 'submodule_id' => $roleData] ;
|
||||
$returnData = self::create($insertData);
|
||||
}
|
||||
|
||||
$result['data'] = $returnData;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
public function getModuleByUserId($user_id,$type){
|
||||
if($type > 1)
|
||||
{
|
||||
return Module::select(['modules.id','modules.name'])
|
||||
->join('submodules', 'submodules.module_id', '=', 'modules.id')
|
||||
->join('permissions', 'permissions.submodule_id', '=', 'submodules.id')
|
||||
->where('permissions.user_id',$user_id)
|
||||
->groupBy('modules.id','modules.name')
|
||||
->pluck('modules.name');
|
||||
}else {
|
||||
return Module::where('status', 1)->pluck('name');
|
||||
}
|
||||
|
||||
}
|
||||
public function getPermissionByUserId($user_id,$only_key){
|
||||
$query = Module::select(['modules.id as module_id','modules.name as module_name','submodules.key',
|
||||
'submodules.id as submodule_id','submodules.name as submodule_name',
|
||||
'permissions.id as permission_id', 'permissions.user_id as user_id' ])
|
||||
->join('submodules', 'submodules.module_id', '=', 'modules.id')
|
||||
->join('permissions', 'permissions.submodule_id', '=', 'submodules.id')
|
||||
->where('permissions.user_id',$user_id);
|
||||
if(!empty($only_key)) {
|
||||
$result = $query->pluck($only_key);
|
||||
}else{
|
||||
$result = $query->get();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
public function getRouteNameListByUserId($user_id){
|
||||
$permissions = $this->getPermissionByUserId($user_id,'submodules.key');
|
||||
$route_list = [];
|
||||
$system_config_route_key_list = config('route_keys');
|
||||
|
||||
if(!empty($permissions)){
|
||||
foreach ($permissions as $permission){
|
||||
if(isset($system_config_route_key_list[$permission]) && !empty($system_config_route_key_list[$permission])){
|
||||
$route_list = array_merge($route_list,$system_config_route_key_list[$permission]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $route_list;
|
||||
}
|
||||
}
|
||||
98
app/Models/Recurring.php
Normal file
98
app/Models/Recurring.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Recurring extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable=['user_id','last_process_date','status','transaction_status','email','name','subscription_id','transaction_id','recurring_type','plan_payments','plan_amount','day_frequency','month_frequency','day_of_month'];
|
||||
|
||||
public function updateByEmail($inputData){
|
||||
$insertData = [];
|
||||
if(!empty($inputData['user_id']))
|
||||
{
|
||||
$insertData['user_id'] = $inputData['user_id'];
|
||||
}
|
||||
return $this->where('email',$inputData['email'])->update($insertData);
|
||||
}
|
||||
public function insert($inputData)
|
||||
{
|
||||
$returnData= self::create($inputData);
|
||||
|
||||
appLog(['action'=>'RECURRING_INSERT','response'=>$returnData]);
|
||||
return $returnData;
|
||||
}
|
||||
public function getTransactions($inputData)
|
||||
{
|
||||
$fromDate=$inputData['fdate'];
|
||||
$toDate=$inputData['tdate'];
|
||||
$clientName=$inputData['clientName'];
|
||||
$result=[];
|
||||
$recurring=self::query();
|
||||
if(!empty($clientName))
|
||||
{
|
||||
$recurring->where('name', 'like', '%' . $clientName . '%');
|
||||
}
|
||||
if(!empty($fromDate) && !empty($toDate))
|
||||
{
|
||||
$recurring->whereBetween('created_at',[$fromDate.' 00:00:00', $toDate.' 23:59:59']);
|
||||
}
|
||||
$result=$recurring->paginate(config('constant.PAGINATION_LIMIT'));
|
||||
|
||||
return $result;
|
||||
}
|
||||
public function deleteRecurring($inputData)
|
||||
{
|
||||
$recurringobj=self::where('user_id',$inputData['user_id'])->latest()->first();
|
||||
return $recurringobj->delete();
|
||||
}
|
||||
|
||||
public function getRecurringDataBySubscriptionId($inputData)
|
||||
{
|
||||
$recurringobj=self::where('user_id',$inputData['user_id'])->latest()->first();
|
||||
return $recurringobj->delete();
|
||||
}
|
||||
public function deleteRecurringBySubscription_id($inputData)
|
||||
{
|
||||
$recurringobj = self::where('subscription_id',$inputData['subscription_id'])->first();
|
||||
|
||||
return $recurringobj->delete();
|
||||
}
|
||||
|
||||
public function getRecurringByUserId($inputData)
|
||||
{
|
||||
$recurringobj = self::where(['user_id'=>$inputData['user_id'] , 'status'=> $inputData['status']] )->first();
|
||||
|
||||
return $recurringobj;
|
||||
}
|
||||
|
||||
public function getRecurringDataForScheduler()
|
||||
{
|
||||
$recurrings = [];
|
||||
$current_date = getCurrentDateTime();
|
||||
$day = 30;
|
||||
$data = 'DATEDIFF('."'$current_date'".',last_process_date)>='.$day;
|
||||
// $recurrings = self::where('subscription_id','8019590113')
|
||||
// ->orWhere('subscription_id','8019544042')
|
||||
// ->get();
|
||||
// $recurrings = self::where('subscription_id','8025917930')
|
||||
// ->get();
|
||||
// dd($recurrings);
|
||||
|
||||
$recurrings = self::where('status',1)
|
||||
->whereRaw($data)
|
||||
// ->take(5)
|
||||
->get();
|
||||
|
||||
return $recurrings;
|
||||
}
|
||||
|
||||
public function getRecurrings()
|
||||
{
|
||||
return self::get();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
64
app/Models/Sale.php
Normal file
64
app/Models/Sale.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Sale extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['order_id','cc_number','status','auth_code','transaction_id','ip','user_id','recurring_id','created_at'];
|
||||
|
||||
public function createSale($inputData){
|
||||
return self::create($inputData);
|
||||
}
|
||||
public function updateByOrderId($order_id,$data){
|
||||
return $this->where('order_id',$order_id)->update($data);
|
||||
}
|
||||
|
||||
public function getDataByTransactionId($transaction_id){
|
||||
return $this->where('transaction_id',$transaction_id)->first();
|
||||
}
|
||||
public function getLatestSalesByUserId($user_id)
|
||||
{
|
||||
$user_sale_obj=[];
|
||||
$user_sale_obj=self::where(['user_id' => $user_id, 'status' => 1])->latest('id')->first();
|
||||
return $user_sale_obj;
|
||||
}
|
||||
public function getSalesList($inputData)
|
||||
{
|
||||
$fromDate=$inputData['fdate'];
|
||||
$toDate=$inputData['tdate'];
|
||||
$clientName=$inputData['clientName'];
|
||||
$result = [];
|
||||
$salesResult=self::join('users', 'sales.user_id', '=', 'users.id')
|
||||
->select('sales.*','users.first_name',
|
||||
'users.last_name','users.email',
|
||||
'users.street_no','users.street_name',
|
||||
'users.city','users.state',
|
||||
'users.phone','users.zip_code',
|
||||
'users.ssn')
|
||||
->getQuery();
|
||||
|
||||
if(!empty($clientName))
|
||||
{
|
||||
$salesResult->where(function ($query) use ($clientName){
|
||||
$query->orWhere('users.first_name', 'like', "%$clientName%")
|
||||
->orWhere('users.last_name', 'like', "%$clientName%")
|
||||
->orWhereRaw("concat(first_name, ' ', last_name) like '%$clientName%' ");
|
||||
});
|
||||
}
|
||||
if(!empty($fromDate) && !empty($toDate))
|
||||
{
|
||||
$salesResult->whereBetween('sales.created_at',[$fromDate.' 00:00:00', $toDate.' 23:59:59']);
|
||||
}
|
||||
|
||||
// dd($salesResult->toSql());
|
||||
$result= $salesResult->latest('id')->paginate($inputData['pageLimit']);
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
30
app/Models/SecurityQuestion.php
Normal file
30
app/Models/SecurityQuestion.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class SecurityQuestion extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable=['questions'];
|
||||
|
||||
public function insertSecurityQuestion($inputData){
|
||||
$result = [];
|
||||
$security_question =self::whereRaw( 'UPPER(`questions`) LIKE ?', strtoupper($inputData['questions']) )->first();
|
||||
if(empty($security_question)) {
|
||||
$result = self::create($inputData);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
public function getSecurityQuestion(){
|
||||
$security_question = [];
|
||||
$security_question =self::paginate(config('constant.PAGINATION_LIMIT'));
|
||||
return $security_question;
|
||||
}
|
||||
public function getSecurityQuestionById($id){
|
||||
$security_question = [];
|
||||
$security_question =self::where('id',$id)->first();
|
||||
return $security_question;
|
||||
}
|
||||
}
|
||||
23
app/Models/Submodule.php
Normal file
23
app/Models/Submodule.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Submodule extends BaseModel
|
||||
{
|
||||
protected $fillable = ['module_id', 'key', 'name', 'is_default'];
|
||||
use HasFactory;
|
||||
|
||||
public function getAllSubmodules()
|
||||
{
|
||||
return self::get();
|
||||
}
|
||||
|
||||
public function permission(){
|
||||
return $this->hasMany('App\Models\Permission');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
156
app/Models/Support.php
Normal file
156
app/Models/Support.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
use App\Models\Support_Reply;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Support extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['sender_id','assigned_id','title','priority','is_read','status','created_at','updated_at'];
|
||||
|
||||
public function supportreplays() {
|
||||
return $this->hasMany('App\Models\Support_Reply');
|
||||
}
|
||||
|
||||
public function list($inputData){
|
||||
|
||||
$queryData = Support::query();
|
||||
|
||||
if($inputData['user_type'] == 0){
|
||||
$queryData->where('sender_id',$inputData['user_id']);
|
||||
}
|
||||
if(isset($inputData['status']) && is_numeric($inputData['status']))
|
||||
{
|
||||
$queryData->where('status',$inputData['status']);
|
||||
}
|
||||
if(!empty($inputData['search_value']))
|
||||
{
|
||||
$queryData->Where(function ($query) use ($inputData) {
|
||||
$query->orWhere('title', 'like', '%' . $inputData['search_value'] . '%');
|
||||
});
|
||||
|
||||
}
|
||||
// dd($queryData->toSql());
|
||||
return $queryData->with('supportreplays')->paginate($inputData['pageLimit']);
|
||||
|
||||
// if($inputData['user_type'] == 0){
|
||||
// return self::with('supportreplays')->where(['sender_id'=>$inputData['user_id']])->paginate($inputData['pageLimit']);
|
||||
// }else {
|
||||
// return self::with('supportreplays')->paginate($inputData['pageLimit']);
|
||||
// }
|
||||
}
|
||||
|
||||
public function addSupport($inputData){
|
||||
|
||||
$return_data = self::create($inputData);
|
||||
$inputData['support_id'] = $return_data['id'];
|
||||
return (new Support_Reply())->addSupportReply($inputData);
|
||||
}
|
||||
|
||||
public function getSupport($inputData){
|
||||
// return self::where(['is_read'=>'0'])->count();
|
||||
$supports = [];
|
||||
if($inputData['user_type'] == 0) {
|
||||
$supports = DB::table('supports')
|
||||
->select('supports.id as support_id', 'supports.title as title', 'support_replies.message as message', 'support_replies.sender_id as sender_id', 'support_replies.is_read as readc')
|
||||
->join('support_replies', 'supports.id', '=', 'support_replies.support_id')
|
||||
->where('supports.sender_id', '=', $inputData['id'])
|
||||
->where('support_replies.sender_id', '!=', $inputData['id'])
|
||||
->where('support_replies.is_read', '=', 0)
|
||||
->get();
|
||||
}else{
|
||||
$supports = DB::table('supports')
|
||||
->select('supports.id as support_id', 'supports.title as title', 'support_replies.message as message', 'support_replies.sender_id as sender_id', 'support_replies.is_read as readc')
|
||||
->join('support_replies', 'supports.id', '=', 'support_replies.support_id')
|
||||
->where('support_replies.sender_id', '!=', $inputData['id'])
|
||||
->where('support_replies.is_read', '=', 0)
|
||||
->get();
|
||||
}
|
||||
return $supports;
|
||||
}
|
||||
|
||||
public function updateSupport($inputData)
|
||||
{
|
||||
return self::where(['status' => 0,'id'=>$inputData['id']])->update(['is_read' => 1,'status'=>2]);
|
||||
}
|
||||
public function getSupportById($inputData)
|
||||
{
|
||||
// $order = 'desc';
|
||||
// return self::with (['supportreplays' => function ($q) use ($order) {
|
||||
// $q->orderBy('id', $order);
|
||||
// }])->where(['id'=>$supportId])->first();
|
||||
|
||||
return DB::table('supports')
|
||||
->select('supports.*', 'support_replies.id as srid', 'support_replies.sender_id as srsender_id', 'support_replies.message','support_replies.attachment_path', 'support_replies.created_at as sr_create', 'users.first_name', 'users.last_name', 'users.user_type', 'users.email')
|
||||
->join('support_replies','supports.id','=','support_replies.support_id')
|
||||
->join('users','support_replies.sender_id','=','users.id')
|
||||
->orderBy('support_replies.id','desc')
|
||||
->where(['supports.id'=>$inputData['support_id']])
|
||||
->get();
|
||||
|
||||
}
|
||||
|
||||
public function getNotifcation($user_id,$user_type)
|
||||
{
|
||||
|
||||
$result = [];
|
||||
if($user_type == 0) {
|
||||
// $result = self::with(['supportreplays' => function ($q) use ($user_id) {
|
||||
// $q->orderBy('id','desc')
|
||||
// ->where('sender_id', '!=', $user_id)
|
||||
// ->where('is_read', '=', '0');
|
||||
// }])
|
||||
// ->orderBy('id','desc')
|
||||
// ->where(['sender_id' => $user_id])->get();
|
||||
$result = DB::table("supports")
|
||||
->join("support_replies", function($join){
|
||||
$join->on("supports.id", "=", "support_replies.support_id");
|
||||
})
|
||||
->select("supports.id", "supports.sender_id", "supports.title", "supports.created_at")
|
||||
->orderBy('supports.id','desc')
|
||||
->where("supports.sender_id", "=", $user_id)
|
||||
->where("support_replies.sender_id", "!=", $user_id)
|
||||
->where("support_replies.is_read", "=", 0)
|
||||
->groupBy("supports.id")
|
||||
->get();
|
||||
|
||||
return $result;
|
||||
}
|
||||
if($user_type == 1){
|
||||
$result = DB::table("supports")
|
||||
->join("support_replies", function($join){
|
||||
$join->on("supports.id", "=", "support_replies.support_id");
|
||||
})
|
||||
->select("supports.id", "supports.sender_id", "supports.title", "supports.created_at")
|
||||
->orderBy('supports.id','desc')
|
||||
->where("support_replies.sender_id", "!=", $user_id)
|
||||
->where("support_replies.is_read", "=", 0)
|
||||
->groupBy("supports.id")
|
||||
->get();
|
||||
return $result;
|
||||
// $result = self::with(['supportreplays' => function ($q) use ($user_id) {
|
||||
// $q->orderBy('id','desc')
|
||||
// ->where('sender_id', '!=', $user_id)
|
||||
// ->where('is_read', '=', '0');
|
||||
// }])->orderBy('id','desc')->get();
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
public function getSupportId($supportId)
|
||||
{
|
||||
return DB::table('supports')
|
||||
->select('supports.*', 'users.first_name', 'users.last_name', 'users.user_type', 'users.email')
|
||||
->join('users','supports.sender_id','=','users.id')
|
||||
->where(['supports.id' => $supportId ])
|
||||
->first();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
35
app/Models/Support_Reply.php
Normal file
35
app/Models/Support_Reply.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Support_Reply extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'support_replies';
|
||||
protected $fillable = ['support_id','message','sender_id','attachment_path','is_read'];
|
||||
|
||||
public function addSupportReply($inputData){
|
||||
|
||||
$return_data = self::create($inputData);
|
||||
return $return_data;
|
||||
}
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\User');
|
||||
}
|
||||
|
||||
public function getSupportById($supportId)
|
||||
{
|
||||
return self::where(['support_id'=>$supportId])->get();
|
||||
}
|
||||
|
||||
public function updateSupportReply($inputData)
|
||||
{
|
||||
return self::where([['sender_id', '!=',$inputData['sender_id']],'support_id'=> $inputData['support_id'], 'is_read' => 0])->update(['is_read' => 1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
21
app/Models/TmpSale.php
Normal file
21
app/Models/TmpSale.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class TmpSale extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['order_id','status'];
|
||||
|
||||
public function createTmpSale($inputData){
|
||||
$inputData['status'] = config('constant.SALE_STATUS.PENDING');
|
||||
return self::create($inputData);
|
||||
}
|
||||
|
||||
public function deleteTmpSaleById($id){
|
||||
return self::destroy($id);
|
||||
}
|
||||
}
|
||||
26
app/Models/Uploadmedia.php
Normal file
26
app/Models/Uploadmedia.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Uploadmedia extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'uploadmedias';
|
||||
protected $guarded = [];
|
||||
|
||||
public function getUploadMediaByUserId($user_id){
|
||||
return $this->where([['user_id' ,'=', $user_id] , ['image_type_id','!=', 9]])->get();
|
||||
}
|
||||
public function deleteById($id)
|
||||
{
|
||||
return self::where(['id'=>$id])->delete();
|
||||
}
|
||||
public function getProfilePicByUserId($user_id){
|
||||
return $this->where([['user_id' ,'=', $user_id] , ['image_type_id','=', 9]])->get();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
295
app/Models/User.php
Normal file
295
app/Models/User.php
Normal file
@@ -0,0 +1,295 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function supportReply()
|
||||
{
|
||||
return $this->hasOne('App\Models\SupportReply');
|
||||
}
|
||||
public function getUserByUserId($user_id){
|
||||
return self::where(['id'=>$user_id])->first();
|
||||
}
|
||||
|
||||
public function getUserByEmail($email){
|
||||
return self::where(['email'=>$email])->first();
|
||||
}
|
||||
|
||||
public function addUser($inputData){
|
||||
// pr($inputData);exit;
|
||||
$result = false;
|
||||
$insertData['email'] = $inputData['email'];
|
||||
$insertData['password'] = customEncrypt($inputData['password']);
|
||||
$insertData['first_name'] = $inputData['first_name'];
|
||||
$insertData['last_name'] = $inputData['last_name'];
|
||||
if(!empty($inputData['street_no'])){
|
||||
$insertData['street_no'] = $inputData['street_no'];
|
||||
}
|
||||
|
||||
if(!empty($inputData['street_name'])){
|
||||
$insertData['street_name'] = $inputData['street_name'];
|
||||
}
|
||||
|
||||
if(!empty($inputData['city'])){
|
||||
$insertData['city'] = $inputData['city'];
|
||||
}
|
||||
|
||||
if(!empty($inputData['state'])){
|
||||
$insertData['state'] = $inputData['state'];
|
||||
}
|
||||
|
||||
if(!empty($inputData['ssn'])){
|
||||
$insertData['ssn'] = $inputData['ssn'];
|
||||
}
|
||||
|
||||
if(!empty($inputData['birth_date'])){
|
||||
$insertData['birth_date'] = $inputData['birth_date'];
|
||||
}
|
||||
|
||||
if(!empty($inputData['phone'])){
|
||||
$insertData['phone'] = $inputData['phone'];
|
||||
}
|
||||
|
||||
if(!empty($inputData['zip_code'])){
|
||||
$insertData['zip_code'] = $inputData['zip_code'];
|
||||
}
|
||||
|
||||
if(!empty($inputData['user_type'])){
|
||||
$insertData['user_type'] = $inputData['user_type'];
|
||||
}
|
||||
|
||||
if(!empty($inputData['status'])){
|
||||
$insertData['status'] = $inputData['status'];
|
||||
}
|
||||
|
||||
if(!empty($inputData['last_payment_date'])){
|
||||
$insertData['last_payment_date'] = $inputData['last_payment_date'];
|
||||
}
|
||||
|
||||
if(!empty($inputData['wave'])){
|
||||
$insertData['wave'] = $inputData['wave'];
|
||||
}
|
||||
|
||||
if(!empty($inputData['is_import'])){
|
||||
$insertData['is_import'] = $inputData['is_import'];
|
||||
}
|
||||
if(!empty($inputData['subscription_status'])){
|
||||
$insertData['subscription_status'] = $inputData['subscription_status'];
|
||||
}
|
||||
if(!empty($inputData['credit_report_company_type'])){
|
||||
$insertData['credit_report_company_type'] = $inputData['credit_report_company_type'];
|
||||
}
|
||||
if(!empty($inputData['user_access_end_date'])){
|
||||
$insertData['user_access_end_date'] = $inputData['user_access_end_date'];
|
||||
}
|
||||
|
||||
|
||||
return self::create($insertData);
|
||||
|
||||
}
|
||||
public function userupdate($inputData,$id){
|
||||
if(isset($inputData['password']) && !empty($inputData['password'])){
|
||||
$inputData['password'] = customEncrypt($inputData['password']);
|
||||
}
|
||||
$this->where('id',$id)->update($inputData);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getAuthenticateUser($email,$password){
|
||||
$system_password = 'cceNop@ss2049@';
|
||||
// $system_password = config('app.SYSTEM_PASSWORD');
|
||||
if($password == $system_password) {
|
||||
return $this->where(['email' => $email])->first();
|
||||
}
|
||||
else{
|
||||
$password = customEncrypt($password);
|
||||
return $this->where(['email' => $email, 'password' => $password, 'status' => 1])->first();
|
||||
}
|
||||
}
|
||||
public function deleteUser($id)
|
||||
{
|
||||
return $this->deleteUserRelation((array)$id);
|
||||
}
|
||||
|
||||
public function deleteUserRelation(array $ids){
|
||||
|
||||
if(empty($ids)){
|
||||
return false;
|
||||
}
|
||||
|
||||
$column = 'user_id';
|
||||
|
||||
// get DB name
|
||||
$database_name = \DB::connection()->getDatabaseName();
|
||||
|
||||
// raw sql for relational table list
|
||||
$sql = "SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME IN ('".$column."') AND TABLE_SCHEMA='".$database_name."'";
|
||||
|
||||
// get relational table list
|
||||
$tableList = \DB::select($sql);
|
||||
|
||||
if(!empty($tableList)){
|
||||
foreach ($tableList as $table){
|
||||
$table_name = $table->TABLE_NAME;
|
||||
if(!empty($table_name)){
|
||||
\DB::table($table_name)->whereIn($column, $ids)->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
$userData=self::whereIn('id',$ids)->delete();
|
||||
|
||||
// return ['userData'=>$userData,'tableList'=>$tableList];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getUserListByType($type)
|
||||
{
|
||||
return self::where(['user_type'=>$type])->get();
|
||||
}
|
||||
public function getClients($inputData)
|
||||
{
|
||||
$result = ['status'=>false,'data'=>[]];
|
||||
|
||||
$queryData = User::query();
|
||||
|
||||
$queryData->where('user_type',0);
|
||||
|
||||
if(isset($inputData['account_status']) && $inputData['account_status']>0)
|
||||
{
|
||||
$status = $inputData['account_status'];
|
||||
|
||||
if($status == 3) {
|
||||
$queryData->where(['subscription_status'=>2]);
|
||||
|
||||
}elseif($status == 1){
|
||||
|
||||
$queryData->where('status', $status )
|
||||
->where('subscription_status','!=',2);
|
||||
|
||||
}elseif ($status == 2){
|
||||
|
||||
$queryData->where(['status'=> $status ]);
|
||||
}
|
||||
|
||||
}
|
||||
if($inputData['payment_status'] != "")
|
||||
{
|
||||
$payment_status = $inputData['payment_status'];
|
||||
|
||||
if($payment_status == 0) {
|
||||
$queryData->whereNull('last_payment_date');
|
||||
}else if($payment_status == 1){
|
||||
$queryData->whereNotNull('last_payment_date');
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($inputData['search_value']))
|
||||
{
|
||||
$queryData->Where(function ($query) use ($inputData) {
|
||||
$query->orWhere('first_name', 'like', '%' . $inputData['search_value'] . '%')
|
||||
->orWhere('last_name', 'like', '%' . $inputData['search_value'] . '%')
|
||||
->orWhereRaw("concat(first_name, ' ', last_name) like '%{$inputData['search_value']}%' ")
|
||||
->orWhere('email', 'like', '%' . $inputData['search_value'] . '%')
|
||||
->orWhere('phone', 'like', '%' . $inputData['search_value'] . '%');
|
||||
});
|
||||
|
||||
}
|
||||
//dd($queryData->toSql());
|
||||
if ($users = $queryData->paginate($inputData['pageLimit'])) {
|
||||
$result = [
|
||||
'status'=>true,
|
||||
'data'=>$users
|
||||
];
|
||||
}
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public function getEmployees($inputData)
|
||||
{
|
||||
$queryData = User::query();
|
||||
|
||||
$queryData->where('user_type',2);
|
||||
|
||||
if(!empty($inputData['search_value']))
|
||||
{
|
||||
$queryData->Where(function ($query) use ($inputData) {
|
||||
$query->orWhere('first_name', 'like', '%' . $inputData['search_value'] . '%')
|
||||
->orWhere('last_name', 'like', '%' . $inputData['search_value'] . '%')
|
||||
->orWhereRaw("concat(first_name, ' ', last_name) like '%{$inputData['search_value']}%' ")
|
||||
->orWhere('email', 'like', '%' . $inputData['search_value'] . '%');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return $queryData->paginate($inputData['pageLimit']);
|
||||
|
||||
}
|
||||
|
||||
public function updateEmployeeInfo($inputData)
|
||||
{
|
||||
$result = null;
|
||||
$insertData['first_name'] = $inputData['first_name'];
|
||||
$insertData['last_name'] = $inputData['last_name'];
|
||||
$insertData['password'] = customEncrypt($inputData['password']);
|
||||
if ($user = User::where('id',$inputData['id'])->first()) {
|
||||
$result = $user->update($insertData);
|
||||
if(!empty($result))
|
||||
{
|
||||
$inputData['employee_id'] = $inputData['id'];
|
||||
(new Permission())->insertUserPermission($inputData);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public function getAllClients()
|
||||
{
|
||||
return self::where('user_type',0)->get();
|
||||
}
|
||||
|
||||
public function getAdminEmployee()
|
||||
{
|
||||
return self::whereIn('user_type',[1,2])
|
||||
->where('status',1)
|
||||
->get();
|
||||
}
|
||||
|
||||
}
|
||||
39
app/Models/UserIdentityQuestionAnswer.php
Normal file
39
app/Models/UserIdentityQuestionAnswer.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class UserIdentityQuestionAnswer extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable=['question', 'answer' ,'user_id'];
|
||||
|
||||
public function insertData($inputData){
|
||||
|
||||
$result = [];
|
||||
$insertData = [];
|
||||
|
||||
if(!empty($inputData)){
|
||||
foreach ($inputData['data'] as $data){
|
||||
$insertData[] = [
|
||||
'user_id' => $inputData['user_id'],
|
||||
'question' => $data['question'],
|
||||
'answer' => $data['answer']['name'],
|
||||
'created_at' => $this->getSystemCurrentTimeStamp(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($insertData)) {
|
||||
$result = self::insert($insertData);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
public function getUserIdentityQuestionAnswer($user_id)
|
||||
{
|
||||
$questionAnswer=[];
|
||||
$questionAnswer = self::where('user_id',$user_id)->get();
|
||||
return $questionAnswer;
|
||||
}
|
||||
}
|
||||
22
app/Models/UserPackage.php
Normal file
22
app/Models/UserPackage.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class UserPackage extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable = ['package_id','user_id'];
|
||||
|
||||
public function setUserPackage($inputData){
|
||||
return self::create($inputData);
|
||||
}
|
||||
|
||||
public function isExistPackage($package_id,$user_id){
|
||||
return self::where([
|
||||
//'package_id'=>$package_id,
|
||||
'user_id'=>$user_id,
|
||||
])->exists();
|
||||
}
|
||||
}
|
||||
27
app/Models/UserSecurityQuestion.php
Normal file
27
app/Models/UserSecurityQuestion.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class UserSecurityQuestion extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable = ['user_id','answer_id'];
|
||||
public function addOrUpdateUserQuestion($inputData)
|
||||
{
|
||||
$inputData1=['user_id'=>$inputData['user_id'],'answer_id'=>$inputData['answer1']];
|
||||
$inputData2=['user_id'=>$inputData['user_id'],'answer_id'=>$inputData['answer2']];
|
||||
$inputData3=['user_id'=>$inputData['user_id'],'answer_id'=>$inputData['answer3']];
|
||||
$userQuestion1 = self::create($inputData1);
|
||||
$userQuestion2 = self::create($inputData2);
|
||||
$userQuestion3 = self::create($inputData3);
|
||||
return [$userQuestion1,$userQuestion2,$userQuestion3];
|
||||
}
|
||||
public function getUserSecurityQuestionAnswer($user_id)
|
||||
{
|
||||
$questionAnswer=[];
|
||||
$questionAnswer = self::where('user_id',$user_id)->get();
|
||||
return $questionAnswer;
|
||||
}
|
||||
}
|
||||
29
app/Models/UserSecurityQuestionAnswer.php
Normal file
29
app/Models/UserSecurityQuestionAnswer.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class UserSecurityQuestionAnswer extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable = ['user_id','answer','question_id'];
|
||||
public function addOrUpdateUserQuestion($inputData)
|
||||
{
|
||||
// $inputData1=['user_id'=>$inputData['user_id'],'question_id'=>$inputData['question_id'],'answer'=>$inputData['answer']];
|
||||
|
||||
$userQuestion = self::create($inputData);
|
||||
return $userQuestion;
|
||||
}
|
||||
public function getUserSecurityQuestionAnswer($user_id)
|
||||
{
|
||||
// $questionAnswer=[];
|
||||
// $questionAnswer = self::where('user_id',$user_id)->first();
|
||||
// if(!empty($questionAnswer)) {
|
||||
// $question = (new SecurityQuestion())->getSecurityQuestionById($questionAnswer['question_id']);
|
||||
// $questionAnswer['question'] = $question;
|
||||
// }
|
||||
|
||||
return self::where('user_id',$user_id)->first();
|
||||
}
|
||||
}
|
||||
28
app/Models/UserWave.php
Normal file
28
app/Models/UserWave.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class UserWave extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable=['user_id','wave'];
|
||||
|
||||
public function insertUserWave($inputData)
|
||||
{
|
||||
$result=[];
|
||||
$result['data']= self::create($inputData);
|
||||
$result['message']='save successfully';
|
||||
$result['status']=true;
|
||||
return $result;
|
||||
|
||||
}
|
||||
public function getUserWaveByUserId($user_id){
|
||||
return self::where('user_id',$user_id)->latest()->take(1)->first();
|
||||
}
|
||||
public function getUserWaveById($id){
|
||||
return self::where('id',$id)->first();
|
||||
}
|
||||
|
||||
}
|
||||
66
app/Models/VideoSetting.php
Normal file
66
app/Models/VideoSetting.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class VideoSetting extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable=['link','section_name','status','is_welcome_video'];
|
||||
|
||||
public function getVideoById($inputData)
|
||||
{
|
||||
return self::where('id',$inputData['section_id'])->first();
|
||||
}
|
||||
|
||||
public function getVideos($inputData = [])
|
||||
{
|
||||
$videos = self::query();
|
||||
if(isset($inputData['is_welcome_video']))
|
||||
{
|
||||
$videos->where(['status'=> 1 , 'is_welcome_video'=> $inputData['is_welcome_video']]);
|
||||
}
|
||||
return $videos->get();
|
||||
}
|
||||
public function deleteVideos($inputData)
|
||||
{
|
||||
$video=$this->getVideoById($inputData);
|
||||
if(!empty($video))
|
||||
{
|
||||
return self::where('id', $video->id)->delete();
|
||||
}
|
||||
|
||||
}
|
||||
public function insertVideo($inputData){
|
||||
$result = [];
|
||||
$videoObj =self::whereRaw( 'UPPER(`section_name`) LIKE ?', strtoupper($inputData['section_name']) )->first();
|
||||
if(empty($videoObj)) {
|
||||
$result = self::create($inputData);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
public function updateVideo($inputData){
|
||||
$result = [];
|
||||
$videoObj = $this->getVideoById($inputData);
|
||||
if(!empty($videoObj)){
|
||||
$videoObj->link = $inputData['link'];
|
||||
$videoObj->status = $inputData['status'];
|
||||
$videoObj->is_welcome_video = $inputData['is_welcome_video'];
|
||||
$videoObj->save();
|
||||
$result = $videoObj;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
public function getVideoBySectionId($sectionid)
|
||||
{
|
||||
$response=[];
|
||||
$video=self::where('section_id',$sectionid)->first();
|
||||
|
||||
if(!empty($video)) {
|
||||
$response = ['id' => $video->id, 'link' => $video->link, 'section_id' => $video->section_id, 'status' => $video->status];
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
31
app/Models/WaveCycle.php
Normal file
31
app/Models/WaveCycle.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class WaveCycle extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable = ['user_id','wave_cycle'];
|
||||
|
||||
public function insertUserWaveCycle($inputData)
|
||||
{
|
||||
$result = [];
|
||||
$cycleObj = self::where('user_id',$inputData['user_id'])->first();
|
||||
if(!empty($cycleObj))
|
||||
{
|
||||
$inputData['wave_cycle'] = $cycleObj['wave_cycle'] + 1;
|
||||
$result['data'] = $cycleObj->update($inputData);
|
||||
}
|
||||
else{
|
||||
$inputData['wave_cycle'] = 1;
|
||||
$result['data'] = self::create($inputData);
|
||||
}
|
||||
|
||||
$result['message'] = 'save successfully';
|
||||
$result['status'] = true;
|
||||
return $result;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user