Exemplo n.º 1
0
 public function get_index()
 {
     $data['title'] = "Palettes Page";
     $data['lead'] = "Your registered palettes.";
     $data['tabs'][] = array('All', URL::to('litmus/palettes'), 'active');
     $data['tabs'][] = array('Add', URL::to('litmus/palettes/create'));
     $data['table']['objects'] = Palette::all();
     //   DEVELOPMENT!!!!!!!!!!!!!
     $data['content'] = View::make('litmus::partials.table', $data['table'])->render();
     return $this->layout($data);
 }
 /**
  * Make changes to the database.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('colors', function ($table) {
         $table->create();
         $table->increments('id');
         $table->string('name');
         $table->integer('red');
         $table->integer('green');
         $table->integer('blue');
         $table->integer('alpha')->default(0);
         $table->string('hex', 7)->nullable();
         $table->integer('palette_id')->unsigned();
         $table->timestamps();
     });
     Schema::table('colors', function ($table) {
         $table->foreign('palette_id')->references('id')->on('palettes')->on_update('cascade')->on_delete('cascade');
     });
     $seed = array();
     for ($r = 1; $r < 256; $r = $r * 10) {
         $array = array();
         $array['red'] = $r;
         for ($g = 1; $g < 256; $g = $g * 10) {
             $array['green'] = $g;
             for ($b = 1; $b < 256; $b = $b * 10) {
                 $array['blue'] = $b;
                 $array['name'] = "rgb({$r}, {$g}, {$b})";
                 $seed[] = $array;
             }
         }
     }
     foreach (Palette::all() as $p) {
         foreach ($seed as $rec) {
             $color = new Color();
             $color->fill($rec);
             $p->colors()->insert($color);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Address for third parties to incorporate an image upload form.
  * 
  * @return html
  */
 public function get_form()
 {
     $data = array();
     $data['fields'] = Config::get('litmus::config.form.image');
     unset($data['fields'][0]);
     unset($data['fields'][1]);
     foreach (Palette::all() as $palette) {
         $id = $palette->id;
         $title = $palette->title;
         $data['fields'][4]['values'][$id] = $title;
     }
     $data['url'] = Input::has('url') ? Input::get('url') : '';
     $form = View::make('litmus::partials.form', $data)->render();
     return $form;
 }