1. Go to this page and download the library: Download thenandan/grids 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/ */
thenandan / grids example snippets
php artisan vendor:publish --tag=public
php artisan make:grid CompanyGrid
namespace App\Grids;
use Illuminate\Database\Eloquent\Model;
use TheNandan\Grids\BaseGrid;
class CompanyGrid extends BaseGrid
{
/**
* Set root model for the grid query
*
* @return Model
*/
protected function setModel(): Model
{
// return new model instance
}
/**
* Configure your grid
*
* @return void
*/
protected function configureGrid(): void
{
// Configure your grid column
}
}
namespace App\Grids;
use Illuminate\Database\Eloquent\Model;
use TheNandan\Grids\BaseGrid;
class CompanyGrid extends BaseGrid
{
/**
* Set root model for the grid query
*
* @return Model
*/
protected function setModel(): Model
{
return new Company();
}
/**
* Configure your grid
*
* @return void
*/
protected function configureGrid(): void
{
$this->grid->setCachingTime(0);
$this->grid->addColumn('id', 'Id')->setSortable();
$this->grid->addColumn('unique_id', 'Unique ID')->setSortable()->setSearchFilter();
$this->grid->addColumn('name', 'Company Name')->setSortable()->setSearchFilter();
$this->grid->addColumn('created_at', 'Added On')->setCallback(function ($createdAt) {
if (null === $createdAt || !$createdAt instanceof Carbon) {
return '-';
}
return Carbon::createFromTimestamp($createdAt->timestamp)->isoFormat('LLLL');
})->setDateFilter();
$this->grid->addColumn('edit_client', 'Edit')->setCallback(function ($val, $row) {
return "<a href='#'><i class='fas fa-edit'></i></a>";
});
$this->grid->addColumn('delete_client', 'Delete')->setCallback(function ($val, $row) {
return "<a href='#' class='text-danger'><i class='fas fa-trash'></i></a>";
});
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.