Ejemplo n.º 1
0
 public function errorComments(Request $request)
 {
     if ($request->ajax()) {
         $text = $request->input('text');
         $reason = $request->input('reason');
         $comment_id = $request->input('comments_id');
         $logged = null;
         if (Auth::check()) {
             $logged = Auth::user()->id;
         } else {
             if (empty($request->input('potpis'))) {
                 return response()->json(array('success' => false, 'messages' => 'Potpisi se ili se prijavi'));
             }
         }
         $rules = array('text' => 'required|max:255|min:1');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return response()->json(array('success' => false, 'messages' => 'Komentar mora biti velicine izmedju 1 i 255 karaktera'));
         }
         if (empty($logged)) {
             $name = $request->input('potpis');
             $user = User::create(array('username' => $name, 'password' => 'password', 'email' => 'email', 'type' => 'user'));
             $logged = $user->id;
         }
         $error = ErrorComment::where('user_id', '=', 1)->where('comment_id', '=', $request->input('comments_id'))->count();
         if ($error >= 2) {
             return response()->json(array('success' => false, 'messages' => 'Ovaj komnetar je vec prijavljivan 2 puta!'));
         }
         $errorComment = ErrorComment::create(array('text' => $text, 'reason' => $reason, 'user_id' => $logged, 'comment_id' => $comment_id));
         return 'text ' . $text . ' reason ' . $reason . ' logged id  ' . $logged . ' comment id ' . $comment_id . ' ' . $errorComment->id;
         //       return response()->json(array('success' => true ,'messages' => 'text ' + $text +' reason '+$reason+' logged id  '+$logged+' comment id '+ $comment_id));
     }
 }
Ejemplo n.º 2
0
 public function getErrcomments()
 {
     $errcomments = ErrorComment::all();
     return json_encode(array('value' => $errcomments));
 }