SHARE
TWEET

Untitled

a guest Oct 5th, 2018 135 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version         :   4.0.6.0
  8. * @ Author          :   DeZender
  9. * @ Release on      :   20.09.2018
  10. * @ Official site   :   http://DeZender.Net
  11. *
  12. */
  13.  
  14. namespace App\Http\Controllers\Admin;
  15.  
  16. class PackageController extends Controller
  17. {
  18.     public function index()
  19.     {
  20.         return view('admin.packages.index');
  21.     }
  22.  
  23.     public function indexData()
  24.     {
  25.         if (request()->server('SERVER_NAME') == 'smmworldpanel.com') {
  26.             $packages = DB::select('SELECT' . "\n" . '                                         id,' . "\n" . '                                         name,' . "\n" . '                                         description,' . "\n" . '                                         price_per_item,' . "\n" . '                                         minimum_quantity,' . "\n" . '                                         maximum_quantity,' . "\n" . '                                         features,' . "\n" . '                                         position,' . "\n" . '                                         status' . "\n" . '                                       FROM' . "\n" . '                                         packages' . "\n" . '                                       UNION' . "\n" . '                                       SELECT' . "\n" . '                                         id,' . "\n" . '                                         name,' . "\n" . '                                         "3kWKcZLJ" AS description,' . "\n" . '                                         -1 AS price_per_item,' . "\n" . '                                         -1 AS minimum_quantity,' . "\n" . '                                         -1 AS maximum_quantity,' . "\n" . '                                         "" AS features,' . "\n" . '                                         position,' . "\n" . '                                         status' . "\n" . '                                       FROM' . "\n" . '                                         services');
  27.         }
  28.         return datatables()->of($packages)->editColumn('id', function($package) {
  29.             if ($package->description == '3kWKcZLJ') {
  30.                 return $package->id . '<br><a href="/admin/package/service/' . $package->id . '/up" class="btn btn-xs btn-success"><i class="fas fa-caret-square-up"></i></a>&nbsp;<a href="/admin/package/service/' . $package->id . '/down" class="btn btn-xs btn-success"><i class="fas fa-caret-square-down"></i></a>';
  31.             }
  32.             else {
  33.                 return $package->id . '<br><a href="/admin/package/' . $package->id . '/up" class="btn btn-xs btn-success"><i class="fas fa-caret-square-up"></i></a>&nbsp;<a href="/admin/package/' . $package->id . '/down" class="btn btn-xs btn-success"><i class="fas fa-caret-square-down"></i></a>';
  34.             }
  35.         })->addColumn('action', function($package) {
  36.             $id = $package->id;
  37.  
  38.             if ($package->description == '3kWKcZLJ') {
  39.                 return view('admin.services.index-buttons', compact('id'));
  40.             }
  41.             else {
  42.                 return view('admin.packages.index-buttons', compact('id'));
  43.             }
  44.         })->addColumn('sposition', function($package) {
  45.             if ($package->description == '3kWKcZLJ') {
  46.                 return $package->position;
  47.             }
  48.             else {
  49.                 return \App\Package::find($package->id)->service->position;
  50.             }
  51.         })->addColumn('jposition', function($package) {
  52.             if ($package->description == '3kWKcZLJ') {
  53.                 return 0;
  54.             }
  55.             else {
  56.                 return $package->position;
  57.             }
  58.         })->editColumn('price_per_item', '{{ getOption(\'currency_symbol\') . number_format(($price_per_item * getOption(\'display_price_per\')),2, getOption(\'currency_separator\'), \'\') }}')->editColumn('description', '{{ str_limit($description,50) }}')->setRowClass(function($package) {
  59.             return $package->description == '3kWKcZLJ' ? 'serviceClass' : '';
  60.         })->rawColumns(['id', 'action'])->toJson();
  61.     }
  62.  
  63.     public function create()
  64.     {
  65.         $apis = \App\API::all();
  66.         $services = \App\Service::where(['status' => 'ACTIVE'])->get();
  67.         return view('admin.packages.create', compact('services', 'apis'));
  68.     }
  69.  
  70.     public function store(\Illuminate\Http\Request $request)
  71.     {
  72.         $this->validate($request, ['service_id' => 'required', 'name' => 'required', 'price_per_item' => 'required|numeric', 'minimum_quantity' => 'required|numeric', 'maximum_quantity' => 'required|numeric', 'description' => 'required', 'features' => 'required']);
  73.         $price_per_item = $request->input('price_per_item') / 1000;
  74.         $minimum_quantity = $request->input('minimum_quantity');
  75.         $preferred_api_id = (!!$request->input('preferred_api_id') ? $request->input('preferred_api_id') : NULL);
  76.         $package = \App\Package::create(['service_id' => $request->input('service_id'), 'name' => $request->input('name'), 'slug' => str_slug($request->input('name')), 'price_per_item' => $price_per_item, 'minimum_quantity' => $request->input('minimum_quantity'), 'maximum_quantity' => $request->input('maximum_quantity'), 'refillbtn' => $request->input('refillbtn'), 'features' => $request->input('features'), 'status' => $request->input('status'), 'preferred_api_id' => $preferred_api_id, 'custom_comments' => $request->input('custom_comments'), 'description' => $request->input('description')]);
  77.         $seller_package_id = (!!$request->input('seller_package_id') ? $request->input('seller_package_id') : NULL);
  78.         if (isset($seller_package_id) && isset($preferred_api_id)) {
  79.             \App\ApiMapping::create(['api_id' => $preferred_api_id, 'api_package_id' => $seller_package_id, 'package_id' => $package->id]);
  80.         }
  81.  
  82.         \Illuminate\Support\Facades\Session::flash('alert', __('messages.created'));
  83.         \Illuminate\Support\Facades\Session::flash('alertClass', 'success');
  84.         return redirect('/admin/packages/create');
  85.     }
  86.  
  87.     public function show($id)
  88.     {
  89.         return redirect('/admin/packages');
  90.     }
  91.  
  92.     public function edit($id)
  93.     {
  94.         $package = \App\Package::findOrFail($id);
  95.         $apis = \App\API::all();
  96.         $services = \App\Service::where(['status' => 'ACTIVE'])->get();
  97.         $am = \App\ApiMapping::where(['api_id' => $package->preferred_api_id, 'package_id' => $package->id])->get();
  98.  
  99.         if (0 < $am->count()) {
  100.             $api_package_id = $am->first()->api_package_id;
  101.         }
  102.         else {
  103.             $api_package_id = '';
  104.         }
  105.  
  106.         return view('admin.packages.edit', compact('services', 'package', 'apis', 'api_package_id'));
  107.     }
  108.  
  109.     public function update(\Illuminate\Http\Request $request, $id)
  110.     {
  111.         $this->validate($request, ['service_id' => 'required', 'name' => 'required', 'price_per_item' => 'required|numeric', 'minimum_quantity' => 'required|numeric', 'maximum_quantity' => 'required|numeric', 'description' => 'required', 'features' => 'required']);
  112.         $price_per_item = $request->input('price_per_item') / 1000;
  113.         $minimum_quantity = $request->input('minimum_quantity');
  114.         $package = \App\Package::findOrFail($id);
  115.         $preferred_api_id = (!!$request->input('preferred_api_id') ? $request->input('preferred_api_id') : NULL);
  116.         $package->service_id = $request->input('service_id');
  117.         $package->name = $request->input('name');
  118.         $package->slug = str_slug($request->input('name'));
  119.         $package->price_per_item = $price_per_item;
  120.         $package->minimum_quantity = $request->input('minimum_quantity');
  121.         $package->maximum_quantity = $request->input('maximum_quantity');
  122.         $package->refillbtn = $request->input('refillbtn');
  123.         $package->features = $request->input('features');
  124.         $package->position = $request->input('position');
  125.         $package->status = $request->input('status');
  126.         $package->description = $request->input('description');
  127.         $package->preferred_api_id = $preferred_api_id;
  128.         $package->custom_comments = $request->input('custom_comments');
  129.         $package->save();
  130.         $seller_package_id = (!!$request->input('seller_package_id') ? $request->input('seller_package_id') : NULL);
  131. ........................................................................................................................
  132. ...................................................
  133. ............................
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top