Example #1
0
 public function update(StoreTableRequest $request, $tableId)
 {
     $input = $request->all();
     $input['slug'] = str_replace(' ', '_', strtolower($input['name']));
     $table = Table::where('id', $tableId)->update($input);
     return $this->createResponse($table);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(StoreTableRequest $request)
 {
     $table = new Table();
     $table->name = $request->get('name');
     $table->fields = $request->get('fields');
     $table->visible = $request->get('visible');
     $table->save();
     Schema::create($table->name, function ($dbTable) use($table) {
         foreach ($table->fields as $field) {
             $fieldType = $field['type'];
             $fieldName = $field['name'];
             $dbTable->{$fieldType}($fieldName);
         }
     });
     return redirect('/tables');
 }