Request::ajax PHP Method

ajax() public static method

Determine if the request is the result of an AJAX call.
public static ajax ( ) : boolean
return boolean
        public static function ajax()
        {
            return \Illuminate\Http\Request::ajax();
        }

Usage Example

 public function destroy($event_id)
 {
     if (Request::ajax()) {
         //get tag_id
         if (!($tag_id = DB::table('event_tags')->where('event_id', '=', $event_id)->pluck('tag_id'))) {
             Session::put('adminDangerAlert', 'Unable to find tag ID. Contact an administrator.');
             return;
         }
         //Check if event is tagged in articles/video before deleting
         if (DB::table('article_tags')->where('tag_id', '=', $tag_id)->get() || DB::table('video_tags')->where('tag_id', '=', $tag_id)->get()) {
             Session::put('adminInfoAlert', 'You cannot delete this event because it is tagged in either an article or video.');
             return;
         } else {
             //delete article
             if ($event = $this->event->find($event_id)) {
                 $event->delete();
                 Session::put('adminSuccessAlert', 'Event deleted.');
                 return;
             } else {
                 Session::put('adminDangerAlert', 'Something went wrong attempting to delete the event.');
                 return;
             }
         }
     }
 }
All Usage Examples Of Request::ajax