/**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('user_details', function (Blueprint $table) {
         $table->increments('id')->unsigned();
         $table->integer('user_id')->unsigned()->index();
         foreach (Pongo::forms('user_details') as $name => $config) {
             $options = array($name);
             if (is_numeric($config['len'])) {
                 array_push($options, $config['len']);
             }
             call_user_func_array(array($table, $config['type']), $options);
         }
         $table->timestamps();
         $table->foreign('user_id')->references('id')->on('users')->onDelete('CASCADE')->onUpdate('CASCADE');
     });
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('posts', function (Blueprint $table) {
         $table->increments('id')->unsigned();
         $table->integer('author_id')->unsigned()->index();
         $table->string('lang', 5);
         foreach (Pongo::forms('posts') as $name => $config) {
             $options = array($name);
             if (is_numeric($config['len'])) {
                 array_push($options, $config['len']);
             }
             call_user_func_array(array($table, $config['type']), $options);
         }
         $table->integer('edit_level');
         $table->boolean('is_active');
         $table->timestamps();
     });
 }
Exemple #3
0
 /**
  * [saveCustomForm description]
  * @param  [type] $form [description]
  * @param  string $msg  [description]
  * @return [type]       [description]
  */
 public function saveCustomForm($name, $form, $msg = 'alert.success.save')
 {
     $form_structure = \Pongo::forms($form);
     extract($this->input);
     $model = $this->model->find($id)->{$name};
     foreach ($form_structure as $field => $value) {
         if ($value['form'] == 'date') {
             $model->{$field} = \Carbon\Carbon::create($birth_year, $birth_month, $birth_day);
         } elseif ($value['form'] == 'datetime') {
             $model->{$field} = \Carbon\Carbon::create($birth_year, $birth_month, $birth_day, $birth_hh, $birth_mm);
         } else {
             $model->{$field} = ${$field};
         }
     }
     $model->save();
     return $this->setSuccess($msg);
 }