1. Go to this page and download the library: Download cryptodev4/orchid-tables library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cryptodev4 / orchid-tables example snippets
use CryptoDev4\OrchidTables\Screen\TDChecklist;
class UserTable extends Table {
//...
public function columns(): array
{
return [
TDChecklist::make(),
//...
TD::make('id'),
];
}
}
class UserTable extends Table {
//...
public function commandBar(): array {
return [
ModalToggle::make("my modal")->modal('myModal'),
];
}
public function columns(): array {
return [
TD::Checklist::make()->checkboxSet('form','screen-modal-form-myModal'),
];
}
class UserScreen extends Screen {
//...
public function activateUsers(Request $request){
Alert::message('Selected item count is still ' . count($request->get('checkbox', []) ) );
$request->flash();
}
TD::make('name')->exportRender(function(string $value, User $entry, int $rowNum){
return Str::upper($value).' #'.$entry->id.' (row-'.$rowNum.')';
})
use CryptoDev4\OrchidTables\Exports\QuickExport;
use Orchid\Screen\Actions\Button;
use Orchid\Screen\Screen;
class UsersTableScreen extends Screen
{
public function commandBar(): array
{
return [
Button::make('export')->method('export')->rawClick(),
];
}
public function export(){
$query = User::filters()->defaultSort('id', 'desc');
return (new QuickExport($query, UserTable::class))->download('userExport.xlsx');
}
//...
use CryptoDev4\OrchidTables\Screen\TableAdvanced
class UserTable extends TableAdvanced
{
public function rowClass(User $row)
{
return $row->active ? 'bg-success' : 'bg-danger';
}
public function rowLink(User $row)
{
return route('admin.users.show',$row);
}
//...