diff --git a/app/Http/Controllers/TableController.php b/app/Http/Controllers/TableController.php index 2429ffa..c9b2568 100644 --- a/app/Http/Controllers/TableController.php +++ b/app/Http/Controllers/TableController.php @@ -44,7 +44,7 @@ class TableController extends Controller return view('table.view', [ 'table' => $tableModel, 'revision' => $revision, - 'columns' => Column::columnsFromJson(json_decode($revision->columns)), + 'columns' => Column::columnsFromJson($revision->columns), 'rows' => $revision->rows()->paginate(25), ]); } @@ -204,7 +204,7 @@ class TableController extends Controller $parsed[$key] = $columns[$i]->cast($val); } return [ - 'data' => json_encode($parsed), + 'data' => $parsed, ]; }, $rowTable); @@ -215,7 +215,7 @@ class TableController extends Controller $revisionFields = [ 'note' => "Initial revision of table $u->name/$input->name", - 'columns' => json_encode($columns), + 'columns' => $columns, 'row_count' => count($rowsData), ]; diff --git a/app/Models/Revision.php b/app/Models/Revision.php index 53d74b1..219e6af 100644 --- a/app/Models/Revision.php +++ b/app/Models/Revision.php @@ -25,6 +25,10 @@ class Revision extends BaseModel use HasRelaquentRelationships; protected $guarded = []; + protected $casts = [ + 'columns' => 'object', + ]; + /** Included rows */ public function rows() { diff --git a/app/Models/Row.php b/app/Models/Row.php index 035d745..f55b137 100644 --- a/app/Models/Row.php +++ b/app/Models/Row.php @@ -10,6 +10,10 @@ namespace App\Models; */ class Row extends BaseModel { + protected $casts = [ + 'data' => 'object', + ]; + protected $guarded = []; public $timestamps = false; } diff --git a/app/Tables/BaseExporter.php b/app/Tables/BaseExporter.php index 4800727..38daa00 100644 --- a/app/Tables/BaseExporter.php +++ b/app/Tables/BaseExporter.php @@ -131,7 +131,7 @@ abstract class BaseExporter $rows = $revision->rows()->offset($start)->limit($chunkSize)->get(); foreach ($rows as $row) { - $data = json_decode($row->data); + $data = $row->data; // column renaming, value formatting... diff --git a/resources/views/table/_rows.blade.php b/resources/views/table/_rows.blade.php index 63df5e7..c1cd7c9 100644 --- a/resources/views/table/_rows.blade.php +++ b/resources/views/table/_rows.blade.php @@ -18,9 +18,8 @@
@foreach($rows as $row)