コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  CommentFormRequest  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CommentFormRequest $request)
 {
     $c = 123;
     $comment = new Comment(array('post_id' => $request->get('post_id'), 'content' => $request->rules($c)));
     $comment->save();
     return redirect()->back()->with('status', 'Your comment has been created.');
 }
コード例 #2
0
 public function postDelete(Request $Request)
 {
     $count = Comment::destroy(Input::get('id'));
     if ($count > 0) {
         $success = true;
         $message = 'Comment Deleted';
         $status = parent::MESSAGE_SUCCESS;
     } else {
         $success = false;
         $message = 'There was a problem removing the comment...';
         $status = parent::MESSAGE_ERROR;
     }
     $returnData = ['success' => $success, 'message' => $message, 'status' => $status];
     if ($Request->ajax()) {
         return Response::json($returnData);
     }
     return Redirect::back()->with($returnData);
 }
コード例 #3
0
 public function scheduleAutolikesOrders($orderDetails)
 {
     $orderModel = new Order();
     $objCommentModel = new Comment();
     $objIinstagramAPI = new API\InstagramAPI\Instagram();
     $whereIn = implode(',', array_unique(array_map(function ($order) {
         return $order->order_id;
     }, $orderDetails)));
     $queryResult = $orderModel->updateOrder(['rawQuery' => 'order_id IN(' . $whereIn . ')'], ['cronjob_status' => 0]);
     // replace with cronjob_status=1
     //        dd($orderDetails);
     try {
         foreach ($orderDetails as $autolikesOrder) {
             //                dd($autolikesOrder->start_time);
             $data1['order_message'] = 'This order is in process. Please wait for sometime to finish it.';
             $quantityTotal = $autolikesOrder->quantity_total;
             $minQuantity = $autolikesOrder->min_quantity;
             $startTime = $autolikesOrder->start_time;
             $amountPerRun = intval($autolikesOrder->orders_per_run) > 0 ? $autolikesOrder->orders_per_run : $quantityTotal;
             $timeInterval = intval($autolikesOrder->time_interval) > 0 ? $autolikesOrder->time_interval : 0;
             $userData = [];
             //            dd($order);
             if ($autolikesOrder->plan_type == 0) {
                 // for likes
                 $tempQuantityTotal = $quantityTotal;
                 //                    dd($minQuantity);
                 while ($tempQuantityTotal - $amountPerRun >= $minQuantity) {
                     $queryResult1 = $this->addScheduleOrderToProcessOrder($autolikesOrder->order_id, $autolikesOrder->supplier_server_id, $autolikesOrder->plan_name_code, $autolikesOrder->plan_type, $autolikesOrder->ins_url, $amountPerRun, $startTime);
                     $tempQuantityTotal = $tempQuantityTotal - $amountPerRun;
                     $startTime = $startTime + $timeInterval;
                 }
                 if ($tempQuantityTotal >= $minQuantity) {
                     $queryResult1 = $this->addScheduleOrderToProcessOrder($autolikesOrder->order_id, $autolikesOrder->supplier_server_id, $autolikesOrder->plan_name_code, $autolikesOrder->plan_type, $autolikesOrder->ins_url, $tempQuantityTotal, $startTime);
                 }
                 if ($queryResult1) {
                     $data1['status'] = 1;
                     $queryResult = $orderModel->updateOrder(['rawQuery' => 'order_id=?', 'bindParams' => [$autolikesOrder->order_id]], $data1);
                 }
             } elseif ($autolikesOrder->plan_type == 2) {
                 // for random comment
                 $queryResult1 = $this->addScheduleOrderToProcessOrder($autolikesOrder->order_id, $autolikesOrder->supplier_server_id, $autolikesOrder->plan_name_code, $autolikesOrder->plan_type, $autolikesOrder->ins_url, $autolikesOrder->quantity_total, $autolikesOrder->start_time);
                 if ($queryResult1) {
                     $data1['status'] = 1;
                     $queryResult = $orderModel->updateOrder(['rawQuery' => 'order_id=?', 'bindParams' => [$autolikesOrder->order_id]], $data1);
                 }
             } elseif ($autolikesOrder->plan_type == 3) {
                 // for custom comment
                 $whereCommentId = ['rawQuery' => 'comment_id=?', 'bindParams' => [$autolikesOrder->comment_id]];
                 $commentListData = $objCommentModel->getCommentList($whereCommentId, ['comments']);
                 $customCommentlist = json_decode($commentListData->comments, true);
                 $commentList = array();
                 $quantityTotal = $autolikesOrder->quantity_total;
                 //                dd($customCommentlist);
                 $commentsCount = count($customCommentlist);
                 if ($commentsCount > $quantityTotal) {
                     for ($i = 0; $i < $quantityTotal; $i++) {
                         $commentList[$i] = $customCommentlist[rand(0, $commentsCount - 1)];
                         for ($j = 0; $j < $i; $j++) {
                             if ($commentList[$j] == $commentList[$i]) {
                                 $i--;
                                 break;
                             }
                         }
                     }
                 } else {
                     for ($i = 0, $j = 0; $i < $quantityTotal; $i++, $j++) {
                         if ($j >= $commentsCount) {
                             $j = 0;
                         }
                         $commentList[$i] = $customCommentlist[$j];
                     }
                 }
                 //                $commentList = json_encode($commentList, true);
                 //                dd($commentList);
                 //                for ($i = 0; $i < $quantityTotal; $i++) {
                 //                    $commentList[] = $customCommentlist[rand(0, (count($customCommentlist) - 1))];
                 //                    for ($j = 0; $j < $i; $j++) {
                 //                        while ($commentList[$j] == $commentList[$i]) {
                 //                            $commentList[$i] = $customCommentlist[rand(0, (count($customCommentlist) - 1))];
                 //                            $j = 0;
                 //                        }
                 //                    }
                 //                }
                 $commentList = json_encode($commentList, true);
                 $queryResult1 = $this->addScheduleOrderToProcessOrder($autolikesOrder->order_id, $autolikesOrder->supplier_server_id, $autolikesOrder->plan_name_code, $autolikesOrder->plan_type, $autolikesOrder->ins_url, $autolikesOrder->quantity_total, $autolikesOrder->start_time, $commentList);
                 if ($queryResult1) {
                     $data1['status'] = 1;
                     $queryResult = $orderModel->updateOrder(['rawQuery' => 'order_id=?', 'bindParams' => [$autolikesOrder->order_id]], $data1);
                 }
             } elseif ($autolikesOrder->plan_type == 4) {
                 // for views
                 $queryResult1 = $this->addScheduleOrderToProcessOrder($autolikesOrder->order_id, $autolikesOrder->supplier_server_id, $autolikesOrder->plan_name_code, $autolikesOrder->plan_type, $autolikesOrder->ins_url, $autolikesOrder->quantity_total, $autolikesOrder->start_time);
                 if ($queryResult1) {
                     $data1['status'] = 1;
                     $queryResult = $orderModel->updateOrder(['rawQuery' => 'order_id=?', 'bindParams' => [$autolikesOrder->order_id]], $data1);
                 }
             }
             //            dd($autolikesOrder);
         }
     } catch (Exception $e) {
         echo $e->getMessage();
         $queryResult = $orderModel->updateOrder(['rawQuery' => 'order_id IN(' . $whereIn . ')'], ['cronjob_status' => 0]);
         // replace with cronjob_status=1
     }
     //        dd($orderDetails);
 }
コード例 #4
0
 public function getIndex()
 {
     $data = [];
     $authUser = Auth::user();
     $data['authId'] = $authUser->id;
     $data['wardId'] = $authUser->ward_id;
     $data['companionship'] = Companionship::where('ht_one_id', '=', $data['authId'])->orWhere('ht_two_id', '=', $data['authId'])->first();
     $data['allFamilies'] = [];
     if (!empty($data['companionship'])) {
         if ($data['companionship']->ht_one_id == $data['authId']) {
             $data['companion'] = Member::find($data['companionship']->ht_two_id);
         } else {
             $data['companion'] = Member::find($data['companionship']->ht_one_id);
         }
         $data['allFamilies'] = CompanionshipFamily::where('companionship_id', '=', $data['companionship']->id)->get();
     }
     if (!empty($data['companion'])) {
         $data['companionName'] = $data['companion']->first_name . ' ' . $data['companion']->last_name;
         $data['companionPhone'] = $data['companion']->phone;
     }
     $data['numFamilies'] = count($data['allFamilies']);
     $data['totalVisitCount'] = 0;
     if ($data['numFamilies'] > 0) {
         foreach ($data['allFamilies'] as $key => $family) {
             $count = 0;
             $familyData =& $data['myFamilies'][$key];
             $familyData['family'] = Member::find($family['member_id']);
             $familyData['visitMonth'] = [];
             $familyData['visitMonthYes'] = [];
             $familyData['visitMonthNo'] = [];
             $visits = CompanionshipVisit::where('member_id', '=', $family['member_id'])->where('visit_year', '=', date('Y'))->get();
             foreach ($visits as $visit) {
                 $familyData['visitMonth'][] = $visit->visitMonth;
                 if ($visit->visited === 'yes') {
                     $familyData['visitMonthYes'][] = $visit->visitMonth;
                     ++$count;
                 } else {
                     $familyData['visitMonthNo'][] = $visit->visitMonth;
                 }
             }
             $familyData['visitCount'] = $count;
             $data['totalVisitCount'] += $familyData['visitCount'];
             $familyData['comments'] = Comment::whereHas('companionship', function ($query) use($data) {
                 $query->where('ht_one_id', '=', $data['authId'])->orWhere('ht_two_id', '=', $data['authId']);
             })->where('family_id', '=', $family['member_id'])->get();
         }
     }
     $data['months'] = ['Jan' => 'January', 'Feb' => 'February', 'Mar' => 'March', 'Apr' => 'April', 'May' => 'May', 'Jun' => 'June', 'Jul' => 'July', 'Aug' => 'August', 'Sep' => 'September', 'Oct' => 'October', 'Nov' => 'November', 'Dec' => 'December'];
     $compMemberRow = CompanionshipFamily::where('member_id', '=', $data['authId'])->first();
     $data['myHomeTeachers'] = [];
     if ($compMemberRow) {
         $compRow = Companionship::where('id', '=', $compMemberRow->companionship_id)->first();
         $data['numHomeTeachers'] = 0;
         if (!empty($compRow->ht_one_id)) {
             $data['myHomeTeachers'][1] = Member::find($compRow->ht_one_id);
             ++$data['numHomeTeachers'];
         }
         if (!empty($compRow->ht_two_id)) {
             $data['myHomeTeachers'][2] = Member::find($compRow->ht_two_id);
             ++$data['numHomeTeachers'];
         }
     }
     $data['year'] = date('Y');
     return view('dashboard', $data);
 }