ajax() public static method

Determine if the request is the result of an AJAX call.
public static ajax ( ) : boolean
return boolean
 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;
             }
         }
     }
 }
Example #2
0
 public function getTagPosts($name)
 {
     try {
         $tag = Tag::where('name', $name)->first();
         if (!$tag) {
             throw new Exception("Tag not found");
         }
         $posts = $tag->posts()->paginate(8);
         $i = 0;
         foreach ($posts as $post) {
             if (!PrivacyHelper::checkPermission(Auth::user(), $post)) {
                 unset($posts[$i]);
                 $i++;
                 continue;
             }
             $i++;
             $post->makrdown = str_limit($post->makrdown, $limit = 500, $end = '...');
             $Parsedown = new Parsedown();
             $post->HTML = $Parsedown->text($post->makrdown);
         }
         if (Request::ajax()) {
             return View::make('posts._list')->with('data', $posts);
         } else {
             if (count($posts) == 0) {
                 return Redirect::intended(URL::action('ProfileController@getProfile', array($id)));
             }
             $this->layout->content = View::make('posts.list')->with('data', $posts);
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
 public function login_post()
 {
     if (!Request::ajax()) {
         App::abort('401');
     }
     $data = array('status' => 'success', 'message' => '');
     try {
         // Set login credentials
         $credentials = array('email' => Input::get('email'), 'password' => Input::get('password'));
         $remember = Input::get('remember') ? Input::get('remember') : false;
         // Try to authenticate the user
         $user = Sentry::authenticate($credentials, $remember);
         $data['status'] = 'success';
         $data['message'] = 'Login Success. Redirecting';
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         $data['status'] = 'error';
         $data['message'] = 'Login field is required.';
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         $data['status'] = 'error';
         $data['message'] = 'Password field is required.';
     } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
         $data['status'] = 'error';
         $data['message'] = 'Wrong password, try again.';
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         $data['status'] = 'error';
         $data['message'] = 'User was not found.';
     } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         $data['status'] = 'error';
         $data['message'] = 'User is not activated.';
     }
     $response = Response::make(json_encode($data), 200);
     $response->header('Content-Type', 'text/json');
     return $response;
 }
 /**
  * function name: paymentRequest
  * @return mixed
  */
 public function paymentRequest($status = '', $page = 1)
 {
     $paymentReq = new PaymentRequestBaseModel();
     $options = array('status' => $status);
     $this->data['status'] = $status;
     $publisher = Input::has('publisher') ? Input::get('publisher') : '';
     $month = Input::has('month') ? Input::get('month') : 0;
     $year = Input::has('year') ? Input::get('year') : 0;
     $field = Input::has('field') ? Input::get('field') : '';
     $order = Input::has('order') ? Input::get('order') : '';
     $options['publisher'] = $publisher;
     $options['month'] = $month;
     $options['year'] = $year;
     $options['field'] = $field;
     $options['order'] = $order;
     $items = $paymentReq->getItems('', ITEM_PER_PAGE, $page, $options);
     $dataPaging['items'] = $items;
     $dataPaging['options'] = array('publisher' => $publisher, 'month' => $month, 'year' => $year, 'field' => $field, 'order' => $order);
     $dataPaging['total'] = $paymentReq->sumAmountPublisher($options);
     if (Request::ajax()) {
         return View::make('publisher_manager.approve_tools_publisher_manager.paymentRequestPaging', $dataPaging);
     } else {
         $this->data['listItems'] = View::make('publisher_manager.approve_tools_publisher_manager.paymentRequestPaging', $dataPaging);
     }
     $this->layout->content = View::make('publisher_manager.approve_tools_publisher_manager.paymentRequest', $this->data);
 }
Example #5
0
 public function postLogin()
 {
     if (Request::ajax()) {
         $userdata = array('usuario' => Input::get('usuario'), 'password' => Input::get('password'));
         if (Auth::attempt($userdata, Input::get('remember', 0))) {
             //buscar los permisos de este usuario y guardarlos en sesion
             $query = "SELECT m.nombre as modulo, s.nombre as submodulo,\n                        su.agregar, su.editar, su.eliminar,\n                        CONCAT(m.path,'.', s.path) as path, m.icon\n                        FROM modulos m \n                        JOIN submodulos s ON m.id=s.modulo_id\n                        JOIN submodulo_usuario su ON s.id=su.submodulo_id\n                        WHERE su.estado = 1 AND m.estado = 1 AND s.estado = 1\n                        and su.usuario_id = ?\n                        ORDER BY m.nombre, s.nombre ";
             $res = DB::select($query, array(Auth::id()));
             $menu = array();
             $accesos = array();
             foreach ($res as $data) {
                 $modulo = $data->modulo;
                 //$accesos[] = $data->path;
                 array_push($accesos, $data->path);
                 if (isset($menu[$modulo])) {
                     $menu[$modulo][] = $data;
                 } else {
                     $menu[$modulo] = array($data);
                 }
             }
             $usuario = Usuario::find(Auth::id());
             Session::set('language', 'Español');
             Session::set('language_id', 'es');
             Session::set('menu', $menu);
             Session::set('accesos', $accesos);
             Session::set('perfilId', $usuario['perfil_id']);
             Session::set("s_token", md5(uniqid(mt_rand(), true)));
             Lang::setLocale(Session::get('language_id'));
             return Response::json(array('rst' => '1', 'estado' => Auth::user()->estado));
         } else {
             $m = '<strong>Usuario</strong> y/o la <strong>contraseña</strong>';
             return Response::json(array('rst' => '2', 'msj' => 'El' . $m . 'son incorrectos.'));
         }
     }
 }
 public function clearAll()
 {
     $this->notificationRepository->clearAll();
     if (!\Request::ajax()) {
         return \Redirect::to(\URL::previous());
     }
 }
 public function getGrafico2()
 {
     if (Request::ajax()) {
         $resultados = Proyecto::getResultados2();
         return Response::Json($resultados);
     }
 }
 public static function errors($code = 404, $title = '', $message = '')
 {
     $ajax = Request::ajax();
     if (!$code) {
         $code = 500;
         $title = 'Internal Server Error';
         $message = 'We got problems over here. Please try again later!';
     } else {
         if ($code == 404) {
             $title = 'Oops! You\'re lost.';
             $message = 'We can not find the page you\'re looking for.';
         }
     }
     if (Request::ajax()) {
         return Response::json(['error' => ['message' => $message]], $code);
     }
     $arrData = [];
     $arrData['content'] = View::make('frontend.errors.error')->with(['title' => $title, 'code' => $code, 'message' => $message]);
     $arrData['metaInfo'] = Home::getMetaInfo();
     $arrData['metaInfo']['meta_title'] = $title;
     $arrData['types'] = Home::getTypes();
     $arrData['categories'] = Home::getCategories();
     $arrData['headerMenu'] = Menu::getCache(['header' => true]);
     return View::make('frontend.layout.default')->with($arrData);
 }
Example #9
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = $this->validate();
     if ($validator->fails()) {
         if (Request::ajax()) {
             return Response::json(array('success' => false, 'messages' => $validator->messages()));
         }
         return Redirect::back()->withErrors($validator->messages())->withInput(Input::all());
     }
     $donor = new Donor();
     $donor->name = Input::get('name');
     $donor->dob = Input::get('dob');
     $donor->nic = Input::get('nic');
     $donor->gender = Input::get('gender');
     $donor->telephone = Input::get('telephone');
     $donor->blood_group_id = Input::get('blood_group_id');
     $donor->email = Input::get('email');
     $donor->address = Input::get('address');
     $donor->details = Input::get('details');
     $donor->save();
     if (Request::ajax()) {
         return Response::json(array('success' => true, 'donors' => [''] + Donor::all()->lists('name_with_blood_group', 'id'), 'donor_id' => $donor->id));
     }
     Session::flash('success', 'Successfully created donor!');
     return Redirect::route('donor.index');
 }
 public function create()
 {
     if (\Request::ajax()) {
         return response()->json(['url' => \Request::url(), 'title' => 'Contact | Jonas Vanderhaegen', 'path' => \Request::path(), 'view' => view('pages.messages.create')->render()]);
     }
     return view('pages.messages.create');
 }
 public function signup()
 {
     if (!Allow::enabled_module('users')) {
         return App::abort(404);
     }
     $json_request = array('status' => FALSE, 'responseText' => '', 'responseErrorText' => '', 'redirect' => FALSE);
     if (Request::ajax()) {
         $validator = Validator::make(Input::all(), User::$rules);
         if ($validator->passes()) {
             $account = User::where('email', Input::get('email'))->first();
             if (is_null($account)) {
                 if ($account = self::getRegisterAccount(Input::all())) {
                     if (Allow::enabled_module('downloads')) {
                         if (!File::exists(base_path('usersfiles/account-') . $account->id)) {
                             File::makeDirectory(base_path('usersfiles/account-') . $account->id, 777, TRUE);
                         }
                     }
                     Mail::send('emails.auth.signup', array('account' => $account), function ($message) {
                         $message->from('*****@*****.**', 'Monety.pro');
                         $message->to(Input::get('email'))->subject('Monety.pro - регистрация');
                     });
                     $json_request['responseText'] = 'Вы зарегистрированы. Мы отправили на email cсылку для активации аккаунта.';
                     $json_request['status'] = TRUE;
                 }
             } else {
             }
         } else {
             $json_request['responseText'] = 'Неверно заполнены поля';
             $json_request['responseErrorText'] = $validator->messages()->all();
         }
     } else {
         return App::abort(404);
     }
     return Response::json($json_request, 200);
 }
Example #12
0
 public function post_ban()
 {
     if (Request::ajax()) {
         $error = '';
         $get = Input::all();
         $banUsername = $get['bUsername'];
         $banReason = $get['bReason'];
         $user = User::where('username', '=', $banUsername)->first();
         // belki kullanıcı zaten banlı olabilir.admin değğilse tekrar banlayamasın
         if ($user->username == Sentry::user()->username) {
             $error = 'Lütfen kendinizi banlamayınız.';
             die("ban");
         }
         $ban = $user->bans()->first();
         // Kullanıcı Zaten Banlıysa,bitiş tarihini geri döndür.
         if ($ban) {
             die($ban->ban_end);
         }
         // Güvenlik Koaaaaaaaaaaaaaaaaaaaaaaaaantrolü
         $date = date('Y-m-d H:i:s');
         $bandate = date('Y-m-d H:i:s', strtotime('+1 day', strtotime($date)));
         $banData = Ban::create(array('user_id' => $user->id, 'ban_ip' => $user->ip_address, 'ban_email' => $user->user_email, 'ban_start' => $date, 'ban_end' => $bandate, 'ban_reason' => $banReason, 'ban_moderatorid' => Sentry::user()->id));
         die("OK");
     }
 }
Example #13
0
 public function index()
 {
     if (\Request::ajax()) {
         return Post::all();
     }
     return view('post.index');
 }
 public function getdates()
 {
     if (\Request::ajax()) {
         $user_id = \Auth::user()->id;
         $ann_scol = \Input::get('ann_scol');
         $type = \Input::get('type');
         $checkYear = SchoolYear::where('user_id', $user_id)->where('ann_scol', $ann_scol)->where('type', $type)->first();
         if ($checkYear) {
             echo json_encode($checkYear);
             die;
         } else {
             /*
                            $tab = [
                                 'startch1'=> '',
                                'endch1' => '',
                                'startch2' => '',
                                'endch2' => '',
             
                             ];*/
             $tab = [];
             echo json_encode($tab);
             die;
         }
     }
 }
Example #15
0
 public function index()
 {
     if (\Request::ajax()) {
         return User::all();
     }
     return view('user.index');
 }
 public function __construct()
 {
     parent::__construct();
     $db = Config::get('database.default');
     if ($db != null) {
         View::share('navLinks', Admin_Menu::menuGenerator());
         View::share('sidebar', Navigator::sidebar());
         View::share('breadcrumb', Navigator::breadcrumb());
     }
     $class = get_called_class();
     if (!Request::ajax()) {
         switch ($class) {
             case 'Home_Controller':
                 $this->filter('before', 'nonauth');
                 break;
             case 'Setup_Controller':
                 $this->filter('before', 'nonauth');
                 break;
             case 'Admin_Auth_Controller':
                 $this->filter('before', 'auth')->except(array('authenticate', 'verifyupdate', 'logout'));
                 break;
             default:
                 $this->filter('before', 'auth');
                 break;
         }
     }
 }
Example #17
0
 function traitEntityAdd()
 {
     //соберем форму
     $this->traitEntityAdd_formBuild();
     $this->traitEntityAdd_formBuildAfter();
     /** @var Model $model_class */
     $model_class = static::getClassModel();
     if ($this->form->isSubmitted()) {
         $validator = $model_class::getDataValidator($this->form->getValue(), $this->form);
         if ($validator->validate()) {
             //запись успешно сохранена
             $this->traitEntity_save($validator);
             //выведем сообщение об успешной вставке
             return $this->traitEntityAdd_success();
         } else {
             //                dd($validator->getErrors());
             \Debugbar::addMessage($validator->getErrors());
             $this->form->setErrors($validator->getErrors());
         }
     } else {
         $fill_labels = $this->model->getFillable();
         foreach ($fill_labels as $fillable) {
             if (null !== \Input::get($fillable)) {
                 $this->form->initValues([$fillable => \Input::get($fillable)]);
             }
         }
     }
     //форма показана в первый раз или с ошибками
     if (\Request::ajax()) {
         return $this->traitEntityAddJson();
     } else {
         return $this->traitEntityAddHtml();
     }
 }
 public function profileSave()
 {
     $json_request = array('status' => FALSE, 'responseText' => '', 'redirectURL' => FALSE);
     $validator = Validator::make(Input::all(), Accounts::$update_rules);
     if ($validator->passes()) {
         $post = Input::all();
         if (self::accountUpdate($post)) {
             $result = self::crmAccountUpdate($post);
             if ($result === -1) {
                 Auth::logout();
                 $json_request['responseText'] = Config::get('api.message');
                 $json_request['redirectURL'] = pageurl('auth');
                 return Response::json($json_request, 200);
             }
             $json_request['redirectURL'] = URL::route('dashboard');
             $json_request['responseText'] = Lang::get('interface.DEFAULT.success_save');
             $json_request['status'] = TRUE;
         } else {
             $json_request['responseText'] = Lang::get('interface.DEFAULT.fail');
         }
     } else {
         $json_request['responseText'] = $validator->messages()->all();
     }
     if (Request::ajax()) {
         return Response::json($json_request, 200);
     } else {
         return Redirect::route('dashboard');
     }
 }
 /**
  * Delete prediction action
  * @return string
  */
 public function delete()
 {
     $response = array('success' => false);
     if (Request::ajax()) {
         $predictionIds = Input::get('predictionIds');
         $tabletId = null;
         if ($predictionIds) {
             $predictionIdsArray = $this->_getPredictionIdsArray($predictionIds);
             foreach ($predictionIdsArray as $predictionId) {
                 $prediction = Prediction::find($predictionId);
                 if (!$tabletId) {
                     $tablet = Tablet::find($prediction->tablet_id);
                 }
                 $predictionExpenses = $prediction->expenses;
                 foreach ($predictionExpenses as $expense) {
                     $tablet->total_expenses = $tablet->total_expenses - $expense->value;
                     $tablet->current_sum = $tablet->current_sum + $expense->value;
                 }
                 $tablet->save();
             }
             Prediction::destroy($predictionIdsArray);
             $response['success'] = true;
         }
     }
     return Response::json($response);
 }
Example #20
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     // HTTP STATUS CODE 400
     if ($e instanceof BadRequestHttpException) {
         if (\Request::ajax()) {
             return \Response::json(['status' => '400', 'message' => 'Bad Request']);
         }
     }
     // HTTP STATUS CODE 401
     if ($e instanceof UnauthorizedHttpException) {
         if (\Request::ajax()) {
             return \Response::json(['status' => '401', 'message' => 'Unauthorized']);
         }
     }
     // HTTP STATUS CODE 403
     if ($e instanceof AccessDeniedHttpException) {
         if (\Request::ajax()) {
             return \Response::json(['status' => '403', 'message' => 'Forbidden']);
         }
     }
     // HTTP STATUS CODE 404
     if ($e instanceof ModelNotFoundException || $e instanceof NotFoundHttpException) {
         if (\Request::ajax()) {
             return \Response::json(['status' => '404', 'message' => 'Not Found']);
         }
         $e = new NotFoundHttpException($e->getMessage(), $e);
     }
     // else HTTP STATUS CODE 500
     if (\Request::ajax()) {
         return \Response::json(['status' => '500', 'message' => 'Internal Server Error']);
     }
     return parent::render($request, $e);
 }
 public function postFacturas()
 {
     date_default_timezone_set('America/Caracas');
     //comprobamos si es una petición ajax
     if (Request::ajax()) {
         //validamos el formulario
         $registerData = array('factura' => Input::get('factura'), 'fecha_fac' => Input::get('fecha_fac'), 'n_factura' => Input::get('n_factura'), 'n_control' => Input::get('n_control'), 'n_nota_debito' => Input::get('n_nota_debito'), 'n_nota_credito' => Input::get('n_nota_credito'), 'tipo_transa' => Input::get('tipo_transa'), 'n_fact_ajustada' => Input::get('n_fact_ajustada'), 'total_compra' => Input::get('total_compra'), 'exento' => Input::get('exento'), 'base_imp' => Input::get('base_imp'), 'iva' => Input::get('iva'), 'impuesto_iva' => Input::get('impuesto_iva'), 'iva_retenido' => Input::get('iva_retenido'), 'id_proveedor' => Input::get('id_proveedor'), 'id_user' => Input::get('id_user'), 'update_user' => Input::get('update_user'), 'id_reporte' => Input::get('id_reporte'));
         $rules = array('factura' => 'unique:facturas', 'fecha_fac' => 'required', 'n_factura' => '', 'n_control' => 'required', 'n_nota_debito' => '', 'n_nota_credito' => '', 'tipo_transa' => 'required', 'n_fact_ajustada' => '', 'total_compra' => 'required|numeric', 'exento' => 'numeric', 'base_imp' => 'numeric', 'iva' => '', 'impuesto_iva' => 'numeric', 'iva_retenido' => 'numeric', 'id_user' => '', 'update_user' => '', 'id_reporte' => '');
         $messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :max carácteres.', 'unique' => 'La factura ingresada ya está agregada en la base de datos.', 'confirmed' => 'Los passwords no coinciden.');
         $validation = Validator::make(Input::all(), $rules, $messages);
         //si la validación falla redirigimos al formulario de registro con los errores
         if ($validation->fails()) {
             //como ha fallado el formulario, devolvemos los datos en formato json
             //esta es la forma de hacerlo en laravel, o una de ellas
             return Response::json(array('success' => false, 'errors' => $validation->getMessageBag()->toArray()));
             //en otro caso ingresamos al usuario en la tabla usuarios
         } else {
             //creamos un nuevo usuario con los datos del formulario
             $content = new Factura($registerData);
             $content->save();
             //si se realiza correctamente la inserción envíamos un mensaje
             //conforme se ha registrado correctamente
             if ($content) {
                 $facturas = DB::table('facturas')->get();
                 return Response::json(array('success' => true, 'message' => "<h3></h3>", 'facturas' => $facturas));
             }
         }
     }
 }
Example #22
0
 /**
  * @return mixed
  */
 public function ajaxLogin()
 {
     if (Request::ajax()) {
         $output = [];
         $input = Input::all();
         $data = ['email' => $input['email'], 'password' => $input['password'], 'estado' => 'activo'];
         //Reglas de los Campos de Email y Password
         $rules = ['email' => 'required|email', 'password' => 'required'];
         $validator = Validator::make($input, $rules);
         //Verificacion previa de los campos, antes de la Autenticacion
         if ($validator->fails()) {
             $output['status'] = 'error';
             $output['msg'] = $validator->getMessageBag()->toArray();
         }
         $data = ['email' => $input['email'], 'password' => $input['password'], 'estado' => 'activo'];
         // Check if  exists in database with the credentials of not
         if (Auth::personales()->attempt($data)) {
             $event = Event::fire('auth.login', Auth::personales()->get());
             $output['status'] = 'success';
             $output['msg'] = Lang::get('messages.loginSuccess');
             return Response::json($output, 200);
         }
         // For Blocked Users
         $data['estado'] = 'inactive';
         if (Auth::personales()->validate($data)) {
             $output['status'] = 'error';
             $output['msg'] = ['error' => Lang::get('messages.loginBlocked')];
         } else {
             $output['status'] = 'error';
             $output['msg'] = ['error' => Lang::get('messages.loginInvalid')];
         }
         return Response::json($output, 200);
     }
 }
Example #23
0
 public static function autoResponse($url = 'back', $statut = 'error', $message = '', $options = array())
 {
     if (Request::ajax()) {
         $data = array();
         // Options
         if (!empty($options)) {
             $data = $options;
         }
         // Statut
         if ($statut == 'error') {
             $statut = 'danger';
         }
         $data['statut'] = $statut;
         $data['message'] = $message;
         // Response
         return Response::json($data);
     } else {
         if ($url == 'back') {
             if ($statut == 'validator') {
                 return Redirect::back()->withInput()->withErrors($message);
             } else {
                 return Redirect::back()->with($statut, $message);
             }
         } else {
             if ($statut == 'validator') {
                 return Redirect::to($url)->withInput()->withErrors($message);
             } else {
                 return Redirect::to($url)->with($statut, $message);
             }
         }
     }
 }
 /**
  * Create income action
  * @return json
  */
 public function create()
 {
     $response = array('success' => false);
     if (Request::ajax()) {
         $postData = Input::all();
         $tabletId = $postData['tabletId'];
         $incomeValue = (double) $postData['incomeValue'];
         $rules = array('tabletId' => array('required', 'not_in:0', 'exists:tablets,id'), 'incomeValue' => array('required', 'numeric', 'min:0'));
         $messages = array('tabletId.required' => 'Please select a tablet.', 'tabletId.not_in' => 'Please select a tablet.', 'tabletId.exists' => 'An error occured. Please try later.', 'incomeValue.required' => 'Please enter income value.', 'incomeValue.numeric' => 'Income must be a numeric value. Ex: 90, 3.42', 'incomeValue.min' => 'Income must have a positive value.');
         $validator = Validator::make($postData, $rules, $messages);
         if ($validator->fails()) {
             $messages = $validator->messages();
             $response['tabletMsg'] = $messages->first('tabletId');
             $response['incomeValueMsg'] = $messages->first('incomeValue');
             return Response::json($response);
         }
         $tablet = Tablet::find($tabletId);
         if ($tablet->id) {
             $initialIncomeValue = (double) $tablet->total_amount;
             $tablet->total_amount = $initialIncomeValue + $incomeValue;
             $tablet->save();
             $response['success'] = true;
             Event::fire('income.create.success', array($incomeValue, $tabletId));
         }
     }
     return Response::json($response);
 }
 public function loadFeaturedCollections($type_id)
 {
     $data = Collection::getFrontend($type_id);
     $arrFeaturedCollection = array();
     foreach ($data as $value) {
         $width = $height = 0;
         $path = '/assets/images/noimage/315x165.gif';
         if (!empty($value['image'])) {
             if ($value['image']['ratio'] > 1) {
                 $width = 450;
                 $height = $width / $value['image']['ratio'];
             } else {
                 $height = 450;
                 $width = $height * $value['image']['ratio'];
             }
             $path = '/pic/newcrop/' . $value['image']['short_name'] . '-' . $value['image']['id'] . '.jpg';
         }
         $arrFeaturedCollection[] = ['collection_id' => $value['id'], 'collection_name' => $value['name'], 'collection_short_name' => $value['short_name'], 'width' => $width, 'height' => $height, 'path' => $path];
     }
     if (Request::ajax()) {
         $html = View::make('frontend.types.featured-collections')->with('arrFeaturedCollection', $arrFeaturedCollection)->render();
         $arrReturn = ['status' => 'ok', 'message' => '', 'html' => $html];
         $response = Response::json($arrReturn);
         $response->header('Content-Type', 'application/json');
         return $response;
     }
     return View::make('frontend.types.featured-collections')->with('arrFeaturedCollection', $arrFeaturedCollection)->render();
 }
 public function ajax()
 {
     if (Request::ajax()) {
         $post = Input::all();
         if (isset($post['action']) && !empty($post['action'])) {
             switch ($post['action']) {
                 case 'service-add':
                     $data = array('business_id' => Auth::user()->business->id, 'name' => $post['service_name']);
                     $group = ServiceGroup::create($data);
                     $group['business_id'] = Auth::user()->business->id;
                     echo View::make('business::ajax.new_group', $group);
                     exit;
                     break;
                 case 'remove-salon-image':
                     $key = $post['key'];
                     echo Auth::user()->business->remove_extra_image($key);
                     exit;
                     break;
                 default:
                     # code...
                     break;
             }
         }
     }
 }
Example #27
0
 public function destroy($id)
 {
     if (\Request::ajax()) {
         $db = Outbox::destroy($id);
         return $db;
     }
 }
 public function postEditar()
 {
     if (Request::ajax()) {
         $usurioid = Input::get('id');
         $tipopersona = Input::get('tipo_persona');
         $usuario['usuario_updated_at'] = Auth::user()->id;
         $usuario = Usuario::find(Auth::user()->id);
         $perfilId = $usuario['perfil_id'];
         $data2 = array(Auth::user()->id, $usurioid, $tipopersona);
         $desactivardata = PermisoEventos::getDesactivarpermisos($data2);
         $metodo = Input::get('metodo');
         for ($i = 0; $i < count($metodo); $i++) {
             $metodoId = $metodo[$i];
             $data = array($metodoId, $usurioid, $tipopersona, '2', $usuario['usuario_updated_at'], $usuario['usuario_updated_at']);
             $datos = PermisoEventos::getAgregarEvento($data);
         }
         $consulta = Input::get('consulta');
         for ($i = 0; $i < count($consulta); $i++) {
             $consultaId = $consulta[$i];
             $data = array($consultaId, $usurioid, $tipopersona, '1', $usuario['usuario_updated_at'], $usuario['usuario_updated_at']);
             $datos = PermisoEventos::getAgregarEvento($data);
         }
         return Response::json(array('rst' => 1, 'msj' => "Se modifico permisos exitosamente"));
     }
 }
 public function getClient($id)
 {
     $clients = Client::select('var_name', 'var_address', 'var_telephone', 'var_email', 'var_mobile')->where('id', '=', $id)->first();
     if (\Request::ajax()) {
         return \Response::json(['mobile' => $clients->var_mobile, 'telephone' => $clients->var_telephone, 'mail' => $clients->var_email, 'address' => $clients->var_address]);
     }
 }
 /**
  * Show the application registration form.
  *
  * @return \Illuminate\Http\Response
  */
 public function getRegister()
 {
     if (\Request::ajax()) {
         return response()->json(['locale' => session()->get('locale', 'nl'), 'url' => \Request::url(), 'title' => 'Register | De Sessie', 'type' => 'pageload', 'path' => \Request::path(), 'view' => view('auth.register')->render()]);
     }
     return view('auth.register');
 }