make() public static method

Return a new response from the application.
public static make ( string $content = '', integer $status = 200, array $headers = [] ) : Illuminate\Http\Response
$content string
$status integer
$headers array
return Illuminate\Http\Response
Example #1
0
 /**
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // Use content negotiation to determine the correct format to return
     $negotiator = new \Negotiation\FormatNegotiator();
     $acceptHeader = Request::header('accept');
     // Set priorities to json (if the app requests json provide it in favor of html)
     $priorities = array('application/json', 'text/html', '*/*');
     // Get the best appropriate content type
     $result = $negotiator->getBest($acceptHeader, $priorities);
     // Default to html if $result is not set
     $val = "text/html";
     if (isset($result)) {
         $val = $result->getValue();
     }
     // See what kind of content we should return
     switch ($val) {
         case "text/html":
             // In case we want to return html, just let
             // Laravel render the view and send the headers
             return Response::view('route.planner')->header('Content-Type', "text/html")->header('Vary', 'accept');
             break;
         case "application/json":
         default:
             // In case we want to return JSON(LD) or something else, generate
             // our JSON by calling our static function 'getJSON()'
             return Response::make($this::getJSON())->header('Content-Type', "application/json")->header('Vary', 'accept');
             break;
     }
 }
 public function update(Request $request, $id)
 {
     try {
         $params = $request->all();
         $reportId = $id;
         $report = CrimeReportsModel::find($id);
         if (isset($params['delete_flag'])) {
             $report->delete_flag = 'y';
             $report->save();
             return response()->json(['message' => 'deleted'], 200);
         } else {
             $newStatus = '';
             switch ($params['status']) {
                 case 'o':
                     $newStatus = 'p';
                     break;
                 case 'p':
                     $newStatus = 'r';
                     break;
                 case 'r':
                     $newStatus = 'r';
                     break;
                 default:
                     $newStatus = 'd';
                     break;
             }
             $report->status = $newStatus;
             $report->save();
             return response()->json(['message' => 'success'], 200);
         }
     } catch (ModelNotFoundException $e) {
         return Response::make('Not Found', 404);
     }
 }
 public function getExport($statistic)
 {
     $title = $statistic->name;
     $type = \Input::get('type');
     $arrColumnName = $statistic->getColumnNameArray();
     $table = $statistic->getResult();
     switch ($type) {
         case 'csv':
             $output = '';
             $output .= implode(",", $arrColumnName) . "\r\n";
             foreach ($table as $row) {
                 $output .= implode(",", $row) . "\r\n";
             }
             $headers = array('Content-Type' => 'text/csv', 'Content-Disposition' => 'attachment; filename="' . $statistic->name . '_' . date('Y_m_d_His') . '.csv"');
             return \Response::make(rtrim($output, "\r\n"), 200, $headers);
         case 'excel':
             $output = '<table><thead><tr>';
             foreach ($arrColumnName as $columnName) {
                 $output = $output . '<th>' . $columnName . '</th>';
             }
             $output = $output . '</tr></thead><tbody>';
             foreach ($table as $result) {
                 $output = $output . '<tr>';
                 foreach ($result as $res) {
                     $output = $output . '<td>' . $res . '</td>';
                 }
                 $output = $output . '</tr>';
             }
             $output = $output . '<tfoot><tr><td colspan="' . count($arrColumnName) . '">' . $statistic->name . '</td></tr></tfoot></table>';
             $headers = array('Pragma' => 'public', 'Expires' => 'public', 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', 'Cache-Control' => 'private', 'Content-Type' => 'application/vnd.ms-excel', 'Content-Disposition' => 'attachment; filename=' . $statistic->name . '_' . date('Y_m_d_His') . '.xls', 'Content-Transfer-Encoding' => ' binary');
             return \Response::make($output, 200, $headers);
     }
     return \View::make(\Config::get('app.admin_template') . '/statistics/result', compact('title', 'statistic'));
 }
 public function getJavascript()
 {
     $contents = View::make('translations');
     $response = Response::make($contents);
     $response->header('Content-Type', 'application/javascript');
     return $response;
 }
Example #5
0
 public function create($type = 'csv')
 {
     try {
         $export = static::getExportForType($type);
     } catch (Exception $e) {
         App::abort(404);
     }
     $export->user_id = Auth::user()->id;
     $export->filename = $export->generateFilename();
     $export->path = $export->folderPath();
     $export->setLogbooks(Input::get('logbooks'));
     $save = Input::has('save') ? (bool) Input::get('save') : true;
     if ($export->run($save)) {
         if ($save == false) {
             $res = Response::make($export->content);
             $res->header('Content-type', $export->getContentType());
             return $res;
         } else {
             $export->save();
             return Response::download($export->fullPath(), $export->filename, ['Content-type' => $export->getContentType()]);
         }
     } else {
         return Redirect::to(action('ExportsController@index'))->with('message', ['content' => 'Er is iets mis gegaan met exporteren.', 'class' => 'danger']);
     }
 }
 /**
  * Gets an array of statements.
  * https://github.com/adlnet/xAPI-Spec/blob/master/xAPI.md#723-getstatements
  * @param [String => mixed] $options
  * @return Response
  */
 public function index($options)
 {
     // Gets the acceptable languages.
     $langs = LockerRequest::header('Accept-Language', []);
     $langs = is_array($langs) ? $langs : explode(',', $langs);
     $langs = array_map(function ($lang) {
         return explode(';', $lang)[0];
     }, $langs);
     // Gets the params.
     $params = LockerRequest::all();
     if (isset($params['agent'])) {
         $decoded_agent = json_decode($params['agent']);
         if ($decoded_agent !== null) {
             $params['agent'] = $decoded_agent;
         }
     }
     // Gets an index of the statements with the given options.
     list($statements, $count, $opts) = $this->statements->index(array_merge(['langs' => $langs], $params, $options));
     // Defines the content type and body of the response.
     if ($opts['attachments'] === true) {
         $content_type = 'multipart/mixed; boundary=' . static::BOUNDARY;
         $body = $this->makeAttachmentsResult($statements, $count, $opts);
     } else {
         $content_type = 'application/json;';
         $body = $this->makeStatementsResult($statements, $count, $opts);
     }
     // Creates the response.
     return \Response::make($body, 200, ['Content-Type' => $content_type, 'X-Experience-API-Consistent-Through' => Helpers::getCurrentDate()]);
 }
 public function subscribe()
 {
     $rules = ['email' => 'required|email'];
     $validator = Validator::make(Input::all(), $rules);
     $contents = json_encode(['message' => 'Your subscription was unsuccessful.']);
     $failure = Response::make($contents, 200);
     $failure->header('Content-Type', 'text/json');
     if ($validator->fails()) {
         return $failure;
     }
     $subscription = new Subscription();
     $subscription->email = Input::get('email');
     $subscription->active = 1;
     $subscription->save();
     $email = Input::get('email');
     $subject = "Subscribe {$email} to Newsletter";
     #Shoot email to subscription service
     Mail::send('emails.subscription', array('email' => $email), function ($message) use($subject) {
         $message->to('*****@*****.**')->subject($subject);
     });
     $contents = json_encode(['message' => 'Your subscription was successful.']);
     $success = Response::make($contents, 200);
     $success->header('Content-Type', 'text/json');
     return $success;
 }
Example #8
0
 /**
  * Emulate a call to index.php?p=$vanilla_module_path
  * Much of this ripped out of Vanilla's index.php
  */
 public function view($segments)
 {
     // if a static asset, return it outright
     $asset = $this->is_static_asset($segments);
     if ($asset) {
         return \Response::make(\File::get($asset))->header('Content-Type', $this->get_content_type($asset));
     }
     // otherwise, dispatch into vanilla
     $user = $this->user;
     $bootstrap = new VanillaBootstrap();
     $bootstrap->call(function () use($user, $segments) {
         // Create the session and stuff the user in
         \Gdn::Authenticator()->SetIdentity($user->getKey(), false);
         \Gdn::Session()->Start(false, false);
         \Gdn::Session()->SetPreference('Authenticator', 'Gdn_Authenticator');
         // Create and configure the dispatcher.
         $Dispatcher = \Gdn::Dispatcher();
         $EnabledApplications = \Gdn::ApplicationManager()->EnabledApplicationFolders();
         $Dispatcher->EnabledApplicationFolders($EnabledApplications);
         $Dispatcher->PassProperty('EnabledApplications', $EnabledApplications);
         // Process the request.
         $Dispatcher->Start();
         $Dispatcher->Dispatch(implode('/', $segments));
     });
 }
 public function receive()
 {
     $request = \Request::instance();
     if (!$this->goCardless->validateWebhook($request->getContent())) {
         return \Response::make('', 403);
     }
     $parser = new \BB\Services\Payment\GoCardlessWebhookParser();
     $parser->parseResponse($request->getContent());
     switch ($parser->getResourceType()) {
         case 'bill':
             switch ($parser->getAction()) {
                 case 'created':
                     $this->processNewBills($parser->getBills());
                     break;
                 case 'paid':
                     $this->processPaidBills($parser->getBills());
                     break;
                 default:
                     $this->processBills($parser->getAction(), $parser->getBills());
             }
             break;
         case 'pre_authorization':
             $this->processPreAuths($parser->getAction(), $parser->getPreAuthList());
             break;
         case 'subscription':
             $this->processSubscriptions($parser->getSubscriptions());
             break;
     }
     return \Response::make('Success', 200);
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     // Add the namespace to config
     $this->app['config']->package('onigoetz/imagecache', __DIR__ . '/../../config');
     $config = $this->app['config']->get('imagecache::imagecache');
     //TODO :: externalize that
     $toolkit = 'gd';
     // Stopwatch - must be registered so the application doesn't fail if the profiler is disabled
     $this->app['imagecache'] = $this->app->share(function () use($config, $toolkit) {
         return new Manager($config, $toolkit);
     });
     //PHP 5.3 compatibility
     $app = $this->app;
     $url = "{$config['path_images']}/{$config['path_cache']}/{preset}/{file}";
     $this->app['router']->get($url, function ($preset, $file) use($app) {
         try {
             $final_file = $app['imagecache']->handleRequest($preset, $file);
         } catch (InvalidPresetException $e) {
             return \Response::make('Invalid preset', 404);
         } catch (NotFoundException $e) {
             return \Response::make('File not found', 404);
         }
         if (!$final_file) {
             return \Response::make('Dunno what happened', 500);
         }
         //TODO :: be more "symfony reponse" friendly
         $transfer = new Transfer();
         $transfer->transfer($final_file);
         exit;
     })->where('file', '.*');
 }
Example #11
0
 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     $app = $this->app;
     $app['config']->package('barryvdh/laravel-debugbar', $this->guessPackagePath() . '/config');
     if (!$this->shouldUseMiddleware()) {
         $app->after(function ($request, $response) use($app) {
             $debugbar = $app['debugbar'];
             $debugbar->modifyResponse($request, $response);
         });
     }
     $this->app['router']->get('_debugbar/open', array('as' => 'debugbar.openhandler', function () use($app) {
         $debugbar = $app['debugbar'];
         if (!$debugbar->isEnabled()) {
             $app->abort('500', 'Debugbar is not enabled');
         }
         $openHandler = new \DebugBar\OpenHandler($debugbar);
         $data = $openHandler->handle(null, false, false);
         return \Response::make($data, 200, array('Content-Type' => 'application/json'));
     }));
     if ($this->app['config']->get('laravel-debugbar::config.enabled')) {
         /** @var LaravelDebugbar $debugbar */
         $debugbar = $this->app['debugbar'];
         $debugbar->boot();
     }
 }
 public function image()
 {
     $key = strip_tags(\Route::input('key'));
     $key = str_replace('.png', '', $key);
     if (empty($key)) {
         return redirect('/');
     } else {
         $result = \DB::table('post')->where('post_key', $key)->first();
         if ($result->post_type == 3) {
             $text = $result->post_message;
             $text = $this->handleText($text);
             $image = $this->warpTextImage($text);
             ob_start();
             imagepng($image, null, 9, null);
             $image = ob_get_contents();
             ob_end_clean();
             @imagedestroy($image);
             $response = \Response::make($image);
             $response->header('Content-Type', 'image/png');
             return $response;
         } else {
             return redirect('/');
         }
     }
 }
 public function handle($request, \Closure $next)
 {
     $auth0 = \App::make('auth0');
     // Get the encrypted user JWT
     $authorizationHeader = $request->header("Authorization");
     $encUser = str_replace('Bearer ', '', $authorizationHeader);
     if (trim($encUser) == '') {
         return \Response::make("Unauthorized user", 401);
     }
     try {
         $jwtUser = $auth0->decodeJWT($encUser);
     } catch (CoreException $e) {
         return \Response::make("Unauthorized user", 401);
     } catch (Exception $e) {
         echo $e;
         exit;
     }
     // if it does not represent a valid user, return a HTTP 401
     $user = $this->userRepository->getUserByDecodedJWT($jwtUser);
     if (!$user) {
         return \Response::make("Unauthorized user", 401);
     }
     // lets log the user in so it is accessible
     \Auth::login($user);
     // continue the execution
     return $next($request);
 }
 /**
  * Generate local sp metadata.
  *
  * @return \Illuminate\Http\Response
  */
 public function metadata()
 {
     $metadata = $this->saml2Auth->getMetadata();
     $response = Response::make($metadata, 200);
     $response->header('Content-Type', 'text/xml');
     return $response;
 }
Example #15
0
 public function image()
 {
     if (!Auth::check()) {
         Session::flash('redirect', URL::current());
         return Redirect::route('login');
     }
     $relativePath = Input::get('path');
     $filePath = Input::get('file');
     $path = Path::fromRelative($relativePath);
     if (!$path->exists()) {
         App::abort(404, 'Archive not found');
     }
     $archive = Archive\Factory::open($path);
     $imageStream = $archive->getEntryStream($filePath);
     $imageData = stream_get_contents($imageStream);
     $response = Response::make($imageData);
     $ext = pathinfo($filePath, PATHINFO_EXTENSION);
     switch ($ext) {
         case 'jpg':
         case 'jpeg':
             $response->header('Content-Type', 'image/jpeg');
             break;
         case 'png':
             $response->header('Content-Type', 'image/png');
             break;
     }
     $response->header('Last-Modified', gmdate('D, d M Y H:i:s', $path->getMTime()) . ' GMT');
     $response->header('Expires', gmdate('D, d M Y H:i:s', strtotime('+1 year')) . ' GMT');
     $response->header('Cache-Control', 'public');
     return $response;
 }
 public function doAction(Request $request)
 {
     $token = $this->getHttpRequestVerifier()->verify($request);
     $payment = $this->getPayum()->getPayment($token->getPaymentName());
     $payment->execute(new Notify($token));
     return \Response::make(null, 204);
 }
 public function CORSOptions()
 {
     $statusCode = 204;
     $origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : URL();
     $headers = ['Access-Control-Allow-Origin' => $origin, 'Access-Control-Allow-Methods' => 'GET, PUT, POST, DELETE, OPTIONS', 'Access-Control-Allow-Headers' => 'Origin, Content-Type, Accept, Authorization, X-Requested-With, X-Experience-API-Version, X-Experience-API-Consistent-Through, Updated', 'Access-Control-Allow-Credentials' => 'true'];
     return \Response::make(null, $statusCode, $headers);
 }
 public function qrcode($code)
 {
     $qrCode = new QrCode();
     $QR = $qrCode->setText($code)->setSize(300)->setPadding(10)->setImageType(QrCode::IMAGE_TYPE_JPEG)->setErrorCorrection(QrCode::LEVEL_HIGH)->getImage();
     $response = \Response::make('', 200);
     $response->header('Content-Type', 'image/jpeg', true);
     header('Content-type: image/png');
     if (($logo = \Config::get('laravel-code::config.logo')) && \File::exists($logo)) {
         $QR_width = imagesx($QR);
         $QR_height = imagesy($QR);
         $im = imagecreatetruecolor($QR_width, $QR_height);
         imagecopy($im, $QR, 0, 0, 0, 0, $QR_width, $QR_height);
         imagedestroy($QR);
         $logo = imagecreatefromstring(file_get_contents($logo));
         $logo_width = imagesx($logo);
         $logo_height = imagesy($logo);
         $logo_qr_width = $QR_width / 5;
         $scale = $logo_width / $logo_qr_width;
         $logo_qr_height = $logo_height / $scale;
         $from_width = ($QR_width - $logo_qr_width) / 2;
         imagecopyresampled($im, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
         imagepng($im);
     } else {
         imagepng($QR);
     }
     return $response;
 }
Example #19
0
 public function postLogin()
 {
     if (Auth::attempt(Input::only('email', 'password'), TRUE)) {
         return Auth::user();
     }
     return Response::make(['message' => 'Wrong credentials'], 500);
 }
 public function ajaxCustomers()
 {
     $cpage = 'customers';
     $i = Input::all();
     $arr = [];
     $arr = getallheaders();
     $count = Customer::all()->count();
     if (isset($arr['Range'])) {
         $response_array = array();
         $response_array['Accept-Ranges'] = 'items';
         $response_array['Range-Unit'] = 'items';
         $response_array['Content-Ranges'] = 'items ' . $arr['Range'] . '/' . $count;
         $arr = explode('-', $arr['Range']);
         $items = $arr[1] - $arr[0] + 1;
         $skip = $arr[0];
         $skip = $skip < 0 ? 0 : $skip;
         $c = null;
         if (isset($_GET['query']) && $_GET['query'] != '') {
             $query = $_GET['query'];
             $c = Customer::where('membership_id', 'LIKE', "%{$query}%")->orWhereRaw("concat_ws(' ',firstname,lastname) LIKE '%{$query}%'")->orWhere('firstname', 'LIKE', "%{$query}")->orWhere('lastname', 'LIKE', "%{$query}%")->skip($skip)->take($items)->get();
         } else {
             $c = Customer::skip($skip)->take($items)->get();
         }
         $response = Response::make($c, 200);
         $response->header('Content-Range', $response_array['Content-Ranges'])->header('Accept-Ranges', 'items')->header('Range-Unit', 'items')->header('Total-Items', $count)->header('Flash-Message', 'Now showing pages ' . $arr[0] . '-' . $arr[1] . ' out of ' . $count);
         return $response;
     }
     $c = Customer::all();
     $response = Response::make($c, 200);
     $response->header('Content-Ranges', 'test');
     return $response;
     /*	$c = Customer::all();
     	return $c;*/
 }
 public function login()
 {
     if (Input::has('url')) {
         // only allow local urls as redirect destinations
         $url = Input::get('url');
         if (!preg_match("~^(//|[^/]+:)~", $url)) {
             Session::flash('url.intended', $url);
         }
     }
     if (!$this->account->samlLogged()) {
         Auth::logout();
         $this->account->samlLogin();
     }
     if ($this->account->samlLogged()) {
         $id = $this->account->getSamlUniqueIdentifier();
         if (!$this->account->IdExists($id)) {
             if (Config::get('laravel-saml::saml.can_create', true)) {
                 $this->account->createUser();
             } else {
                 return Response::make(Config::get('laravel-saml::saml.can_create_error'), 400);
             }
         } else {
             if (!$this->account->laravelLogged()) {
                 $this->account->laravelLogin($id);
             }
         }
     }
     if ($this->account->samlLogged() && $this->account->laravelLogged()) {
         $intended = Session::get('url.intended');
         $intended = str_replace(Config::get('app.url'), '', $intended);
         Session::flash('url.intended', $intended);
         return Redirect::intended('/');
     }
 }
Example #22
0
 /**
  * Returns document with all sitemap items from $items array
  *
  * @param string $format (options: xml, html, txt, ror-rss, ror-rdf)
  *
  * @return View
  */
 public function render($format = 'xml')
 {
     if (empty($this->link)) {
         $this->link = Config::get('application.url');
     }
     if (empty($this->title)) {
         $this->title = 'Sitemap for ' . $this->link;
     }
     $channel = array('title' => $this->title, 'link' => $this->link);
     switch ($format) {
         case 'ror-rss':
             return Response::make(Response::view('sitemap::ror-rss', array('items' => $this->items, 'channel' => $channel)), 200, array('Content-type' => 'text/rss+xml; charset=utf-8'));
             break;
         case 'ror-rdf':
             return Response::make(Response::view('sitemap::ror-rdf', array('items' => $this->items, 'channel' => $channel)), 200, array('Content-type' => 'text/rdf+xml; charset=utf-8'));
             break;
         case 'html':
             return Response::make(Response::view('sitemap::html', array('items' => $this->items, 'channel' => $channel)), 200, array('Content-type' => 'text/html'));
             break;
         case 'txt':
             return Response::make(Response::view('sitemap::txt', array('items' => $this->items, 'channel' => $channel)), 200, array('Content-type' => 'text/plain'));
             break;
         default:
             return Response::make(Response::view('sitemap::xml', array('items' => $this->items)), 200, array('Content-type' => 'text/xml; charset=utf-8'));
     }
 }
Example #23
0
 /**
  * Creates a Laravel route, returning a closure which passes the raw input to AngularPHP and returns the response
  */
 protected function init()
 {
     $route = func_get_arg(0);
     $this->setErrorHandler(function (\Exception $e, Request $r) {
         \Log::error($e, $r->toArray());
     });
     $endpoint = $this;
     \Route::any($route, function () use($endpoint) {
         $path = '/' . \Request::path();
         $referrer = \Request::header('referer');
         $host = \Request::header('host');
         if (($origin = \Request::header('Origin')) && count($this->corsHosts)) {
             $this->setCorsOrigin($origin);
         }
         /**
          * If being called remotely, add the domain name to the URI
          */
         if (strlen($referrer) && parse_url($referrer, PHP_URL_HOST) != $host) {
             $uri = '//' . $host . $path;
         } else {
             $uri = $path;
         }
         $request = new Request(\Request::json()->all());
         $response = $endpoint->setUri($uri)->execute($request, \Request::getMethod());
         return \Response::make($response->content, $response->code, $response->headers)->header('Content-Type', $response->contentType);
     });
 }
Example #24
0
 public function EditAccount()
 {
     $entre_data = array();
     if (DB::table('accounts_dbx')->where('account_id', Input::get('id'))->update(array('account_status' => Input::get('action')))) {
         $entre_data = DB::select("SELECT firstname,lastname,email_address from accounts_dbx where account_id = ?", array(Input::get('id')));
         if (Input::get('send_email') == '1') {
             if (Input::get('action') == 'ACTIVE') {
                 Session::put('email_names', $entre_data[0]->firstname . ' ' . $entre_data[0]->lastname);
                 Session::put('email_message', 'Your Mradifund account has been activated. You can now login and access your account');
                 $data = array('message' => "Your Mradifund account has been activated. You can now login and access your account");
                 Mail::send('emails.notice', $data, function ($message) {
                     $entre_data = DB::select("SELECT firstname,lastname,email_address from accounts_dbx where account_id = ?", array(Input::get('id')));
                     $message->to($entre_data[0]->email_address, $entre_data[0]->firstname . ' ' . $entre_data[0]->lastname)->subject('Mradi Account');
                 });
             } else {
                 Session::put('email_names', $entre_data[0]->firstname . ' ' . $entre_data[0]->lastname);
                 Session::put('email_message', 'Your Mradifund account has been deactivated. Please contact us for more information');
                 $data = array('message' => "Your Mradifund account has been deactivated. Please contact us for more information");
                 Mail::send('emails.notice', $data, function ($message) {
                     $entre_data = DB::select("SELECT firstname,lastname,email_address from accounts_dbx where account_id = ?", array(Input::get('id')));
                     $message->to($entre_data[0]->email_address, $entre_data[0]->firstname . ' ' . $entre_data[0]->lastname)->subject('Mradi Account');
                 });
                 //return Redirect::route(Input::get('route'));
             }
         }
         return Response::make("OK", 200);
     } else {
         return Response::make("OK", 200);
     }
 }
 /**
  * Returns css for the given path
  * 
  * @return \Illuminate\Support\Facades\Response
  */
 private function stylesheet($path)
 {
     $this->prepareClientCache($path);
     $response = Response::make(Asset::stylesheet($path), 200);
     $response->header('Content-Type', 'text/css');
     return $response;
 }
Example #26
0
 /**
  * Generate bootstrap javascript virtual file
  * 
  * @return void
  */
 public function init()
 {
     $contents = \Render::view('partials.initjs');
     $response = \Response::make($contents, 200);
     $response->header('Content-Type', 'application/javascript');
     return $response;
 }
 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;
 }
Example #28
0
 public function download($id, $type = 'l')
 {
     $result = $this->faxes->download($id, $type);
     // If they want a pdf we need to set the proper header
     $headers = $type == 'p' ? ['Content-Type' => 'application/pdf', "Content-Disposition" => "attachment; filename=fax-{$id}.pdf"] : ['Content-Type' => 'image/jpeg'];
     return \Response::make($result, 200, $headers);
 }
Example #29
0
 public function getImageCover($id)
 {
     $result = $this->Users->getPathImageCover($id);
     $response = Response::make(File::get($result[0]->img_cover_url));
     $response->header('Content-Type', 'image/png');
     return $response;
 }
Example #30
-1
 /**
  * Handle an exception and display the exception report.
  *
  * @param  Exception  $exception
  * @param  bool       $trace
  * @return void
  */
 public static function exception($exception, $trace = true)
 {
     static::log($exception);
     ob_get_level() and ob_end_clean();
     $message = $exception->getMessage();
     // For Laravel view errors we want to show a prettier error:
     $file = $exception->getFile();
     if (str_contains($exception->getFile(), 'eval()') and str_contains($exception->getFile(), 'laravel' . DS . 'view.php')) {
         $message = 'Error rendering view: [' . View::$last['name'] . ']' . PHP_EOL . PHP_EOL . $message;
         $file = View::$last['path'];
     }
     // If detailed errors are enabled, we'll just format the exception into
     // a simple error message and display it on the screen. We don't use a
     // View in case the problem is in the View class.
     if (Config::get('error.detail')) {
         $response_body = "<html><h2>Unhandled Exception</h2>\n\t\t\t\t<h3>Message:</h3>\n\t\t\t\t<pre>" . $message . "</pre>\n\t\t\t\t<h3>Location:</h3>\n\t\t\t\t<pre>" . $file . " on line " . $exception->getLine() . "</pre>";
         if ($trace) {
             $response_body .= "\n\t\t\t\t  <h3>Stack Trace:</h3>\n\t\t\t\t  <pre>" . $exception->getTraceAsString() . "</pre></html>";
         }
         $response = Response::make($response_body, 500);
     } else {
         $response = Event::first('500', array($exception));
         $response = Response::prepare($response);
     }
     $response->render();
     $response->send();
     $response->foundation->finish();
     exit(1);
 }