private function execute($message, $tg)
 {
     try {
         if (!array_key_exists('text', $message)) {
             app()->abort(200, 'Missing command');
         }
         if (starts_with($message['text'], '/start')) {
             $this->start($message, $tg);
         } else {
             if (starts_with($message['text'], '/cancel')) {
                 $this->cancel($message, $tg);
             } else {
                 if (starts_with($message['text'], '/list')) {
                     $this->listApps($message, $tg);
                 } else {
                     if (starts_with($message['text'], '/revoke')) {
                         $this->revoke($message, $tg);
                     } else {
                         if (starts_with($message['text'], '/help')) {
                             $this->help($message, $tg);
                         } else {
                             $this->commandReply($message, $tg);
                         }
                     }
                 }
             }
         }
         return response()->json('', 200);
     } catch (\Exception $e) {
         \Log::error($e);
         app()->abort(200);
     }
 }
 /**
  * Stores new upload
  *
  */
 public function store()
 {
     $file = Input::file('file');
     $upload = new Upload();
     try {
         $upload->process($file);
     } catch (Exception $exception) {
         // Something went wrong. Log it.
         Log::error($exception);
         $error = array('name' => $file->getClientOriginalName(), 'size' => $file->getSize(), 'error' => $exception->getMessage());
         // Return error
         return Response::json($error, 400);
     }
     // If it now has an id, it should have been successful.
     if ($upload->id) {
         $newurl = URL::asset($upload->publicpath() . $upload->filename);
         // this creates the response structure for jquery file upload
         $success = new stdClass();
         $success->name = $upload->filename;
         $success->size = $upload->size;
         $success->url = $newurl;
         $success->thumbnailUrl = $newurl;
         $success->deleteUrl = action('UploadController@delete', $upload->id);
         $success->deleteType = 'DELETE';
         $success->fileID = $upload->id;
         return Response::json(array('files' => array($success)), 200);
     } else {
         return Response::json('Error', 400);
     }
 }
 private function notifyHost($client, $reservation)
 {
     $host = $reservation->property->user;
     $twilioNumber = config('services.twilio')['number'];
     try {
         $client->account->messages->sendMessage($twilioNumber, $host->fullNumber(), $reservation->message);
     } catch (Exception $e) {
         Log::error($e->getMessage());
     }
 }
 private function notifyHost($client, $reservation)
 {
     $host = $reservation->property->user;
     $twilioNumber = config('services.twilio')['number'];
     $messageBody = $reservation->message . ' - Reply \'yes\' or \'accept\' to confirm the reservation, or anything else to reject it.';
     try {
         $client->messages->create($host->fullNumber(), ['from' => $twilioNumber, 'body' => $messageBody]);
     } catch (Exception $e) {
         Log::error($e->getMessage());
     }
 }
 public function update(Request $request)
 {
     $query = DB::table('Company')->where('companyId', $request->input('companyId'))->update(array('companyName' => $request->input('companyName'), 'generalAttributes' => $request->input('generalAttributes'), 'purposeAndTopic' => $request->input('purposeAndTopic'), 'companyCenterAndDepartment' => $request->input('companyCenterAndDepartment'), 'jobDescription' => $request->input('jobDescription'), 'companyAdress' => $request->input('companyAdress'), 'employeeCount' => $request->input('employeeCount'), 'companyMail' => $request->input('companyMail'), 'employeeId' => \Session::get('employeeId')));
     \Log::error($query);
     if ($query) {
         $result = array("result" => "success");
     } else {
         $result = array("result" => "failed");
     }
     return \View::make('ajaxResult', $result);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(MicroCritical $request)
 {
     //store
     $microcritical = new MicroCritical();
     $microcritical->description = $request->description;
     try {
         $microcritical->save();
         $url = session('SOURCE_URL');
         return redirect()->to($url)->with('message', trans('messages.record-successfully-saved'))->with('activemicrocritical', $microcritical->id);
     } catch (QueryException $e) {
         Log::error($e);
     }
 }
Example #7
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store($measures)
 {
     // dd($measures);
     $measureIds = array();
     foreach ($measures as $data) {
         $measure = new Measure();
         $measure->name = trim($data['name']);
         $measure->measure_type_id = $data['measure_type_id'];
         $measure->unit = $data['unit'];
         $measure->description = $data['description'];
         try {
             $measure->save();
             $measureIds[] = $measure->id;
         } catch (QueryException $e) {
             Log::error($e);
         }
         if ($measure->isNumeric()) {
             $val['agemin'] = $data['agemin'];
             $val['agemax'] = $data['agemax'];
             $val['gender'] = $data['gender'];
             $val['rangemin'] = $data['rangemin'];
             $val['rangemax'] = $data['rangemax'];
             $val['interpretation'] = $data['interpretation'];
             // Add ranges for this measure
             for ($i = 0; $i < count($val['agemin']); $i++) {
                 $measurerange = new MeasureRange();
                 $measurerange->measure_id = $measure->id;
                 $measurerange->age_min = $val['agemin'][$i];
                 $measurerange->age_max = $val['agemax'][$i];
                 $measurerange->gender = $val['gender'][$i];
                 $measurerange->range_lower = $val['rangemin'][$i];
                 $measurerange->range_upper = $val['rangemax'][$i];
                 $measurerange->interpretation = $val['interpretation'][$i];
                 $measurerange->save();
             }
         } else {
             if ($measure->isAlphanumeric() || $measure->isAutocomplete()) {
                 $val['val'] = $data['val'];
                 $val['interpretation'] = $data['interpretation'];
                 for ($i = 0; $i < count($val['val']); $i++) {
                     $measurerange = new MeasureRange();
                     $measurerange->measure_id = $measure->id;
                     $measurerange->alphanumeric = $val['val'][$i];
                     $measurerange->interpretation = $val['interpretation'][$i];
                     $measurerange->save();
                 }
             }
         }
     }
     return $measureIds;
 }
Example #8
0
 public function deleteComment($id, $token)
 {
     $comment = Comment::find($id);
     if (!$comment) {
         return CommentHelpers::formatData(array(), false, sprintf('Comment %d not found', $id), 400);
     }
     if (trim(urldecode($token)) == trim($comment->getAttribute('token'))) {
         $comment->delete();
         \Log::info(sprintf('Deleted comment #%d', $id));
         return CommentHelpers::formatData(array(), true, sprintf('Comment %d was deleted', $id));
     }
     \Log::error(sprintf('Unauthorized request to delete comment #%d', $id));
     return CommentHelpers::formatData(array(), false, null, 403);
 }
Example #9
0
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6', 'rol' => 'required|in:1,2', 'image' => 'required|mimes:jpeg,png,bmp']);
     if (!$request->file('image')->isValid()) {
         Log::error('Invalid image file for user ' . Carbon::now());
         App::abort(500);
     }
     $image_name = $request->input('email') . Carbon::now()->timestamp . "_" . $request->file('image')->getClientOriginalName();
     $request->file('image')->move(public_path() . '/images/users/', $image_name);
     $data = $request->all();
     $data['image'] = $image_name;
     User::create($data);
     return redirect(action('UserController@index'));
 }
 /**
  * Handle incomming hooks.
  *
  * @param Request $request Incomming request object
  * @param string  $appName Name of the application the hook came from
  *
  * @return Response
  */
 public function recieve(Request $request, $appName)
 {
     /** @var \App\Hooks\ServiceRouter $serviceRouter */
     $serviceRouter = app('ServiceRouter');
     $result = $serviceRouter->route($request, $appName);
     if ($result === false) {
         \Log::error('Unable to handle request ' . $request->getUri());
         \Log::error(json_encode($request->all(), JSON_PRETTY_PRINT));
         return ['status' => 'Failure', 'message' => 'Unable to handle this type of request'];
     }
     if (isset($result['project']) && $result['project'] instanceof Project) {
         $this->processProject($result);
     }
     return ['status' => 'Success'];
 }
Example #11
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(ItemRequest $request)
 {
     //store
     $item = new Item();
     $item->name = Input::get('name');
     $item->unit = Input::get('unit');
     $item->remarks = Input::get('remarks');
     $item->min_level = Input::get('min_level');
     $item->max_level = Input::get('max_level');
     $item->storage_req = Input::get('storage_req');
     $item->user_id = Auth::user()->id;
     try {
         $item->save();
         $url = session('SOURCE_URL');
         return redirect()->to($url)->with('message', trans('messages.record-successfully-saved'))->with('activeitem', $item->id);
     } catch (QueryException $e) {
         \Log::error($e);
     }
 }
Example #12
0
 public function store(ProductQueryRequest $request)
 {
     if (!$request->hasFile('image') || !$request->file('image')->isValid()) {
         Log::error('Invalid image file for product ' . Carbon::now());
         App::abort(500);
     }
     $image_name = $request->input('name') . Carbon::now()->timestamp . "_" . $request->file('image')->getClientOriginalName();
     $request->file('image')->move(public_path() . '/images/products/', $image_name);
     $data = $request->all();
     $data['image'] = $image_name;
     $product = Product::create($data);
     $query_data = $request->input("_queries");
     $pattern = "/([@#]\\w+)/";
     preg_match_all($pattern, $query_data, $result);
     $string_query = implode(" OR ", $result[0]);
     $query = new Query(["query_string" => $string_query]);
     $product->queries()->save($query);
     return redirect(action("ProductController@index", $product->brand_id));
 }
Example #13
0
 public function githubCallback(Request $request)
 {
     $state = $request->get('state');
     if ($state == session('github.state')) {
         //http client
         $client = new Client();
         $res = $client->post('https://github.com/login/oauth/access_token', ['headers' => ['Accept' => 'application/json'], 'form_params' => ['client_id' => config('github.clientID'), 'client_secret' => config('github.clientSecret'), 'scope' => 'user', 'code' => $request->get('code'), 'state' => $request->get('state')]]);
         $jr = json_decode($res->getBody());
         if (isset($jr['error'])) {
             \Log::error($res->getBody());
             return abort(500, '<a href="' . $jr['error_uri'] . '">' . $jr['error_description'] . '</a>');
         } else {
             $access_token = $jr['access_token'];
             $res = $client->post('', ['headers' => ['Authorization' => 'token ' . $access_token]]);
         }
     } else {
         return abort(403, 'Invalid github state');
     }
 }
Example #14
0
 /**
  * Search for video
  *
  * @param string $q The search query
  *
  * @return Response
  */
 public function searchVideo($q)
 {
     // init result array
     $result = array();
     // create slug from query
     $q_slug = str_slug('youtube-' . $q);
     // check if search is in cache
     if (\Cache::has($q_slug)) {
         // retrieve item from cache
         $items = \Cache::get($q_slug);
         // add data to array
         $result = array('fromcache' => true, 'data' => $items);
     } else {
         // init Google objects
         $client = new \Google_Client();
         $client->setDeveloperKey(env('YOUTUBE_API_KEY'));
         $youtube = new \Google_Service_YouTube($client);
         try {
             $items = array();
             // use youtube search to retrieve video data
             $searchResponse = $youtube->search->listSearch('id,snippet', array('q' => $q, 'maxResults' => 3, 'type' => 'video'));
             // loop through search results
             foreach ($searchResponse['items'] as $video) {
                 // create object for this video
                 $item = new YoutubeVideo($video['id']['videoId'], $video['snippet']['title'], $video['snippet']['description'], $video['snippet']['thumbnails']['default']['url']);
                 // add object to results
                 $items[] = $item;
             }
             // add items to cache for a year
             \Cache::add($q_slug, $items, 60 * 24 * 365);
             // add data to array
             $result = array('fromcache' => false, 'data' => $items);
         } catch (\Google_Service_Exception $e) {
             // log Google_Service_Exception
             \Log::error('Google_Service_Exception: ' . $e->getMessage());
         } catch (\Google_Exception $e) {
             // log Google_Exception
             \Log::error('Google_Exception: ' . $e->getMessage());
         }
     }
     // return json formatted response
     return response()->json($result);
 }
Example #15
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Critical $request)
 {
     //store
     $critical = new Critical();
     $critical->parameter = $request->measure_id;
     $critical->gender = $request->gender;
     $critical->age_min = $request->age_min;
     $critical->age_max = $request->age_max;
     $critical->normal_lower = $request->normal_lower;
     $critical->normal_upper = $request->normal_upper;
     $critical->critical_low = $request->critical_low;
     $critical->critical_high = $request->critical_high;
     $critical->unit = $request->unit;
     try {
         $critical->save();
         $url = session('SOURCE_URL');
         return redirect()->to($url)->with('message', trans('messages.record-successfully-saved'))->with('activecritical', $critical->id);
     } catch (QueryException $e) {
         Log::error($e);
     }
 }
Example #16
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(StockRequest $request)
 {
     $stock = new Stock();
     $stock->item_id = $request->item_id;
     $stock->lot = $request->lot;
     $stock->batch_no = $request->batch_no;
     $stock->expiry_date = $request->expiry_date;
     $stock->manufacturer = $request->manufacturer;
     $stock->supplier_id = $request->supplier_id;
     $stock->quantity_supplied = $request->quantity_supplied;
     $stock->cost_per_unit = $request->cost_per_unit;
     $stock->date_of_reception = $request->date_of_reception;
     $stock->remarks = $request->remarks;
     $stock->user_id = Auth::user()->id;
     try {
         $stock->save();
         $url = session('SOURCE_URL');
         return redirect()->to($url)->with('message', trans('messages.record-successfully-saved'))->with('activestock', $stock->id);
     } catch (QueryException $e) {
         Log::error($e);
     }
 }
 public function receive(Request $request, $token)
 {
     try {
         if ($token != env('WEBHOOK_TOKEN')) {
             app()->abort(401, 'This is not the site you are looking for!');
         }
         $message = $request->input('message');
         if (!array_key_exists('text', $message)) {
             app()->abort(200, 'Missing command');
         }
         if (starts_with($message['text'], '/start')) {
             $this->start($message);
         } else {
             if (starts_with($message['text'], '/cancel')) {
                 $this->cancel($message);
             } else {
                 if (starts_with($message['text'], '/list')) {
                     $this->listApps($message);
                 } else {
                     if (starts_with($message['text'], '/revoke')) {
                         $this->revoke($message);
                     } else {
                         if (starts_with($message['text'], '/help')) {
                             $this->help($message);
                         } else {
                             $this->commandReply($message);
                         }
                     }
                 }
             }
         }
         return response()->json('', 200);
     } catch (\Exception $e) {
         \Log::error($e);
         app()->abort(200);
     }
 }
Example #18
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     $rules = array('receivers_name' => 'required', 'quantity_issued' => 'required|integer', 'batch_no' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return redirect()->to('issue.index')->withErrors($validator);
     } else {
         // store
         $issue = new Issue();
         $issue->receipt_id = Input::get('batch_no');
         $issue->topup_request_id = Input::get('topup_request_id');
         $issue->quantity_issued = Input::get('quantity_issued');
         $issue->issued_to = Input::get('receivers_name');
         $issue->user_id = Auth::user()->id;
         $issue->remarks = Input::get('remarks');
         try {
             $issue->save();
             return redirect()->to('issue.index')->with('message', trans('messages.commodity-succesfully-added'));
         } catch (QueryException $e) {
             Log::error($e);
         }
     }
 }
Example #19
0
 public function deleteImage($docId)
 {
     $doc = Doc::where('id', $docId)->first();
     $image_path = $doc->getImagePathFromUrl($doc->thumbnail);
     if (Storage::has($image_path)) {
         try {
             Storage::delete($image_path);
         } catch (Exception $e) {
             Log::error("Error deleting document featured image for document id {$docId}");
             Log::error($e);
         }
     }
     $doc->thumbnail = null;
     $doc->save();
     return Response::json($this->growlMessage('Image deleted successfully', 'success'));
 }
Example #20
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     //Validate
     $rules = array('name' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return redirect()->to('metric.index')->withErrors($validator);
     } else {
         // Update
         $metric = Metric::find($id);
         $metric->name = Input::get('unit_of_issue');
         $metric->description = Input::get('description');
         try {
             $metric->save();
             return redirect()->to('metric.index')->with('message', trans('messages.success-updating-metric'))->with('activemetric', $metric->id);
         } catch (QueryException $e) {
             Log::error($e);
         }
     }
 }
Example #21
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(SupplierRequest $request, $id)
 {
     $supplier = Supplier::find($id);
     $supplier->name = $request->name;
     $supplier->address = $request->address;
     $supplier->phone = $request->phone;
     $supplier->email = $request->email;
     $supplier->user_id = Auth::user()->id;
     $supplier->save();
     try {
         $supplier->save();
         $url = session('SOURCE_URL');
         return redirect()->to($url)->with('message', trans('messages.record-successfully-updated'))->with('activesupplier', $supplier->id);
     } catch (QueryException $e) {
         \Log::error($e);
     }
 }
 public function processCancel(Request $request, $id)
 {
     $requesition = Requesition::with(['items' => function ($query) {
         $query->where('status', RequesitionItem::PADDING);
     }, 'items.product', 'items.product.stock'])->whereId($id)->first();
     try {
         DB::transaction(function () use(&$requesition, $request) {
             $requesition->setStatusCancel($request->get('requesition_item_ids'));
         });
         $url = url('/requesitions');
         if ($requesition->status != Requesition::SUCCESS) {
             $url = url("/requisitions/processes/{$requesition->id}");
         }
         return ['status' => true, 'title' => trans('requesition.label.name'), 'message' => trans('requesition.message_alert.status_cancel_message'), 'url' => $url];
     } catch (Exception $e) {
         Log::error('requesition-item-unsuccess', array($e));
         return ['status' => false, 'title' => trans('requesition.label.name'), 'message' => trans('requesition.message_alert.status_cancel_unsuccess_message'), 'url' => url("/requisitions/processes/{$requesition->id}")];
     }
 }
Example #23
0
 public function postFinishSignUp(SignUpFinish $req)
 {
     /** @var User $user */
     $user = unserialize(session('signup.user'));
     try {
         \DB::transaction(function () use($req, $user) {
             if ($req->email) {
                 $user->email = $req->email;
             }
             $user->username = $req->username;
             $user->throwOnValidation = true;
             //todo: https://github.com/laravel-ardent/ardent/issues/279
             $user->save();
             $this->saveLinks($user, true);
             $this->saveLinks($user);
             //those fields should not be "pulled" as an error might rise and their values can be reused in a 2nd try
             session()->remove('signup.user');
             session()->remove('signup.relations');
         });
     } catch (InvalidModelException $e) {
         return redirect()->action('AuthController@getSignUp')->with('social_error', true)->with('provider', $req->provider)->withErrors($e->getErrors());
     } catch (\Exception $e) {
         \Log::error(class_basename($e) . ' during social auth (' . printr($_GET) . '): [' . $e->getCode() . '] ' . $e->getMessage());
         return redirect()->action('AuthController@getSignUp')->with('social_error', true)->with('provider', $req->provider);
     }
     return $this->loginAfterSignUp($user, $req->provider);
 }
Example #24
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     try {
         Credntial::findOrFail($id)->delete();
     } catch (\Exception $e) {
         \Log::error($e);
         return redirect()->back()->withError('Deletion failed');
     }
 }
Example #25
0
 /**
  * 記事の一覧
  */
 public function getIndex()
 {
     \Log::error('エラーログテスト');
     $articles = Article::latest('updated_at')->paginate(3);
     return view('articles.index')->with(compact('articles'));
 }
Example #26
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     try {
         $validator = Validator::make($request->all(), $this->form_rules);
         if ($validator->fails()) {
             return redirect()->route('freeproducts.create', [$request->input('order_id')])->withErrors($validator->errors())->withInput();
         }
         //As is not defined that way is going to deliver products for every winner, I will confirm that the total winning is equal to total products in the cart
         $cart_detail = OrderDetail::where('order_id', $request->input('order_id'))->get();
         if ($request->input('draw_number') > $cart_detail->count()) {
             return redirect()->route('freeproducts.create', [$request->input('order_id')])->withErrors(trans('freeproduct.drawnumber_exceed_total_products'))->withInput();
         } else {
             //Process the order. The process is the same as with a shopping cart. The address is not requested
             //Direction is taken as the one with the user by default. Not having, it notifies the user to create a.
             $errors = Order::placeOrders('freeproduct');
             if ($errors) {
                 return redirect()->route('freeproducts.create', [$request->input('order_id')])->withErrors($errors)->withInput();
             } else {
                 $user = \Auth::user();
                 //Save Free Product
                 $freeproduct = new FreeProduct();
                 $freeproduct->user_id = $user->id;
                 $freeproduct->description = $request->input('description');
                 $freeproduct->start_date = $request->input('start_date');
                 $freeproduct->end_date = $request->input('end_date');
                 $freeproduct->participation_cost = $request->input('participation_cost');
                 $freeproduct->min_participants = $request->input('min_participants');
                 $freeproduct->max_participants = $request->input('max_participants');
                 $freeproduct->max_participations_per_user = $request->input('max_participations_per_user');
                 $freeproduct->draw_number = $request->input('draw_number');
                 $freeproduct->draw_date = $request->input('draw_date');
                 $freeproduct->save();
                 //Because the method placeOrders products generates orders for each vendor, you need to associate these orders to free product
                 $orders = Order::ofType('freeproduct')->ofStatus('paid')->where('user_id', $user->id)->get();
                 if ($orders) {
                     foreach ($orders as $order) {
                         //Each order products are searched and a duplicate of the same is made, marking them as a free product. This will allow the product goes on the results of the advanced search
                         $order_detail = OrderDetail::where('order_id', $order->id)->get();
                         if ($order_detail) {
                             foreach ($order_detail as $detail) {
                                 $product = Product::find($detail->product_id);
                                 $productactual = $product->toArray();
                                 unset($productactual['id']);
                                 unset($productactual['num_of_reviews']);
                                 $productactual['user_id'] = $user->id;
                                 $productactual['stock'] = $detail->quantity;
                                 $productactual['type'] = 'freeproduct';
                                 $productactual['parent_id'] = $product->id;
                                 $newproduct = Product::create($productactual);
                             }
                         }
                         if (!FreeProductOrder::where('order_id', $order->id)->first()) {
                             //order registration as a free product
                             $order_to_fp = new FreeProductOrder();
                             $order_to_fp->freeproduct_id = $freeproduct->id;
                             $order_to_fp->order_id = $order->id;
                             $order_to_fp->save();
                         }
                     }
                 }
                 //Send message process Ok and redirect
                 Session::flash('message', trans('freeproduct.saved_successfully'));
                 return redirect()->route('freeproducts.show', [$freeproduct->id]);
             }
         }
     } catch (ModelNotFoundException $e) {
         Log::error($e);
         return redirect()->back()->withErrors(['induced_error' => [trans('freeproduct.error_exception')]])->withInput();
     }
 }
 public function update(Request $request)
 {
     $query = DB::table('CV')->where('employeeId', Session::get('employeeId'))->update(array('tcNo' => $request->input('1'), 'sex' => $request->input('2'), 'birtday' => $request->input('3'), 'lastBussines' => $request->input('4'), 'eStatus' => $request->input('5'), 'mStatus' => $request->input('6'), 'army' => $request->input('7'), 'reference' => $request->input('8')));
     \Log::error($query);
     if ($query) {
         $result = array("result" => "success");
     } else {
         $result = array("result" => "failed");
     }
     return \View::make('ajaxResult', $result);
 }
Example #28
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(TopupRequest $request, $id)
 {
     // Update
     $topup = Topup::find($id);
     $topup->item_id = $request->item_id;
     $topup->quantity_remaining = $request->quantity_remaining;
     $topup->test_category_id = $request->test_category_id;
     $topup->tests_done = $request->tests_done;
     $topup->quantity_ordered = $request->quantity_ordered;
     $topup->remarks = $request->remarks;
     $topup->user_id = Auth::user()->id;
     try {
         $topup->save();
         $url = session('SOURCE_URL');
         return redirect()->to($url)->with('message', trans('messages.record-successfully-updated'))->with('activerequest', $topup->id);
     } catch (QueryException $e) {
         \Log::error($e);
     }
 }
Example #29
0
 public function setActiveGroup($groupId)
 {
     try {
         if (!Auth::check()) {
             return Response::json($this->growlMessage('You must be logged in to use Madison as a group', 'error'), 401);
         }
         if ($groupId == 0) {
             Session::remove('activeGroupId');
             return Response::json($this->growlMessage('Active group has been removed', 'success'));
         }
         if (!Group::isValidUserForGroup(Auth::user()->id, $groupId)) {
             return Response::json($this->growlMessage('Invalid group', 'error'), 403);
         }
         Session::put('activeGroupId', $groupId);
         return Response::json($this->growlMessage('Active group changed', 'success'));
     } catch (\Exception $e) {
         Log::error($e);
         return Response::json($this->growlMessage('There was an error changing the active group', 'error'), 500);
     }
 }
Example #30
0
 /**
  * Update the specified instrument.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     //
     $rules = array('name' => 'required', 'ip' => 'required|ip');
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator);
     } else {
         // Update
         $instrument = Instrument::find($id);
         $instrument->name = Input::get('name');
         $instrument->description = Input::get('description');
         $instrument->ip = Input::get('ip');
         $instrument->hostname = Input::get('hostname');
         try {
             $instrument->save();
             $message = trans('messages.success-updating-instrument');
         } catch (QueryException $e) {
             $message = trans('messages.failure-updating-instrument');
             Log::error($e);
         }
         return redirect()->to('instrument.index')->with('message', $message);
     }
 }