environment() public static method

public static environment ( )
 /**
  * Handle a login request to the application.
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function postLogin(\Illuminate\Http\Request $request)
 {
     if (\App::environment('local')) {
         $this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required']);
     } else {
         $this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required', 'g-recaptcha-response' => 'required|recaptcha']);
     }
     // If the class is using the ThrottlesLogins trait, we can automatically throttle
     // the login attempts for this application. We'll key this by the username and
     // the IP address of the client making these requests into this application.
     $throttles = $this->isUsingThrottlesLoginsTrait();
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return $this->sendLockoutResponse($request);
     }
     $credentials = $this->getCredentials($request);
     if (\Auth::attempt($credentials, $request->has('remember'))) {
         return $this->handleUserWasAuthenticated($request, $throttles);
     }
     // If the login attempt was unsuccessful we will increment the number of attempts
     // to login and redirect the user back to the login form. Of course, when this
     // user surpasses their maximum number of attempts they will get locked out.
     if ($throttles) {
         $this->incrementLoginAttempts($request);
     }
     return redirect($this->loginPath())->withInput($request->only($this->loginUsername(), 'remember'))->withErrors([$this->loginUsername() => $this->getFailedLoginMessage()]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     /* CONFIG::ALL */
     $this->call('PlanSeeder');
     $this->call('WidgetDescriptorSeeder');
     /* CONFIG::LOCAL ONLY */
     if (App::environment('local')) {
         Eloquent::unguard();
         $this->call('UserSeeder');
         $this->call('InitialSeeder');
         /* CONFIG::DEVELOPMENT ONLY */
     } else {
         if (App::environment('development')) {
             Eloquent::unguard();
             $this->call('UserSeeder');
             $this->call('InitialSeeder');
             /* CONFIG::STAGING ONLY */
         } else {
             if (App::environment('staging')) {
                 /* Nothing here */
                 /* CONFIG::PRODUCTION ONLY */
             } else {
                 if (App::environment('production')) {
                     /* Nothing here */
                 }
             }
         }
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $currentAppEnvirontment = App::environment();
     // if ($currentAppEnvirontment === 'production') {
     // 	exit('I just stopped you getting fired. Love Phil - Current environment: "' . $currentAppEnvirontment . '"');
     // }
     Eloquent::unguard();
     $truncate = ['user', 'patient', 'identification_type', 'country', 'state', 'city', 'marital_status', 'relationship', 'exam', 'medical_history', 'exam_type', 'exam_item', 'speciality', 'external_cause', 'purpose_appointment', 'cie_category'];
     // se desactivan las relaciones entre las tablas para que el truncado se haga sin problemas.
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     foreach ($truncate as $table) {
         DB::table($table)->truncate();
     }
     // se reactivan las relaciones entre las tablas.
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     // Se llaman los "seeders" para poblar la db.
     $this->call('UserTableSeeder');
     $this->call('PatientTableSeeder');
     $this->call('CountryTableSeeder');
     $this->call('StateTableSeeder');
     $this->call('CityTableSeeder');
     $this->call('IdentificationTypeTableSeeder');
     $this->call('MaritalStatusTableSeeder');
     $this->call('RelationshipTableSeeder');
     $this->call('ExamTableSeeder');
     $this->call('ExamItemTableSeeder');
     $this->call('medicalHistoryTableSeeder');
     $this->call('ExamTypeTableSeeder');
     $this->call('SpecialityTableSeeder');
     $this->call('ExternalCauseTableSeeder');
     $this->call('PurposeAppointmentTableSeeder');
     $this->call('CieCategoryTableSeeder');
 }
示例#4
0
 public function fire()
 {
     if (!$this->input->getOption('force') && \App::environment() === 'production') {
         $this->error('ERROR : use --force to expunge on a production environment');
         die;
     }
     switch (DB::connection()->getDriverName()) {
         case 'mysql':
             $database = DB::connection()->getDatabaseName();
             DB::statement('SET FOREIGN_KEY_CHECKS=0;');
             $expr = DB::raw("SELECT table_name FROM information_schema.tables WHERE table_schema = '{$database}';");
             foreach (DB::select($expr) as $row) {
                 $tables[] = '`' . $row->table_name . '`';
             }
             if (!empty($tables)) {
                 $expr = DB::raw('DROP TABLE IF EXISTS ' . implode(', ', $tables));
                 DB::statement($expr);
             }
             DB::statement('SET FOREIGN_KEY_CHECKS=1;');
             $this->info("Deleted all tables from MySQL database `{$database}`");
             break;
         case 'pgsql':
             $database = DB::connection()->getDatabaseName();
             $result = DB::raw('drop schema public cascade;');
             DB::statement($result);
             $result = DB::raw('create schema public;');
             DB::statement($result);
             $this->info("Deleted all tables from PostgreSQL database `{$database}`");
             break;
     }
 }
示例#5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     if (App::environment() === 'production') {
         exit('Do not seed in production environment');
     }
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // disable foreign key constraints
     DB::table('users')->truncate();
     DB::table('volunteers')->truncate();
     DB::table('doctors')->truncate();
     User::create(['id' => 1, 'name' => 'admin', 'email' => '*****@*****.**', 'password' => '$2y$10$zJxQkCB6UNr9zzLIgve71ekLMEcOWue/lKuyCtunV559qN2NDV1ra', 'roleId' => 2]);
     User::create(['id' => 2, 'name' => 'volunteer1', 'email' => '*****@*****.**', 'password' => '$2y$10$zJxQkCB6UNr9zzLIgve71ekLMEcOWue/lKuyCtunV559qN2NDV1ra', 'roleId' => 5]);
     User::create(['id' => 3, 'name' => 'Arun', 'email' => '*****@*****.**', 'password' => '$2y$10$zJxQkCB6UNr9zzLIgve71ekLMEcOWue/lKuyCtunV559qN2NDV1ra', 'roleId' => 4]);
     User::create(['id' => 4, 'name' => 'Biswas', 'email' => '*****@*****.**', 'password' => '$2y$10$zJxQkCB6UNr9zzLIgve71ekLMEcOWue/lKuyCtunV559qN2NDV1ra', 'roleId' => 4]);
     User::create(['id' => 5, 'name' => 'Sunil', 'email' => '*****@*****.**', 'password' => '$2y$10$zJxQkCB6UNr9zzLIgve71ekLMEcOWue/lKuyCtunV559qN2NDV1ra', 'roleId' => 4]);
     User::create(['id' => 6, 'name' => 'volunteer2', 'email' => '*****@*****.**', 'password' => '$2y$10$zJxQkCB6UNr9zzLIgve71ekLMEcOWue/lKuyCtunV559qN2NDV1ra', 'roleId' => 5]);
     Volunteer::create(['userId' => 3, 'firstname' => 'volunteer1', 'lastname' => 'volunteer1', 'contactNumber' => '9717017651', 'isVerified' => true]);
     Volunteer::create(['userId' => 6, 'firstname' => 'volunteer2', 'lastname' => 'volunteer2', 'contactNumber' => '9717017650', 'isVerified' => true]);
     Doctor::create(['userId' => 3, 'firstname' => 'Arun', 'lastname' => 'Jain', 'contactNumber' => '9717017650', 'specialization' => 1, 'location' => 'Delhi', 'isVerified' => true]);
     Doctor::create(['userId' => 4, 'firstname' => 'Biswas', 'lastname' => 'Rao', 'contactNumber' => '9717017651', 'specialization' => 2, 'location' => 'Bangalore', 'isVerified' => true]);
     Doctor::create(['userId' => 5, 'firstname' => 'Sunil', 'lastname' => 'Jain', 'contactNumber' => '9717017651', 'specialization' => 2, 'location' => 'Bangalore', 'isVerified' => true]);
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     // enable foreign key constraints
 }
 /**
  * trackAll:
  * --------------------------------------------------
  * Tracks an event with all available tracking sites. In 'lazy mode'
  * eventData contains only the eventName and an eventOption string.
  * In 'detailed mode' the eventData contains all necessary options
  * for all the tracking sites.
  * @param (string)  ($mode)    lazy | detailed
  * @param (array) ($eventData) The event data
  *    LAZY MODE
  *      (string) ($en) The name of the event
  *      (string) ($el) Custom label for the event
  *    DETAILED MODE
  *      (string) (ec) [Req] Event Category (Google)
  *      (string) (ea) [Req] Event Action   (Google)
  *      (string) (el) Event label.         (Google)
  *      (int)    (ev) Event value.         (Google)
  *      (string) (en) [Req] Event name     (Intercom)(Mixpanel)
  *      (array)  (md) Metadata             (Intercom)(Mixpanel)
  * @return None
  * --------------------------------------------------
  */
 public function trackAll($mode, $eventData)
 {
     if (App::environment('production')) {
         /* Lazy mode */
         if ($mode == 'lazy') {
             $googleEventData = array('ec' => $eventData['en'], 'ea' => $eventData['en'], 'el' => $eventData['el']);
             /* Intercom IO event data */
             $intercomEventData = array('en' => $eventData['en'], 'md' => array('metadata' => $eventData['el']));
             /* Mixpanel event data */
             $mixpanelEventData = array('en' => $eventData['en'], 'md' => array('metadata' => $eventData['el']));
             /* Detailed option */
         } else {
             /* Google Analytics event data */
             $googleEventData = array('ec' => $eventData['ec'], 'ea' => $eventData['ea'], 'el' => $eventData['el'], 'ev' => $eventData['ev']);
             /* Intercom IO event data */
             $intercomEventData = array('en' => $eventData['en'], 'md' => $eventData['md']);
             /* Mixpanel event data */
             $mixpanelEventData = array('en' => $eventData['en'], 'md' => $eventData['md']);
         }
         /* Send events */
         self::$google->sendEvent($googleEventData);
         self::$intercom->sendEvent($intercomEventData);
         self::$mixpanel->sendEvent($mixpanelEventData);
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (App::environment() == 'testing') {
         Schema::create('lots', function (Blueprint $table) {
             $table->increments('id');
             $table->string('name');
             $table->string('address');
             $table->unsignedInteger('owner_id')->default(0);
             $table->foreign('owner_id')->references('id')->on('owners')->onDelete('cascade');
             $table->decimal('longitude', 12, 8);
             $table->decimal('latitude', 12, 8);
         });
     } else {
         Schema::create('lots', function (Blueprint $table) {
             $table->increments('id');
             $table->string('name');
             $table->string('address');
             $table->unsignedInteger('owner_id')->default(0);
             $table->foreign('owner_id')->references('id')->on('owners')->onDelete('cascade');
             $table->decimal('longitude', 10, 8);
             $table->decimal('latitude', 11, 8);
             $table->timestamps();
         });
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $configFile = $this->env->configFileName();
     if (!File::exists($configFile)) {
         $this->error("\nNo database configuration found.\nPlease create a {$configFile} file in your root directory with your database details.\n-> Alternativly run the `php artisan ssms:dbconfig` helper command.");
     } else {
         $this->line("\nRunning installer script on " . App::environment() . " environment... \n");
         if ($this->confirm("This installer will attempt to create a config file, create & seed database tables. Do you wish to continue? [yes|no]: ")) {
             if (Schema::hasTable('migrations')) {
                 if (!$this->confirm("Previous migrations detected. This installer will reset all tables and settings, are you sure you want to continue? [yes|no] :")) {
                     $this->abort();
                 }
             }
             try {
                 if (!Schema::hasTable('migrations')) {
                     $this->call("migrate:install");
                 }
                 $this->call("migrate:reset");
                 $this->call("migrate");
                 $this->call("db:seed");
                 $this->info("Installer complete!");
             } catch (Exception $e) {
                 $this->error("\nAn error occured during database migrations (code " . $e->getCode() . "): \n   " . $e->getMessage());
                 $this->info("\nCheck your {$configFile} database credentials!");
                 $this->abort();
             }
         } else {
             $this->abort();
         }
     }
 }
示例#9
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)
 {
     if ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     }
     /**
      * Response Exception as Json
      *
      */
     if ($request->wantsJson()) {
         $error = new \stdclass();
         $error->error = true;
         if ($e instanceof NotFoundHttpException) {
             $error->code = $e->getStatusCode();
         } else {
             $error->code = $e->getCode();
         }
         if ($error->code == 0) {
             $error->code = 400;
         }
         if ($e instanceof ValidatorException) {
             $error->message = $e->getMessageBag();
         } else {
             $error->message = $e->getMessage();
             if (\App::environment('local')) {
                 $error->file = $e->getFile();
                 $error->line = $e->getLine();
             }
         }
         return response()->json($error, $error->code);
     }
     return parent::render($request, $e);
 }
示例#10
0
 /**
  * Email Accident
  */
 public function emailAccident()
 {
     $site = Site::findOrFail($this->site_id);
     $email_list = env('EMAIL_ME');
     if (\App::environment('dev', 'prod')) {
         $email_list = "robert@capecod.com.au; gary@capecod.com.au; tara@capecod.com.au; jo@capecod.com.au; " . $email_list;
         foreach ($site->supervisors as $super) {
             if (preg_match(VALID_EMAIL_PATTERN, $super->email)) {
                 $email_list .= '; ' . $super->email;
             }
         }
     }
     $email_list = trim($email_list);
     $email_list = explode(';', $email_list);
     $email_list = array_map('trim', $email_list);
     // trim white spaces
     $email_user = \App::environment('dev', 'prod') ? Auth::user()->email : '';
     $data = ['id' => $this->id, 'site' => $site->name . ' (' . $site->code . ')', 'address' => $site->address . ', ' . $site->SuburbStatePostcode, 'date' => $this->date->format('d/m/Y g:i a'), 'worker' => $this->name . ' (age: ' . $this->age . ')', 'occupation' => $this->occupation, 'location' => $this->location, 'nature' => $this->nature, 'referred' => $this->referred, 'damage' => $this->damage, 'description' => $this->info, 'user_fullname' => User::find($this->created_by)->fullname, 'user_company_name' => User::find($this->created_by)->company->name, 'submit_date' => $this->created_at->format('d/m/Y g:i a'), 'site_owner' => $site->client->clientOfCompany->name];
     Mail::send('emails.siteAccident', $data, function ($m) use($email_list, $email_user) {
         $m->from('*****@*****.**');
         $m->to($email_list);
         if (preg_match(VALID_EMAIL_PATTERN, $email_user)) {
             $m->cc($email_user);
         }
         $m->subject('WHS Accident Notification');
     });
 }
示例#11
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if (\App::environment() === 'production') {
         $this->error('This feature is not available on this server');
     }
     $command = base_path('vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'apigen') . ' generate -s app  -d  phpdoc';
     $this->comment($command);
     $process = new Process($command);
     $process->run(function ($type, $buffer) {
         $buffer = trim($buffer);
         if (empty($buffer)) {
             return;
         }
         if ('err' === $type) {
             $this->error($buffer);
         } else {
             $this->comment($buffer);
         }
     });
     if (!$process->isSuccessful()) {
         $this->error($process->getErrorOutput());
         return;
     }
     $this->comment('Documentation generated in folder ' . base_path('phpdoc'));
     $this->comment(\PHP_Timer::resourceUsage());
 }
示例#12
0
 function layout_version($layout = 'main')
 {
     $get_hash = function ($layout) {
         $hash = '';
         $files = [public_path('assets/css/app.css'), public_path('assets/js/app.js'), resource_path('views/layouts/main.blade.php'), resource_path('views/partials/header.blade.php'), resource_path('views/partials/footer.blade.php')];
         if ($layout != 'main') {
             $files[] = resource_path('views/layouts/' . str_replace('.', DIRECTORY_SEPARATOR, $layout) . '.blade.php');
         }
         foreach ($files as $file) {
             $hash .= hash_file('md5', $file);
         }
         return hash('md5', $hash);
     };
     if (App::environment('local', 'development', 'staging')) {
         if (!($hash = config('version.layout.' . $layout))) {
             $hash = $get_hash($layout);
             config(compact('hash'));
         }
     } else {
         $hash = Cache::remember('version.layout.' . $layout, config('version.cache_duration', 5), function () use($get_hash, $layout) {
             return $get_hash($layout);
         });
     }
     return $hash;
 }
示例#13
0
 /**
  * Email Issue
  */
 public function emailTicket($action)
 {
     $email_list = env('EMAIL_ME');
     if (\App::environment('prod', 'dev')) {
         $email_list = "jo@capecod.com.au; tara@capecod.com.au; " . $email_list;
     }
     $email_list = explode(';', $email_list);
     $email_list = array_map('trim', $email_list);
     // trim white spaces
     $email_user = $this->createdBy->email;
     $data = ['id' => $this->id, 'date' => Carbon::now()->format('d/m/Y g:i a'), 'name' => $this->name, 'priority' => $this->priority_text, 'summary' => $this->summary, 'user_fullname' => Auth::user()->fullname, 'user_company_name' => Auth::user()->company->name];
     $filename = $this->attachment;
     Mail::send('emails/supportTicket', $data, function ($m) use($email_list, $email_user, $filename, $action) {
         $m->from('*****@*****.**');
         $m->to($email_list);
         if ($email_user) {
             $m->cc($email_user);
         }
         $m->subject('Support Ticket Notification');
         $file_path = public_path('filebank/support/ticket/' . $filename);
         if ($filename && file_exists($file_path)) {
             $m->attach($file_path);
         }
     });
 }
 /**
  * Route::get('/', 'HomeController@index');
  *
  * Handle angular application, displaying view based on environment
  */
 public function index()
 {
     if (App::environment() === 'production') {
         return View::make('angularjs.application_production');
     }
     return View::make('angularjs.application');
 }
示例#15
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     if (App::environment() == "production") {
         $this->command->error("WARNING: You are running in production. Data will be permanently deleted if you continue.");
         if (!$this->command->confirm('Are you sure you want to continue? [y|n]:', false)) {
             $this->command->comment("Aborting.");
             return;
         }
     }
     $this->call('TruncateTablesSeeder');
     $this->call('PermissionSeeder');
     $this->call('PermissionGroupSeeder');
     $this->call('QualityDefinitionsSeeder');
     $this->call('LiveStreamStateDefinitionsSeeder');
     $this->call('FileExtensionsSeeder');
     $this->call('FileTypesSeeder');
     $this->call('UploadPointsSeeder');
     $this->call('UserSeeder');
     $this->call('SiteUsersSeeder');
     $this->call('LiveStreamsSeeder');
     $this->call('MediaItemSeeder');
     $this->call('FileSeeder');
     $this->call('VideoFilesSeeder');
     $this->call('ShowsSeeder');
     $this->call('PlaylistsSeeder');
     $this->call('ProductionRolesSeeder');
 }
示例#16
0
 /**
  * Use this to create the initial admin account.
  *
  * @return void
  */
 public function run()
 {
     if (App::environment() == "production") {
         $this->command->error("You are about to create a user 'admin' with admin permissions?");
         if (!$this->command->confirm('Are you sure you want to continue? [y|n]:', false)) {
             $this->command->comment("Aborting.");
             return;
         }
     }
     $user = User::where("username", "admin")->first();
     if (!is_null($user)) {
         if (!$this->command->confirm("A user with username 'admin' already exists. This user will be removed. Are you sure you want to continue? [y|n]:", false)) {
             $this->command->comment("Aborting.");
             return;
         }
         $user->delete();
     }
     $password = $this->command->secret('Enter a password:'******'Re-enter password:'******'admin' with admin permissions.");
 }
 private function getTablesToSeed()
 {
     if (App::environment() === 'production') {
         return $this->tablesToSeed = $this->productionOnlyTables;
     }
     return $this->tablesToSeed = array_merge($this->productionOnlyTables, $this->tables);
 }
示例#18
0
 public function __construct($config = null)
 {
     ini_set('max_execution_time', 300);
     //var_dump($config["url"]);exit
     if (!$config) {
         $config = Config::get('api');
     }
     $this->logFile = base_path() . '/logs/sii-api.log';
     if (!is_array($config)) {
         throw new Exception("Error: no configuration for Sii");
     } elseif (!array_key_exists("url", $config)) {
         throw new Exception("Error: no url was found");
     } elseif (!array_key_exists("name", $config)) {
         throw new Exception("Error: No name for app was found");
     } elseif (!array_key_exists("password", $config)) {
         throw new Exception("Error: No password for app was found");
     } else {
         $this->url = $config["url"];
         $this->name = $config["name"];
         $this->password = $config["password"];
         $this->proxy = $config['proxy'];
         $curr_user = Session::get('user');
         $this->token = $curr_user['persona']['token'];
         //$this->client = new Buzz\Client\FileGetContents();
         $this->client = new Buzz\Client\Curl();
         $this->client->setTimeout(60);
         $this->response = new Buzz\Message\Response();
         Log::useFiles($this->logFile, App::environment('local', 'staging') ? 'debug' : 'critical');
     }
     //$this->client = $buzz;
 }
示例#19
0
 /**
  * Get the evaluated contents of the view.
  *
  * @param  string $path
  * @param  array  $data
  *
  * @throws \Exception
  * @return string
  */
 public function get($path, array $data = array())
 {
     ob_start();
     try {
         $smarty = new \Smarty();
         $smarty->caching = $this->config->get('smarty-view::caching');
         $smarty->debugging = $this->config->get('smarty-view::debugging');
         $smarty->cache_lifetime = $this->config->get('smarty-view::cache_lifetime');
         $smarty->compile_check = $this->config->get('smarty-view::compile_check');
         $smarty->error_reporting = $this->config->get('smarty-view::error_reporting');
         if (\App::environment('local')) {
             $smarty->force_compile = true;
         }
         $smarty->setTemplateDir($this->config->get('smarty-view::template_dir'));
         $smarty->setCompileDir($this->config->get('smarty-view::compile_dir'));
         $smarty->setCacheDir($this->config->get('smarty-view::cache_dir'));
         $smarty->registerResource('view', new ViewResource());
         $smarty->addPluginsDir(__DIR__ . '/plugins');
         foreach ((array) $this->config->get('smarty-view::plugins_path', array()) as $pluginPath) {
             $smarty->addPluginsDir($pluginPath);
         }
         foreach ($data as $key => $value) {
             $smarty->assign($key, $value);
         }
         $smarty->display($path);
     } catch (\Exception $e) {
         ob_get_clean();
         throw $e;
     }
     return ltrim(ob_get_clean());
 }
示例#20
0
 /**
  * Email Action Notification
  */
 public function emailAction($action)
 {
     $issue = SiteIssue::findOrFail($action->issue_id);
     $site = Site::findOrFail($issue->site_id);
     $email_list = env('EMAIL_ME');
     if (\App::environment('prod')) {
         $email_list = "*****@*****.**";
     } else {
         if (\App::environment('dev')) {
             //$email_list = "jo@capecod.com.au; tara@capecod.com.au; " . $email_list;
         }
     }
     $email_list = explode(';', $email_list);
     $email_list = array_map('trim', $email_list);
     // trim white spaces
     $email_user = \App::environment('prod', 'dev') ? Auth::user()->email : '';
     $data = ['id' => $issue->id, 'site' => $site->name . ' (' . $site->code . ')', 'date' => Carbon::now()->format('d/m/Y g:i a'), 'user_fullname' => Auth::user()->fullname, 'user_company_name' => Auth::user()->company->name, 'action' => $action->action, 'site_owner' => $site->client->clientOfCompany->name];
     $filename = $this->photo;
     Mail::send('emails/siteIssueAction', $data, function ($m) use($email_list, $email_user, $site, $filename, $action) {
         $m->from('*****@*****.**');
         $m->to($email_list);
         if (preg_match(VALID_EMAIL_PATTERN, $email_user)) {
             $m->cc($email_user);
         }
         $m->subject('WHS Issue Update Notification');
     });
 }
示例#21
0
 /**
  * Obtain the user information from GitHub.
  *
  * @return Response
  */
 public function handleProviderCallback(Request $request)
 {
     // Used for development purposes. Hit /auth/google/callback
     // to get a dummy JWT for local use.
     if (\App::environment('local')) {
         $member = Member::findOrFail(1);
         if (!$member->hasRole('member')) {
             $member->attachRole(Role::where('name', 'member')->firstOrFail());
         }
         $token = JWTAuth::fromUser($member, ['level' => config('auth.levels.high'), 'member' => $member]);
         return response()->json($token);
     }
     $provider = new GoogleRitProvider($request);
     $user = $provider->user();
     if (array_get($user->user, 'domain', '') != 'g.rit.edu') {
         return new JsonResponse(['error' => 'domain user not authorized'], Response::HTTP_FORBIDDEN);
     }
     $member = Member::firstOrNew(['email' => $user->email]);
     $member->first_name = $user->user['name']['givenName'];
     $member->last_name = $user->user['name']['familyName'];
     $member->save();
     if (!$member->hasRole('member')) {
         $member->attachRole(Role::where('name', 'member')->firstOrFail());
     }
     $token = JWTAuth::fromUser($member, ['level' => config('auth.levels.high'), 'member' => $member]);
     if ($callback = $provider->getCallback()) {
         return redirect($callback . '?token=' . $token);
     } else {
         return response()->json(['token' => $token]);
     }
 }
示例#22
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     if ('local' !== App::environment()) {
         exit('Only run on local environment.');
     }
     /**
      * just add this with seeder class name
      * @var [string]
      */
     $seeders = ['RoleTableSeeder', 'UserTableSeeder', 'ApiKeyTableSeeder', 'ContactTableSeeder', 'ZoneTableSeeder', 'BlacklistDomainTableSeeder', 'UserDomainTableSeeder', 'DnsRecordTableSeeder', 'PageTableSeeder', 'SettingTableSeeder'];
     /**
      * Dont change code below
      */
     Model::unguard();
     /**
      * remove all table record
      * from the inverse
      */
     foreach (array_reverse($seeders) as $seeder) {
         $a = new $seeder();
         $a->remove();
     }
     /**
      * Run the seeder
      */
     foreach ($seeders as $seeder) {
         $this->call($seeder);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  * @throws ImageFailedException
  * @throws \BB\Exceptions\FormValidationException
  */
 public function store()
 {
     $data = \Request::only(['user_id', 'category', 'description', 'amount', 'expense_date', 'file']);
     $this->expenseValidator->validate($data);
     if (\Input::file('file')) {
         try {
             $filePath = \Input::file('file')->getRealPath();
             $ext = \Input::file('file')->guessClientExtension();
             $mimeType = \Input::file('file')->getMimeType();
             $newFilename = \App::environment() . '/expenses/' . str_random() . '.' . $ext;
             Storage::put($newFilename, file_get_contents($filePath), 'public');
             $data['file'] = $newFilename;
         } catch (\Exception $e) {
             \Log::error($e);
             throw new ImageFailedException($e->getMessage());
         }
     }
     //Reformat from d/m/y to YYYY-MM-DD
     $data['expense_date'] = Carbon::createFromFormat('j/n/y', $data['expense_date']);
     if ($data['user_id'] != \Auth::user()->id) {
         throw new \BB\Exceptions\FormValidationException('You can only submit expenses for yourself', new \Illuminate\Support\MessageBag(['general' => 'You can only submit expenses for yourself']));
     }
     $expense = $this->expenseRepository->create($data);
     event(new NewExpenseSubmitted($expense));
     return \Response::json($expense, 201);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (App::environment() == 'testing') {
         Schema::create('entranxits', function (Blueprint $table) {
             $table->increments('id');
             $table->string('orientation');
             $table->unsignedInteger('lot_id')->default(0);
             $table->foreign('lot_id')->references('id')->on('lots')->onDelete('cascade');
             $table->unsignedInteger('region_id')->default(0);
             $table->foreign('region_id')->references('id')->on('regions')->onDelete('cascade');
             $table->string('image');
             $table->timestamps();
         });
     } else {
         Schema::create('entranxits', function (Blueprint $table) {
             $table->increments('id');
             $table->string('orientation');
             $table->unsignedInteger('lot_id')->default(0);
             $table->foreign('lot_id')->references('id')->on('lots')->onDelete('cascade');
             $table->unsignedInteger('region_id')->default(0);
             $table->foreign('region_id')->references('id')->on('regions')->onDelete('cascade');
             $table->timestamps();
         });
     }
 }
 /**
  * Auto-prefix the document index name with the current Laravel
  * environment.
  *
  * @param array $parameters
  * @return array
  */
 public function handleIndex(array $parameters)
 {
     if ($index = array_get($parameters, 'index')) {
         $environment = mb_strtolower(preg_replace('/[^a-z0-9_\\-]+/', '-', \App::environment()));
         $parameters['index'] = trim($environment, '_-') . '-' . $index;
     }
     return $parameters;
 }
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     if (\App::environment('local')) {
         return ['name' => 'required|min:3', 'email' => 'required|email', 'message' => 'required'];
     } else {
         return ['name' => 'required|min:3', 'email' => 'required|email', 'message' => 'required', 'g-recaptcha-response' => 'required|recaptcha'];
     }
 }
 public function run()
 {
     // not to delete in production just in case lol
     if (App::environment('production')) {
         DB::table('crypto_types')->delete();
     }
     CryptoType::create(['crypto_type' => 'BTC']);
 }
示例#28
0
 protected function sendEvent($url, $post)
 {
     if (\App::environment() == 'local') {
         \Mail::send('emails.siftScience.sendData', ['siftData' => $post], function ($mail) {
             $mail->to('*****@*****.**')->from('*****@*****.**')->subject("siftScienceEvent");
         });
     }
 }
示例#29
0
 /**
  * Report or log an exception.
  *
  * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
  *
  * @param  \Exception  $e
  * @return void
  */
 public function report(Exception $e)
 {
     // some quick data about the error for local development
     if (\App::environment('local')) {
         die("File: " . $e->getFile() . "\nLine: " . $e->getLine() . "\nMessage: " . $e->getMessage() . "\n\nTrace:\n" . substr($e->getTraceAsString(), 0, 25000));
     }
     return parent::report($e);
 }
示例#30
0
 public function render($viewPath, $tplVars = NULL)
 {
     if (isset($_GET['rdtest']) && $_GET['rdtest'] == 1 && App::environment(APP_ENVIRONMENT_DEVELOPMENT)) {
         $this->assign('view_path', $viewPath);
         return parent::render(Enhancer_Const::getDebugViewFilePath(), $tplVars);
     }
     return parent::render($viewPath, $tplVars);
 }