コード例 #1
0
ファイル: RowController.php プロジェクト: left-right/center
 public function update($table, $row_id)
 {
     $table = config('center.tables.' . $table);
     # Security
     if (!isset($table->name)) {
         return redirect()->action('\\LeftRight\\Center\\Controllers\\TableController@index')->with('error', trans('center::site.table_does_not_exist'));
     } elseif (!LoginController::checkPermission($table->name, 'edit') || !$table->editable) {
         return redirect()->action('\\LeftRight\\Center\\Controllers\\RowController@index', $table->name)->with('error', trans('center::site.no_permissions_edit'));
     }
     //sanitize and convert input to array
     $updates = self::processColumnsInput($table, $row_id);
     //run update
     try {
         DB::table($table->name)->where('id', $row_id)->update($updates);
     } catch (Exception $e) {
         return redirect()->back()->withInput()->with('error', $e->getMessage());
     }
     //relations
     self::processRelationsInput($table, $row_id);
     //clean up abandoned files
     FileController::cleanup();
     //return to last line in stack or object index
     return redirect(Trail::last(action('\\LeftRight\\Center\\Controllers\\RowController@index', $table->name)));
 }
コード例 #2
0
 public static function saveImage($table_name, $field_name, $file_name, $row_id = null, $extension = null)
 {
     return FileController::saveImage($table_name, $field_name, $file_name, $row_id, $extension);
 }