/
home
/
pay
/
server
/
app
/
Http
/
Controllers
/
Admin
/
File Upload :
llllll
Current File: /home/pay/server/app/Http/Controllers/Admin/CustomerController.php
<?php namespace App\Http\Controllers\Admin; use App\DB\Te\TableEngine; use App\Http\Controllers\SuperController; use App\Models\Customer; use App\Models\TransactionsAdmin; use App\Models\Withdraw; use Illuminate\Http\Request; use Rooyesh\Wallet\interfaces\TransactionInterface; use Rooyesh\Wallet\interfaces\WalletInterface; use Rooyesh\Wallet\models\Transaction; use Rooyesh\Wallet\models\Wallet; use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; class CustomerController extends SuperController { public function __construct() { $this->with = []; $this->select = ['*']; $search=['name','mobile']; $this->query = Customer::with($this->with,'wallet')->where('is_archive',false)->where('type',1); // $this->query = Customer::where('is_archive',false)->get(); parent::__construct(Customer::class, $this->with, $this->select, 'customer', $this->query, $search); } /** * @param $id * @return \Illuminate\Http\JsonResponse */ public function listUser(){ $user = Customer::with(['wallet'])->select('id','name','mobile','type')->get(); return response()->json($user); } public function referrals(Request $request,$customer_id) { $customer_referral_id = Customer::where("id",$customer_id)->first()->referral_id; $query_table = Customer::where("referral_to_id",$customer_referral_id); TableEngine::create($query_table, $request) ->initSearch($this->search) ->select(['*',Customer::$SELECT_TYPE_STR]) ->export($query_table); return response()->json($query_table); } public function funds(Request $request,$customer_id) { $query_table = Wallet::with('fund')->where('owner', $customer_id); // Adjust columns as per your schema TableEngine::create($query_table, $request) ->initSearch($this->search) ->select(['id', 'owner', 'cash', 'gold','fund_id','created_at', 'updated_at']) ->export($query_table); return response()->json($query_table); } public function archive($id){ $query = Customer::findOrFail($id); $query->update([ 'is_archive'=>!$query->is_archive ]); return response()->json(true); } public function tableWallets(Request $request){ $query_table = Customer::with(['wallet','referral'])->where("is_archive",false)/*->where('type',1)*/; TableEngine::create($query_table, $request) ->initSearch($this->search) ->select(['*',Customer::$SELECT_TYPE_STR]) ->export($query_table); return response()->json($query_table); } public function archiveTable(Request $request) { $query_table = Customer::with($this->with)->where("is_archive",true)/*->where('type',1)*/; TableEngine::create($query_table, $request) ->initSearch($this->search) ->select($this->select) ->export($query_table); return response()->json($query_table); } /** * @param $id * @return \Illuminate\Http\JsonResponse */ public function active($id){ $query = Customer::findOrFail($id); $active = !$query->active; $query->update([ 'active'=>!$query->active ]); if ($active){ $message ='اکانت شما توسط کارشناس سیستم تایید شد '."\n". 'با رفتن به لینک زیر وارد حساب کاربری خود شوید'."\n". $this->Config('app_url')."\n". 'با تشکر'.$this->Config('name_fa'); } else{ $message ='اکانت شما توسط کارشناس سیستم غیر فعال شد '."\n". 'با کارشناسان ما تماس بگیرید'."\n". 'با تشکر'.$this->Config('name_fa'); } $this->Send($query->mobile,$message); return response()->json(true); } public function changeTradeActive($id){ $query = Customer::findOrFail($id); $query->update([ 'trade_active'=>!$query->trade_active ]); return response()->json(true); } // single customer------------------- public function singleArchiveTable(Request $request) { $query_table = Customer::with($this->with)->where("is_archive",true)->where('type',2); TableEngine::create($query_table, $request) ->initSearch($this->search) ->select($this->select) ->export($query_table); return response()->json($query_table); } public function singleCustomerTable(Request $request) { $query_table = Customer::with($this->with)->where("is_archive",false)->where('type',2); TableEngine::create($query_table, $request) ->initSearch($this->search) ->select($this->select) ->export($query_table); return response()->json($query_table); } public function MakeValidByAdmin(Request $request,$id) { $customer = Customer::with('referral')->where('id', $id)->first(); if ($customer->is_legal == 2){ return response()->json(true); } $customer->is_legal = 2; $customer->save(); if ($this->Config('has_page_earn_money') == true){ $gift_for_invite = 0.01; $Withdraw = Withdraw::create([ 'user_id' => $customer->id, 'customer_id' => $customer->referral->id, "cash" => 0, "gold" => $gift_for_invite, 'sts' => 5, ]); } $companyName = $this->Config('name_fa'); $companyurl = $this->Config('app_url'); $message ='حساب کاربری شما توسط کارشناس سیستم تایید شد '."\n". 'با رفتن به لینک زیر وارد حساب کاربری خود شوید'."\n". $this->Config('app_url')."\n". 'با تشکر'.$this->Config('name_fa'); $this->Send($customer->mobile, $message); $referrer = $customer->referral; if ($referrer) { if (Customer::where('referral_to_id', $referrer->referral_id)->get()->count()<=$referrer->add_user_limit) { $referrerWallet = Wallet::where('owner',$customer->referral->id)->first(); $message = "سلام {$referrer->name} عزیز،\n\n{$gift_for_invite} گرم طلا بابت معرفی {$customer->name} به حساب شما واریز شد.\nموجودی فعلی: {$referrerWallet->gold} گرم.\n\nاطلاعات بیشتر: $companyurl\n\nبا احترام،\n$companyName"; $this->Send($referrer->mobile, $message); } } return response()->json(true); } }
Copyright ©2k19 -
Hexid
|
Tex7ure