Example #1
0
 public function doDelete($id)
 {
     $gift = Gift::findOrFail($id);
     try {
         $gift->delete();
         return redirect()->back()->with('message', 'Gift has been deleted successfully !');
     } catch (ParseException $ex) {
         echo 'Failed to create new meal , with error message: ' . $ex->getMessage();
     }
 }
Example #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Gift::destroy($id);
     return \Redirect::route('gifts.index')->with('message', "The gift has been deleted");
 }
Example #3
0
 public function create($doctorId = NULL)
 {
     $AMIds = Employee::select('id')->where('manager_id', 1)->get();
     $employees = Employee::select('id')->whereIn('manager_id', $AMIds)->get();
     $description_names = Customer::distinct()->select('description_name')->whereIn('mr_id', $employees)->get();
     $doctors = Customer::whereIn('mr_id', $employees)->get();
     $employeesLines = Employee::select('line_id')->where('manager_id', 4)->get();
     $products = Product::where('line_id', $employeesLines)->get();
     $gifts = Gift::all();
     $dataView = ['description_names' => $description_names, 'doctors' => $doctors, 'products' => $products, 'gifts' => $gifts, 'doctorId' => !empty($doctorId) ? $doctorId : ''];
     return view('sm.report.create', $dataView);
 }
Example #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $gift = Gift::findOrFail($id);
     $gift->delete();
     return redirect()->route('admin.gifts.index')->with('message', 'Xóa thành công');
 }
Example #5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Gift::truncate();
     $data = [['code' => "asdfsdaf3svwe33r", 'description' => "Skill"]];
     Gift::insert($data);
 }
Example #6
0
 public function postGift(Request $request)
 {
     $data = $request->except('_token');
     $model = new GAccount();
     $gift = new Gift();
     $giftBox = new GiftBox();
     //check all user if exsit on all server game
     $servers = Server::all();
     foreach ($servers as $server) {
         $model->setConnection($server->user_db);
         $gift->setConnection($server->user_db);
         $giftBox->setConnection($server->user_db);
         try {
             $account = $model->where('loginName', $data['username'])->first();
             $gift = $gift->where('GiftCode', $data['gift_code'])->first();
             if (is_null($gift)) {
                 dd('không tồn tại gift code');
                 return redirect()->route('user.gift.get')->with('message', 'Gift code sai!');
             }
             if (is_null($account)) {
                 dd('không tồn tại tên đăng nhập');
                 return redirect()->route('user.gift.get')->with('message', 'Username tồn tại');
             }
             $giftBox->acct_id = $account->acct_id;
             $giftBox->item_id = $gift->gift_id;
             $giftBox->itemtype = 0;
             $giftBox->quantity = 1;
             $giftBox->serialNo = 0;
             $giftBox->save();
         } catch (\Exception $e) {
             dd($e);
             return redirect()->route('user.gift.get')->with('error', 'database có lỗi!');
         }
     }
     return redirect()->route('user.gift.get')->with('message', 'Nhận quà thành công!');
 }
Example #7
0
 public function search()
 {
     $doctors = Customer::where('mr_id', \Auth::user()->id)->get();
     $MRLine = Employee::findOrFail(\Auth::user()->id)->line_id;
     $products = Product::where('line_id', $MRLine)->get();
     $gifts = Gift::all();
     $dataView = ['doctors' => $doctors, 'products' => $products, 'gifts' => $gifts];
     return view('mr.search.reports.search', $dataView);
 }