You can switch to the Table mode in Tinkerwell by either pressing Cmd/Ctrl+T
or using the menu bar via Tinker Mode -> Table.
The table mode allows you to see any collection or array representation as a browseable table.
Here's an example using a simple Eloquent model query that returns all users:
The table mode will then take the collection result and display it in the table below. Allowing to paginate through your results, search them or sort by specific attributes.
You can also save the given data as CSV - this is especially useful when building more complex Eloquent queries that you want to access as CSV data. Since Tinkerwell executes the code within your application context (locally or via SSH) you can make use of all your Eloquent model relations or scopes.
The table mode not only works with Eloquent model results, but you can also create tables manually by just returning an array or Laravel collection in the code editor.
Here's an example that uses a simple PHP array:
When working with the table mode, it can be very helpful to be able to copy a specific row as either JSON data or even as a PHP array. You can just right-click on any row in the table mode, which will open up a context menu.
In here you can choose how you want to copy the given row.
Here's the example output of copying one row as a PHP array:
$array = [ 'id' => '1', 'name' => 'Marcel', 'created_at' => '2020-01-07 09:55:07', 'updated_at' => '2020-03-17 14:41:15', 'paddle_id' => 'null', 'confirmed_at' => '2020-03-17 14:41:15', 'confirmation_code' => 'null',];
This also works when selecting multiple rows at once. Just click on the first row that you want to select and then press shift while clicking on the next row. This will create a selection of multiple rows. When you copy multiple rows as PHP arrays, the output looks like this:
$array = [ [ 'id' => '1', 'name' => 'Marcel', 'created_at' => '2020-01-07 09:55:07', 'updated_at' => '2020-03-17 14:41:15', 'paddle_id' => 'null', 'confirmed_at' => '2020-03-17 14:41:15', 'confirmation_code' => 'null', ], [ 'id' => '5', 'name' => 'Guest', 'created_at' => '2020-03-16 09:46:04', 'updated_at' => '2020-03-17 14:41:15', 'paddle_id' => 'null', 'confirmed_at' => '2020-03-17 14:41:15', 'confirmation_code' => 'null', ],];