You can switch to the Table mode in Tinkerwell by either pressing
Shift + 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 some users and maps them to a collection:
The table mode will then take the collection result and display it in the table below, allowing to paginate through the 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 = [ 'name' => 'Marcel', 'role' => 'Creative Genius', ];
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 = [ [ 'name' => 'Marcel', 'role' => 'Creative Genius', ], [ 'name' => 'Sebastian', 'role' => 'Marcels Caregiver', ], ];