গ্রিড কলাম ব্যবহার
কলামের প্রস্থ
$grid->column('title')->width(200);
কলামের রঙ
$grid->column('title')->color('#ffff00');
HTML অ্যাট্রিবিউট
$grid->column('title')->setAttributes(['style' => 'color:red;']);
$grid->column('desc')->style('max-width:200px;word-break:break-all;');
হেল্প টেক্সট
$grid->column('title')->help('This column shows the post title');
সর্টিং
// Enable sortable column
$grid->column('created_at')->sortable();
// Sortable with type casting
$grid->column('price')->sortable(false, 'DECIMAL');
// Default ordering
$grid->model()->orderBy('id', 'desc');
ডিফল্ট অনুযায়ী কলাম লুকান
$grid->column('created_at')->hide();
ব্যবহারকারীরা কলাম সিলেক্টর ব্যবহার করে এটি দেখাতে পারবেন।
ফিক্সড কলাম
অনুভূমিক স্ক্রলিংয়ের সময় প্রথম ও শেষ কলাম দৃশ্যমান রাখুন:
$grid->fixColumns(3, -2); // Fix first 3, last 2
স্ট্রিং অপারেশন
কলামের ভ্যালুর উপর Illuminate\Support\Str মেথড চেইন করুন:
$grid->title()->limit(30);
$grid->title()->ucfirst();
$grid->title()->substr(1, 10);
$grid->email()->limit(20, '...');
অ্যারে / কালেকশন অপারেশন
অ্যারে বা কালেকশন ভ্যালুর জন্য, Illuminate\Support\Collection মেথড চেইন করুন:
$grid->tags()->pluck('name');
$grid->tags()->pluck('name')->map('ucwords')->implode(', ');
জটিল ট্রান্সফরমেশন
$grid->images()->display(function ($images) {
return json_decode($images, true);
})->map(function ($path) {
return 'http://localhost/images/' . $path;
})->image();
কলাম এক্সটেন্ড করা
অ্যানোনিমাস ফাংশন
use SuperAdmin\Admin\Grid\Column;
Column::extend('color', function ($value, $color) {
return "<span style='color: $color'>$value</span>";
});
// Usage
$grid->title()->color('#ccc');
ক্লাস-ভিত্তিক এক্সটেনশন
Column::extend('popover', Popover::class);
// Usage
$grid->description()->popover('right');