1. Go to this page and download the library: Download mercurioplatform/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/ */
mercurioplatform / tables example snippets
// app/Tables/Catalog/ProductResource.php
namespace App\Tables\Catalog;
use App\Models\Product;
use Illuminate\Database\Eloquent\Builder;
use Mercurio\Tables\Field\StatusField;
use Mercurio\Tables\Field\TextField;
use Mercurio\Tables\ListResource;
class ProductResource extends ListResource
{
public function key(): string
{
return 'catalog.products';
}
public function query(): Builder
{
return Product::query();
}
public function fields(): array
{
return [
TextField::make('id', '#')->sortable()->mono()->align('left'),
TextField::make('title', 'Название')->sortable(),
StatusField::make('status', 'Статус')
->kinds(['published' => 'success', 'draft' => 'secondary'])
->labels(['published' => 'Опубликован', 'draft' => 'Черновик']),
];
}
public function searchable(): array
{
return ['id', 'title'];
}
}
// routes/web.php
use App\Tables\Catalog\ProductResource;
use Illuminate\Support\Facades\Route;
Route::middleware(['auth'])->group(function () {
Route::tablesPage('admin/products', ProductResource::class);
});
> use Mercurio\Tables\Field\TextField;
> use Mercurio\Tables\Field\NumberField;
> use Mercurio\Tables\Form\Field\TextField as TextInput;
> use Mercurio\Tables\Form\Field\NumberField as NumberInput;
>