⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.142
Server IP:
217.76.53.76
Server:
Linux vmi1397931.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64
Server Software:
Apache
PHP Version:
8.2.27
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
www
/
wwwroot
/
onlinestore.ng
/
app
/
Models
/
View File Name :
User.php
'datetime', ]; public function creatorId() { if($this->type == 'Owner' || $this->type == 'super admin') { return $this->id; } else { return $this->created_by; } } public function currentLanguages() { return $this->lang; } public function countCompany() { return User::where('type', '=', 'Owner')->where('created_by', '=', $this->creatorId())->count(); } public function countPaidCompany() { return User::where('type', '=', 'Owner')->whereNotIn( 'plan', [ 0, 1, ] )->where('created_by', '=', \Auth::user()->id)->count(); } public function assignPlan($planID) { $plan = Plan::find($planID); if($plan) { $this->plan = $plan->id; if($this->trial_expire_date != null); { $this->trial_expire_date = null; } if($plan->duration == 'Month') { $this->plan_expire_date = Carbon::now()->addMonths(1)->isoFormat('YYYY-MM-DD'); } elseif($plan->duration == 'Year') { $this->plan_expire_date = Carbon::now()->addYears(1)->isoFormat('YYYY-MM-DD'); } else if($plan->duration == 'Lifetime') { $this->plan_expire_date = null; } // else // { // $this->plan_expire_date=null; // } $this->save(); $users = User::where('created_by', '=', \Auth::user()->creatorId())->where('type', '!=', 'super admin')->get(); $products = Product::where('created_by', '=', \Auth::user()->creatorId())->get(); $stores = Store::where('created_by', '=', \Auth::user()->creatorId())->get(); if($plan->max_stores == -1) { foreach($stores as $store) { $store->is_active = 1; $store->save(); } } else { $storeCount = 0; foreach($stores as $store) { $storeCount++; if($storeCount <= $plan->max_stores) { $store->is_active = 1; $store->save(); } else { $store->is_active = 0; $store->save(); } } } if($plan->max_products == -1) { foreach($products as $product) { $product->is_active = 1; $product->save(); } } else { $productCount = 0; foreach($products as $product) { $productCount++; if($productCount <= $plan->max_products) { $product->is_active = 1; $product->save(); } else { $product->is_active = 0; $product->save(); } } } return ['is_success' => true]; } else { return [ 'is_success' => false, 'error' => 'Plan is deleted.', ]; } } public function countProducts() { return Product::where('created_by', '=', $this->creatorId())->count(); } public function countStores($id) { return Store::where('created_by', $id)->count(); } public function countStore() { return Store::where('created_by', '=', $this->creatorId())->count(); } public function currentuser(){ if(is_null(self::$currentUser)){ $user = User::find($this->creatorId()); self::$currentUser = $user; } return self::$currentUser; } public function countUsers() { return User::where('created_by', '=', $this->creatorId())->count(); } public function currentPlan() { return $this->hasOne('App\Models\Plan', 'id', 'plan'); } public function stores() { return $this->belongsToMany('App\Models\Store', 'user_stores', 'user_id', 'store_id')->withPivot('permission'); } public function activeStore(){ return $this->hasOne('App\Models\Store','id','current_store'); } public function dateFormat($date) { $settings = Utility::settings(); return date($settings['site_date_format'], strtotime($date)); } public static function priceFormat($price) { $settings = Utility::settings(); return (($settings['currency_symbol_position'] == "pre") ? $settings['currency_symbol_position'] : '') . number_format($price, Utility::getValByName('decimal_number')) . (($settings['currency_symbol_position'] == "post") ? $settings['currency_symbol_position'] : ''); } public function currencySymbol() { $settings = Utility::settings(); return $settings['site_currency_symbol']; } public function countStoreUsers($storeID) { return User::where('created_by', '=', $this->creatorId())->where('current_store', '=', $storeID)->count(); } public function countStoreProducts($storeID) { return Product::where('created_by', '=', $this->creatorId())->where('store_id', '=', $storeID)->count(); } }