/
home
/
old_henza
/
server
/
app
/
Http
/
Controllers
/
Adm
/
File Upload :
llllll
Current File: /home/old_henza/server/app/Http/Controllers/Adm/MajorCustomerController.php
<?php namespace App\Http\Controllers\Adm; use App\DB\Te\TableEngine; use App\Http\Controllers\Controller; use App\Models\Major\Cash; use App\Models\Customer; use App\Models\Order; use App\Models\Sms; use Illuminate\Http\Request; use Illuminate\Support\Facades\Validator; class MajorCustomerController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { $records = Customer::with(['reagent', 'cash', 'order']) ->orderBy('id', 'DESC'); TableEngine::create($records,$request->all()) ->initSearch(['fname','lname','mobile','name']) ->select([ '*', Customer::$SELECT_CAJ, ])->export($records); return response()->json($records); } public function dashboard($id){ $records = Customer::select('fname', 'lname','gram_level', 'percent', 'remain', 'rial_remain','grams_sell', 'created_at', 'active', 'sts',Customer::$SELECT_CAJ,Customer::$SELECT_STS_STR) ->findOrFail($id); $count = Customer::where('reagent_id',$id)->count(); $records['count'] = $count; return response()->json($records); } public function order(Request $request){ // $records = Order::where('customer_id',$id); $records = Order::query(); TableEngine::create($records,$request->all()) ->initSearch([]) ->select([ '*', Order::$SELECT_CAJ, Order::$SELECT_STS_STR, Order::$SELECT_TYPE_STR ])->export($records); return response()->json($records); } public function cash(Request $request){ // $records = Cash::where('customer_id',$id); $records = Cash::query(); TableEngine::create($records,$request->all()) ->initSearch(['fname','lname','mobile','name']) ->select([ '*', Cash::$SELECT_CAJ, Cash::$SELECT_STS_STR, Cash::$SELECT_TYPE_STR ])->export($records); return response()->json($records); } public function shopkeeper(Request $request){ // $records = Customer::where('reagent_id',$id); $records = Customer::query(); TableEngine::create($records,$request->all()) ->initSearch(['fname','lname','mobile','name']) ->select([ '*', Cash::$SELECT_CAJ, Cash::$SELECT_STS_STR, Cash::$SELECT_TYPE_STR ])->export($records); return response()->json($records); } public function indexSms(Request $request){ $records = Sms::query(); TableEngine::create($records, $request->all()) ->initSearch([]) ->select([ '*', Sms::$SELECT_CAJ, ])->export($records); return response()->json($records); } public function verifyRegister(Request $request){ $validator = Validator::make($request->all(), [ 'customer_id'=>'required', ]); if ($validator->fails()) { return response()->json($validator->errors(),422); } $data = $request->all(); $customer = Customer::findOrFail($data['customer_id']); if (isset($data['sts_verify_step_one'])){ $customer->sts_verify_step_one = $data['sts_verify_step_one']; if ($data['sts_verify_step_one'] == 2){ $customer->api_token = \Illuminate\Support\Str::random(60); $customer->active = 1; }elseif ($data['sts_verify_step_one'] == 3){ $customer->active =-1; } } if (isset($data['sts_verify_step_two'])){ $customer->sts_verify_step_two = $data['sts_verify_step_two']; if ($data['sts_verify_step_two'] == 2){ Sms::Send($customer->mobile, 'هنزا گلد' . "\n" . 'مشتری گرامی حساب کاربری شما در باشگاه مشتریان اپلیکیشن هنزا تایید و فعال شد '); } } if (isset($data['is_archive'])){ $customer->is_archive = $data['is_archive']; } $customer->save(); return response()->json(true); } public function indexArchive(Request $request){ $records = Customer::where('is_archive',1); TableEngine::create($records,$request->all()) ->initSearch(['fname','lname','mobile','name']) ->select([ '*', Cash::$SELECT_CAJ, Cash::$SELECT_STS_STR, Cash::$SELECT_TYPE_STR ])->export($records); return response()->json($records); } public function indexVerify(Request $request){ $records = Customer::with(['business_license_image','shop_image','ncode_image']) ->where('is_archive',0)->where(function ($q){ return $q->where('sts_verify_step_one',1)-> orWhere('sts_verify_step_two',1); }); TableEngine::create($records,$request->all()) ->initSearch(['fname','lname','mobile','name']) ->select([ '*', Customer::$SELECT_CAJ, Customer::$SELECT_STS_STR, Customer::$SELECT_TYPE_STR, // Customer::$SELECT_STS_VERIFY_STEP_ONE_STR, // Customer::$SELECT_STS_VERIFY_STEP_TWO_STR, ])->export($records); return response()->json($records); } public function archive($id){ $query = Customer::findOrFail($id); $query->update([ 'is_archive'=>!$query->is_archive ]); return response()->json(true); } }
Copyright ©2k19 -
Hexid
|
Tex7ure