json() public static method

Return a new JSON response from the application.
public static json ( string | array $data = [], integer $status = 200, array $headers = [], integer $options ) : Illuminate\Http\JsonResponse
$data string | array
$status integer
$headers array
$options integer
return Illuminate\Http\JsonResponse
 /**
  * Requests that a page version event's start and end times
  * be updated
  *
  * @param  int   $id
  * @param  array $input
  * @return Response
  */
 public function requestPageVersionEventUpdate($id, $input)
 {
     $start = array_get($input, 'start');
     $end = array_get($input, 'end');
     $published = array_get($input, 'published', false);
     $event = $this->PageVersionSource->updatePageVersion($id, $start, $end, $published);
     return $this->Response->json($event);
 }
Example #2
0
 public function postRestore()
 {
     // validasi
     $input = Input::all();
     $rules = array('sql' => 'required|sql');
     $validasi = Validator::make(Input::all(), $rules);
     // tidak valid
     if ($validasi->fails()) {
         // pesan
         $sql = $validasi->messages()->first('sql') ?: '';
         return Response::json(compact('sql'));
         // valid
     } else {
         // ada sql
         if (Input::hasFile('sql')) {
             // nama sql
             $sql = date('dmYHis') . '.sql';
             // unggah sql ke dir "app/storage/restores"
             Input::file('sql')->move(storage_path() . '/restores/', $sql);
             // path file
             $file = storage_path() . '/restores/' . $sql;
             // dump database
             $dump = new Dump();
             $dump->file($file)->dsn($this->dsn)->user($this->user)->pass($this->pass);
             new Import($dump);
             // hapus file restore
             unlink($file);
             // tidak ada sql
         } else {
             // pesan
             $sql = 'Sql gagal diunggah.';
             return Response::json(compact('sql'));
         }
     }
 }
 public function index()
 {
     $analytics = new Analytics();
     $statusCode = 200;
     $response = ['numTweets' => $analytics->numTweets(), 'numTweetsWithLink' => $analytics->numTweetsWithLink(), 'numTweetsTypeRT' => $analytics->numTweetsTypeRT(), 'numTimesRetweeted' => $analytics->numTimesRetweeted(), 'avgNumCharacters' => $analytics->avgNumCharacters()];
     return \Response::json($response, $statusCode);
 }
Example #4
0
 /**
  * Create a Job
  * @return \Illuminate\Http\JsonResponse
  */
 public function create()
 {
     Log::info(\Input::all());
     $inputdata = \Input::all();
     $success = false;
     $inputdata["mandate_start"] = strtotime($inputdata["mandate_start"]);
     $inputdata["mandate_end"] = strtotime($inputdata["mandate_end"]);
     $inputdata["date_of_entry"] = strtotime($inputdata["date_of_entry"]);
     if ($this->validator->validate(\Input::all())) {
         $job = Job::create($inputdata);
         if (\Input::has('skills')) {
             $skills = [];
             foreach (\Input::get('skills') as $skill) {
                 $skills[$skill['skill_id']] = ['description' => isset($skill['description']) ? $skill['description'] : '', 'level' => isset($skill['level']) ? $skill['level'] : 0];
             }
             $job->skills()->attach($skills);
         }
         if (\Input::get('agent_id')) {
             $agent = Agent::find(\Input::get('agent_id'));
             // $job->agents()->attach($agent->user_id);
             $job->agent_id = $agent->user_id;
         }
     }
     $success = $job == true;
     return \Response::json(['success' => $success]);
 }
 /**
  * Saves user submissions for Independent Sponsor requests.
  */
 public function putRequest()
 {
     //Validate input
     $rules = array('address1' => 'required', 'city' => 'required', 'state' => 'required', 'postal_code' => 'required', 'phone' => 'required');
     $validation = Validator::make(Input::all(), $rules);
     if ($validation->fails()) {
         return Response::json($this->growlMessage($validation->messages()->all(), 'error'), 400);
     }
     //Add new user information to their record
     $user = Auth::user();
     $user->address1 = Input::get('address1');
     $user->address2 = Input::get('address2');
     $user->city = Input::get('city');
     $user->state = Input::get('state');
     $user->postal_code = Input::get('postal_code');
     $user->phone = Input::get('phone');
     $user->save();
     if (!$user->getSponsorStatus()) {
         //Add UserMeta request
         $request = new UserMeta();
         $request->meta_key = UserMeta::TYPE_INDEPENDENT_SPONSOR;
         $request->meta_value = 0;
         $request->user_id = $user->id;
         $request->save();
     }
     return Response::json();
 }
 public function postTerminal()
 {
     if (\Request::ajax()) {
         $terminal_password = \Config::get('laraedit::laraedit.terminal.password');
         $command = '';
         if (!empty($_POST['command'])) {
             $command = $_POST['command'];
         }
         if (strtolower($command == 'exit')) {
             \Session::put('term_auth', false);
             $output = '[CLOSED]';
         } else {
             if (\Session::get('term_auth') !== true) {
                 if ($command == $terminal_password) {
                     \Session::put('term_auth', true);
                     $output = '[AUTHENTICATED]';
                 } else {
                     $output = 'Enter Password:'******'';
                 $command = explode("&&", $command);
                 foreach ($command as $c) {
                     $Terminal->command = $c;
                     $output .= $Terminal->Process();
                 }
             }
         }
         return \Response::json(htmlentities($output));
     }
 }
Example #7
0
 public function getVentas()
 {
     $fecha = Input::get('fecha');
     $detallescaja = Detallecaja::whereBetween('fechainicio', [$fecha . ' 00:00:00', $fecha . ' 23:59:59'])->with(['ventas', 'ventas.alquiler', 'ventas.alquiler.habitacion', 'ventas.productos', 'usuario'])->get();
     return Response::json($detallescaja);
     //return View::make('reportes.ventas', compact('detallescaja'));
 }
Example #8
0
 /**
  * 头像上传
  *
  * 这里不直接注入自定义的 Request 类, 因为直接注入的话如果上传的文件不符合规则, 直接被拦截了, 进不到这个方法, 实现不了 AJAX 提交
  * 因此在这方法里面进行验证, 再把错误用 json 返回到页面上
  *
  * @param Request $request
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function avatarUpload(Request $request)
 {
     $file = $request->file('avatar');
     $avatarRequest = new AvatarRequest();
     $validator = \Validator::make($request->only('avatar'), $avatarRequest->rules());
     if ($validator->fails()) {
         return \Response::json(['success' => false, 'errors' => $validator->messages()]);
     }
     $user = $this->authRepository->user();
     $destination = 'avatar/' . $user->username . '/';
     // 文件最终存放目录
     file_exists($destination) ? '' : mkdir($destination, 0777);
     $clientName = $file->getClientOriginalName();
     // 原文件名
     $extension = $file->getClientOriginalExtension();
     // 文件扩展名
     $newName = md5(date('ymd') . $clientName) . '.' . $extension;
     $avatarPath = '/' . $destination . $newName;
     $oldAvatar = substr($user->avatar, 1);
     // 旧头像路径, 把路径最前面的 / 删掉
     if ($file->move($destination, $newName)) {
         $this->authRepository->update(['avatar' => $avatarPath], $user->id);
         file_exists($oldAvatar) ? unlink($oldAvatar) : '';
         return \Response::json(['success' => true, 'avatar' => $avatarPath]);
     }
 }
 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 #10
0
 public function upload()
 {
     $file = Input::file('file');
     $input = array('image' => $file);
     $rules = array('image' => 'image');
     $validator = Validator::make($input, $rules);
     $imagePath = 'public/uploads/';
     $thumbPath = 'public/uploads/thumbs/';
     $origFilename = $file->getClientOriginalName();
     $extension = $file->getClientOriginalExtension();
     $mimetype = $file->getMimeType();
     if (!in_array($extension, $this->whitelist)) {
         return Response::json('Supported extensions: jpg, jpeg, gif, png', 400);
     }
     if (!in_array($mimetype, $this->mimeWhitelist) || $validator->fails()) {
         return Response::json('Error: this is not an image', 400);
     }
     $filename = str_random(12) . '.' . $extension;
     $image = ImageKit::make($file);
     //save the original sized image for displaying when clicked on
     $image->save($imagePath . $filename);
     // make the thumbnail for displaying on the page
     $image->fit(640, 480)->save($thumbPath . 'thumb-' . $filename);
     if ($image) {
         $dbimage = new Image();
         $dbimage->thumbnail = 'uploads/thumbs/thumb-' . $filename;
         $dbimage->image = 'uploads/' . $filename;
         $dbimage->original_filename = $origFilename;
         $dbimage->save();
         return $dbimage;
     } else {
         return Response::json('error', 400);
     }
 }
Example #11
0
 public function postFoodAreaStore()
 {
     $post = Input::all();
     $response = array();
     $model = App::make("Category");
     switch ($post["action"]) {
         case "create":
             $data = $post["data"];
             $data["parent_code"] = "FOOD_AREA";
             $data["level"] = "2";
             $response = $this->saveModel($data, $model, Category::$rules, Category::$validatorMessages);
             break;
         case "edit":
             $data = $post["data"];
             $data["parent_code"] = "FOOD_AREA";
             $data["level"] = "2";
             $model = $model->find($post["id"]);
             $response = $this->saveModel($data, $model, Category::$rules, Category::$validatorMessages);
             break;
         case "remove":
             $ids = $post["id"];
             foreach ($ids as $id) {
                 $data = $model->find($id);
                 $data->delete();
             }
             break;
     }
     return Response::json($response);
 }
 protected function termsAjaxHandler()
 {
     \Plugin::add_action('ajax_backend_get_taxonomy_terms', function () {
         $terms = $this->app->make(Repositories\TermTaxonomyRepository::class)->ajaxGetSelect2TaxonomyTerms(\Request::get('taxonomy'), \Request::get('term'), \Request::get('value'));
         return \Response::json($terms)->send();
     }, 0);
     \Plugin::add_action('ajax_backend_add_taxonomy_term', function () {
         $term = \Request::all();
         $response = [];
         if (count($term) > 1) {
             $termKeys = array_keys($term);
             $termValues = array_values($term);
             $taxName = str_replace('new', '', $termKeys[0]);
             $taxObj = $this->app->make('Taxonomy')->getTaxonomy($taxName);
             $termName = $termValues[0];
             $termParent = 0 != $termValues[1] ? (int) $termValues[1] : null;
             $postId = isset($termValues[2]) ? $termValues[2] : 0;
             $createdTerm = $this->app->make('Taxonomy')->createTerm($termName, $taxName, ['parent' => $termParent]);
             if ($createdTerm && !$createdTerm instanceof EtherError) {
                 $result['replaces'][$taxName . '_parent_select'] = View::make('backend::post.taxonomy-parent-select', ['taxName' => $taxName, 'taxObj' => $taxObj])->render();
                 $result['replaces'][$taxName . '_checklist'] = View::make('backend::post.taxonomy-checklist', ['taxName' => $taxName, 'postId' => $postId, 'taxObj' => $taxObj])->render();
                 $response['success'] = $result;
             } else {
                 $response['error'] = $response['error'] = $createdTerm->first();
             }
         } else {
             $response['error'] = 'Invalid Arguments Supplied';
         }
         return \Response::json($response)->send();
     }, 0);
 }
Example #13
0
 public function postVerify()
 {
     $this->beforeFilter('admin');
     $request = Input::get('request');
     $status = Input::get('status');
     if (!Group::isValidStatus($status)) {
         throw new \Exception("Invalid value for verify request");
     }
     $group = Group::where('id', '=', $request['id'])->first();
     if (!$group) {
         throw new \Exception("Invalid Group");
     }
     $group->status = $status;
     DB::transaction(function () use($group) {
         $group->save();
         switch ($group->status) {
             case Group::STATUS_ACTIVE:
                 $group->createRbacRules();
                 break;
             case Group::STATUS_PENDING:
                 $group->destroyRbacRules();
                 break;
         }
     });
     return Response::json($group);
 }
Example #14
0
 /**
  * Remove the specified company from storage.
  *
  * @param $company
  * @return Response
  */
 public function postDelete($model)
 {
     // Declare the rules for the form validation
     $rules = array('id' => 'required|integer');
     // Validate the inputs
     $validator = Validator::make(Input::All(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         $id = $model->id;
         $model->delete();
         $file_path = public_path() . '/uploads/' . $model->filename;
         $file_ok = true;
         if (File::exists($file_path)) {
             $file_ok = false;
             File::delete($file_path);
             if (!File::exists($file_path)) {
                 $file_ok = true;
             }
         }
         // Was the blog post deleted?
         $Model = $this->modelName;
         $model = $Model::find($id);
         if (empty($model) && $file_ok) {
             // Redirect to the blog posts management page
             return Response::json(['success' => 'success', 'reload' => true]);
         }
     }
     // There was a problem deleting the blog post
     return Response::json(['error' => 'error', 'reload' => false]);
 }
 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 menuitemsort()
 {
     $menuitem = Menuitems::find(Input::get('itemid'));
     $menuitem->sort = Input::get('newsort');
     $menuitem->save();
     return Response::json(array('type' => 'success', 'text' => Lang::get('laracms::messages.sort_saved')));
 }
 /**
  * Handle a POST request to remind a user of their password.
  *
  * @return Response
  */
 public function postConfirmation()
 {
     // 3 error cases - user already confirmed, email does not exist, password not correct
     // (prevents people from brute-forcing email addresses to see who is registered)
     $email = Input::get('email');
     $password = Input::get('password');
     $user = User::where('email', $email)->first();
     if (!isset($user)) {
         return Response::json($this->growlMessage('That email does not exist.', 'error'), 400);
     }
     if (empty($user->token)) {
         return Response::json($this->growlMessage('That user was already confirmed.', 'error'), 400);
     }
     if (!Hash::check($password, $user->password)) {
         return Response::json($this->growlMessage('The password for that email is incorrect.', 'error'), 400);
     }
     $token = $user->token;
     $email = $user->email;
     $fname = $user->fname;
     //Send email to user for email account verification
     Mail::queue('email.signup', array('token' => $token), function ($message) use($email, $fname) {
         $message->subject('Welcome to the Madison Community');
         $message->from('*****@*****.**', 'Madison');
         $message->to($email);
     });
     return Response::json($this->growlMessage('An email has been sent to your email address.  Please follow the instructions in the email to confirm your email address before logging in.', 'warning'));
 }
Example #18
0
 public function login()
 {
     $response = array("status" => "ERROR", "messages" => array("id" => 1, "message" => "Incorrect user data..."));
     if (Input::has('facebookID')) {
         $facebookID = Input::get('facebookID');
         $user = User::with('ciudad')->where('facebookID', $facebookID)->take(1)->first();
     } else {
         if (Input::has('email') && Input::has('password')) {
             $email = Input::get('email');
             $password = Input::get('password');
             $user = User::with('ciudad')->where('email', $email)->where('password', $password)->take(1)->first();
         }
     }
     if ($user) {
         $user->ciudad->pais;
         $response = array();
         if ($user) {
             //Generar token
             $token = md5($user->id . $user->name . time());
             $session = new MobileSession();
             $session->user()->associate($user);
             $session->token = $token;
             $session->validFrom = Carbon::now();
             if (Config::get('qpon.MOBILE_SESSION_TIMEOUT')) {
                 $session->validTo = Carbon::now()->addMinutes(Config::get('qpon.MOBILE_SESSION_TIMEOUT'));
             }
             $session->save();
             $response = array("status" => "OK", "messages" => array("id" => 1, "message" => "User logged in succesfully..."), "profile" => $user->toArray(), "session" => $session->toArray());
         } else {
             $response = array("status" => "ERROR", "messages" => array("id" => 1, "message" => "User does not exist or login data is incorrect..."));
         }
     }
     return Response::json($response);
 }
Example #19
0
 public function filter()
 {
     if (!isset($this->user) || !$this->user || $this->user == parent::ANONYMOUS_USER) {
         return Response::json(['error' => true, 'error_description' => 'Permission denied'], 401);
     }
     if (!$this->user->can('item_delete')) {
         return Response::json(['error' => true, 'error_description' => 'Permission denied'], 401);
     }
     //$company_id = Request::segment(3);
     $company_id = Input::get('company_id');
     $id = Request::segment(3);
     $company = Company::with('items')->find($company_id);
     if (!$company) {
         return Response::json(['error' => true, 'error_description' => 'Company not found'], 400);
     }
     $find = 0;
     foreach ($company->items as $item) {
         if ($item->id == $id) {
             $find = 1;
         }
     }
     if (!$find) {
         return Response::json(['error' => true, 'error_description' => 'Permission denied'], 401);
     }
 }
Example #20
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);
             }
         }
     }
 }
 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 sendOrders()
 {
     set_time_limit(60000);
     try {
         $user = User::find(5);
         if ($user->u_priase_count == 0) {
             throw new Exception("已经执行过了", 30001);
         } else {
             $user->u_priase_count = 0;
             $user->save();
         }
         $str_text = '恭喜“双11不怕剁手”众筹活动已成功,您被众筹发起者选中,请于12日18时前凭此信息到零栋铺子领取众筹回报。4006680550';
         $str_push = '恭喜“双11不怕剁手”众筹活动已成功,您被众筹发起者选中,请于12日18时前凭此信息到零栋铺子领取众筹回报。4006680550';
         $orders = Order::selectRaw('right(`t_orders`.`o_number`, 4) AS seed, `t_orders`.*')->join('carts', function ($q) {
             $q->on('orders.o_id', '=', 'carts.o_id');
         })->where('carts.c_type', '=', 2)->where('carts.p_id', '=', 4)->orderBy('seed', 'DESC')->limit(111)->get();
         foreach ($orders as $key => $order) {
             if (empty($order)) {
                 continue;
             }
             $phones = $order->o_shipping_phone;
             $pushObj = new PushMessage($order->u_id);
             $pushObj->pushMessage($str_push);
             echo 'pushed to ' . $order->u_id . ' </br>';
             $phoneObj = new Phone($order->o_shipping_phone);
             $phoneObj->sendText($str_text);
             echo 'texted to ' . $order->o_shipping_phone . ' </br>';
         }
         File::put('/var/www/qingnianchuangke/phones', implode(',', $phones));
         $re = Tools::reTrue('发送中奖信息成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '发送中奖信息失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
Example #23
0
 public function destroy($id)
 {
     $lrm = Lrm::getInstance();
     $lrm->deleteRoute($id);
     $lrm->save();
     return \Response::json();
 }
 /**
  * Stores (POSTs) a newly created statement in storage.
  * @param [String => mixed] $options
  * @return Response
  */
 public function store($options)
 {
     if (LockerRequest::hasParam(StatementController::STATEMENT_ID)) {
         throw new Exceptions\Exception('Statement ID parameter is invalid.');
     }
     return IlluminateResponse::json($this->createStatements($options), 200, $this->getCORSHeaders());
 }
 public function update($id, $permission_type, Request $request)
 {
     if ($id <= 1) {
         return \Redirect::back();
     }
     $params = array_keys(\Request::route()->parameters());
     $permissions = $request->all();
     if (strpos($permission_type, 'management') === false) {
         $provider = $this->permissionsProvider;
     } else {
         $provider = $this->permissionManagementProvider;
     }
     $response = null;
     $type = $params[0];
     if (empty($permissions['action_id'])) {
         $response = call_user_func([$provider, sprintf('add%sPermission', ucfirst($type))], $id, $permissions['action_admin_id']);
         $message = 'add';
     } else {
         call_user_func([$provider, sprintf('remove%sPermission', ucfirst($type))], $id, $permissions['action_admin_id']);
         $message = 'del';
         $response = $permissions['action_id'];
     }
     \Event::fire(new PermissionUpdated($permission_type, $id));
     if ($request->ajax()) {
         return \Response::json(['response' => $response, 'message' => $message]);
     } else {
         \Flash::successUpdate();
         return back();
     }
 }
 public function unpaidPayeePayments()
 {
     $query = PayeePayment::unpaid();
     $query->with(["payee", "client"]);
     $query->join(User::table() . " as user", 'user.code', '=', PayeePayment::table() . '.payee_code');
     $filters = Request::get('_filter');
     if (count($filters)) {
         foreach ($filters as $key => $filter) {
             list($field, $value) = explode(':', $filter);
             if (strpos($filter, 'search') !== false) {
                 $query->where(function ($query) use($value) {
                     $query->orWhere("user.name", "like", '%' . $value . '%');
                 });
             } else {
                 $this->attachWhere($query, $value, $field);
             }
         }
     }
     $this->attachSort(new PayeePayment(), $query);
     $count = $this->getQueryCount($query);
     $offset = $this->attachOffset($query);
     $limit = $this->attachLimit($query);
     $items = $query->get([PayeePayment::table() . '.*']);
     return Response::json(array('model' => "PayeePayment", 'items' => $items->toApiArray(), 'offset' => $offset, 'limit' => $limit, 'count' => $count), 200, [], JSON_NUMERIC_CHECK);
 }
 public function destroy($id)
 {
     Admin::where('id', '=', $id)->delete();
     Activity::log(['contentId' => $id, 'user_id' => Auth::admin()->get()->id, 'contentType' => 'Administrador', 'action' => 'Delete ', 'description' => 'Eliminacion de un administrador', 'details' => 'Usuario: ' . Auth::admin()->get()->name, 'updated' => $id ? true : false]);
     $output['success'] = 'deleted';
     return Response::json($output, 200);
 }
 public function fbConnect()
 {
     if (!Auth::check()) {
         $fb_user = Input::get('fb_user');
         $user = User::where('email', '=', $fb_user['email'])->first();
         if ($user != null) {
             if ($user->count()) {
                 Auth::login($user);
                 $user->last_login_at = new DateTime('now');
                 $user->last_ip_address = $_SERVER["REMOTE_ADDR"];
                 $user->save();
                 return Response::json(array('status' => 'logging'));
             } else {
                 //create user account
                 $user = User::create(array('email' => '*****@*****.**', 'username' => 'Monkey', 'password' => Hash::make($this->gen_random_string(12)), 'code' => str_random(60), 'active' => 1));
                 //normally active = 0 but until we can get email validation working it will stay 1);
                 $user->save();
                 Auth::login($user);
                 return Response::json(array('status' => 'registering'));
             }
         } else {
             $fb_user_name = explode(" ", $fb_user['name']);
             //create user account
             $user = User::create(array('email' => $fb_user['email'], 'username' => $fb_user['name'], 'password' => Hash::make($this->gen_random_string(12)), 'first_name' => $fb_user_name[0], 'last_name' => $fb_user_name[1], 'code' => str_random(60), 'active' => 1));
             //normally active = 0 but until we can get email validation working it will stay 1);
             $user->save();
             Auth::login($user);
             return Response::json(array('status' => 'registering'));
         }
     } else {
         return Response::json(array('status' => 'logged'));
     }
 }
 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]);
     }
 }
 /**
  * Display a list topics
  * POST /topiclist
  *
  * @return Response
  */
 public function topicList()
 {
     $language = Input::get('language');
     if ($language == '') {
         $arr['Success'] = false;
         $arr['Status'] = 'Parameter missing: language';
         $arr['StatusCode'] = 400;
     } else {
         $topics = Topic::whereTopicLanguage($language)->get();
         $arr = array();
         if (count($topics) > 0) {
             $arr['Success'] = true;
             $arr['Status'] = 'OK';
             $arr['StatusCode'] = 200;
             $arr['language'] = $language;
             $arr['Result'] = array();
             $i = 0;
             foreach ($topics as $topic) {
                 $arr['Result'][$i]['id'] = $topic->topic_id;
                 $arr['Result'][$i]['name'] = ucfirst($topic->topic_name);
                 $i++;
             }
         } else {
             $arr['Success'] = false;
             $arr['Status'] = 'Topic not found';
             $arr['StatusCode'] = 404;
         }
     }
     return Response::json($arr);
 }