Exemplo n.º 1
0
 public static function onSendReport($is_rest = false)
 {
     if (!Auth::check() && !$is_rest) {
         return null;
     }
     if (!Auth::check() && $is_rest) {
         return 'Bad Request!';
     }
     $data = post();
     $rules = ['item_id' => 'required|numeric', 'content' => 'required', 'type' => 'required'];
     $validation = Validator::make($data, $rules);
     if ($validation->fails() && !$is_rest) {
         throw new ValidationException($validation);
     }
     if ($validation->fails() && $is_rest) {
         return $validation->messages()->first();
     }
     try {
         $report = new Report();
         $report->content = $data['content'];
         $report->user_id = Auth::getUser()->id;
         $report->item_id = $data['item_id'];
         $report->type = $data['type'];
         $report->save();
     } catch (Exception $ex) {
         if ($is_rest) {
             return $ex->getMessage();
         }
     }
     if (!$is_rest) {
         /*
          * Redirect to the intended page after successful sign in
          */
         $redirectUrl = $this->pageUrl($this->property('redirect'));
         if ($redirectUrl = post('redirect', $redirectUrl)) {
             return Redirect::intended($redirectUrl);
         }
     } else {
         return null;
     }
 }
Exemplo n.º 2
0
 public function index_onDelete()
 {
     if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
         foreach ($checkedIds as $reportId) {
             if (!($report = Report::find($reportId)) || !$report->canEdit($this->user)) {
                 continue;
             }
             $report->delete();
         }
         Flash::success('Successfully deleted those reports.');
     }
     return $this->listRefresh();
 }
Exemplo n.º 3
0
 public function run()
 {
     Report::insert([['user_id' => 4, 'content' => 'Test Report ' . rand(), 'item_id' => '1', 'status' => 0, 'type' => 'ad'], ['user_id' => 4, 'content' => 'Test Report ' . rand(), 'item_id' => '1', 'status' => 0, 'type' => 'ad'], ['user_id' => 4, 'content' => 'Test Report ' . rand(), 'item_id' => '1', 'status' => 0, 'type' => 'ad'], ['user_id' => 4, 'content' => 'Test Report ' . rand(), 'item_id' => '1', 'status' => 0, 'type' => 'ad'], ['user_id' => 4, 'content' => 'Test Report ' . rand(), 'item_id' => '1', 'status' => 0, 'type' => 'ad'], ['user_id' => 4, 'content' => 'Test Report ' . rand(), 'item_id' => '1', 'status' => 0, 'type' => 'ad'], ['user_id' => 4, 'content' => 'Test Report ' . rand(), 'item_id' => '1', 'status' => 0, 'type' => 'ad'], ['user_id' => 4, 'content' => 'Test Report ' . rand(), 'item_id' => '1', 'status' => 0, 'type' => 'ad'], ['user_id' => 4, 'content' => 'Test Report ' . rand(), 'item_id' => '1', 'status' => 0, 'type' => 'ad'], ['user_id' => 4, 'content' => 'Test Report ' . rand(), 'item_id' => '1', 'status' => 0, 'type' => 'ad'], ['user_id' => 4, 'content' => 'Test Report ' . rand(), 'item_id' => '1', 'status' => 0, 'type' => 'ad'], ['user_id' => 4, 'content' => 'Test Report ' . rand(), 'item_id' => '1', 'status' => 0, 'type' => 'ad'], ['user_id' => 4, 'content' => 'Test Report ' . rand(), 'item_id' => '1', 'status' => 0, 'type' => 'ad'], ['user_id' => 4, 'content' => 'Test Report ' . rand(), 'item_id' => '1', 'status' => 0, 'type' => 'ad'], ['user_id' => 4, 'content' => 'Test Report ' . rand(), 'item_id' => '1', 'status' => 0, 'type' => 'ad']]);
 }