Пример #1
0
 /**
  * Execute the console command
  *
  * @return void
  */
 public function fire()
 {
     $allowed_types = array('array', 'boolean', 'integer', 'number', 'null', 'object', 'string');
     $cluster = Cluster::where('clustername', '=', $this->option('cluster'))->first();
     if (!isset($cluster)) {
         $this->comment("This cluster doesn't exist.");
         return;
     }
     do {
         // get company name
         do {
             $name = $this->ask("Company name : ");
             if (empty($name)) {
                 $this->comment("Your company name is empty.");
             }
         } while (empty($name));
         // check if a company with this name and cluster already exists
         $company = Company::byName($cluster, $name)->first();
         if (isset($company)) {
             $this->comment("A company with this name already exists, please choose another one.");
         }
     } while (isset($company));
     // get company logo url
     do {
         $logo_url = $this->ask("Logo url: ");
         if (empty($logo_url)) {
             $this->comment("Your logo url is empty.");
         }
     } while (empty($logo_url));
     $domains = array();
     // get company domains
     $add_domains = $this->ask("Do you want to add any domains (like: '@flatturtle.com')? [Y]/n") ? 0 : 1;
     while ($add_domains) {
         $domain = $this->ask("Domain: ");
         if (empty($domain)) {
             $this->comment("Your domain is empty.");
         }
         array_push($domains, $domain);
         $add_domains = $this->ask("Do you want to add more domains (like: '@flatturtle.com')? [Y]/n") ? 0 : 1;
     }
     $company = Company::create(array("name" => $name, "logo_url" => $logo_url, "cluster_id" => $cluster->id, "domains" => json_encode($domains)));
     $this->info("Company '{$company->name}' has been saved.");
     return;
 }
Пример #2
0
  |--------------------------------------------------------------------------
  |
  | Here is where you can register all of the routes for an application.
  | It's a breeze. Simply tell Laravel the URIs it should respond to
  | and give it the Closure to execute when that URI is requested.
  |
*/
App::error(function (\Symfony\Component\HttpKernel\Exception\HttpException $e) {
    return Response::json(array('error' => $e->getMessage()), $e->getStatusCode());
});
/*
 * Model bindings
 *
 */
Route::bind('cluster', function ($cluster_name, $route) {
    $cluster = $cluster = Cluster::where('clustername', '=', $cluster_name)->first();
    if (!isset($cluster)) {
        throw new EntityNotFoundException("Cluster.NotFound");
    }
    return $cluster;
});
/**
 * AUTH routes
 */
Route::group(array('before' => 'auth.basic'), function () {
    /*
      PUT http://reservation.hostname/{cluster_name}/amenities/{name}
      create or update an amenity.
    */
    Route::put('/{cluster}/amenities/{name}', 'EntityController@createAmenity');
    /*