/**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $commentid
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $commentid)
 {
     $reply = new \App\Reply();
     $reply->create(['user_id' => \Auth::user()->id, 'comment_id' => $request['comment_id'], 'comment' => $request['comment']]);
     $comment = \App\Comment::where(['id' => $commentid])->get()->first();
     $comment->reply = $reply;
     return redirect()->back();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $comments = \App\Comment::all();
     $fake_replies = file_get_contents("http://jsonplaceholder.typicode.com/comments");
     $fake_replies = json_decode($fake_replies, true);
     foreach ($comments as $comment) {
         if (mt_rand(0, 1)) {
             $replies = \App\Reply::where('reply_to_id', $comment->id)->get();
             if (count($replies) > 0) {
                 continue;
             } else {
                 $reply = new \App\Reply();
                 $reply->reply_to_id = $comment->id;
                 $one_reply = $fake_replies[mt_rand(0, count($fake_replies) - 1)];
                 $reply->reply_text = $one_reply['body'];
                 $reply->save();
             }
         }
     }
 }
Example #3
0
     }
     return view('booking_requests', ['properties' => $properties, 'bookings' => $bookings, 'confirmed_bookings' => $confirmed_bookings]);
 }));
 Route::get('/booking/comment/reply/{comment_id}', function ($commend_id) {
     $comment = Comment::find($commend_id);
     $property = Property::find($comment->property_id);
     $author = User::find($comment->user_id);
     return view('new_reply', ['comment' => $comment, 'property' => $property, 'author' => $author]);
 });
 Route::post('/booking/comment/reply', function (Request $request) {
     $data = $request->all();
     $validator = Validator::make($request->all(), ['comment_id' => 'required|numeric|min:1|integer']);
     if ($validator->fails()) {
         return redirect(url('/booking/comment/reply/' . $data['comment_id']))->withInput()->withErrors($validator);
     }
     $reply = new \App\Reply();
     $reply->reply_to_id = $data['comment_id'];
     $reply->reply_text = $data['reply'];
     $reply->save();
     $comment = Comment::find($data['comment_id']);
     return redirect(url('/property/' . $comment->property_id));
 });
 Route::post('/property/booking_requests/confirm', function (Request $request) {
     $data = $request->all();
     $validator = Validator::make($request->all(), ['booking_id' => 'required|numeric|min:1|integer']);
     if ($validator->fails()) {
         return redirect(url('/property/booking_requests'))->withInput()->withErrors($validator);
     }
     $booking = \App\Booking::find($data['booking_id']);
     $select_statement = 'SELECT * FROM bookings WHERE ' . "'" . $booking->start . "'" . ' <= bookings.end AND ' . "'" . $booking->end . "'" . ' >= start AND bookings.status = ' . "'" . 'requested' . "' AND bookings.id <> " . $booking->id;
     $overlapping_bookings = DB::select($select_statement);