data-table
data-table copied to clipboard
add row button on datatable
Hi, any idea on how to add row button based on DB column value? I planned to add it on Action column
so far this is my code:
- Controller:
<?php
namespace App\Admin\Controllers;
use App\Http\Controllers\Controller;
use Encore\Admin\Layout\Content;
use Encore\Admin\Layout\Row;
use Encore\Admin\Widgets\Box;
use Encore\Admin\Widgets\Callout;
use Illuminate\Support\Facades\DB;
class ReportController extends Controller
{
public function index(Content $content)
{
return $content
->title($title = 'Report')
->row(function (Row $row) {
$eval = DB::table('evaluations')
->select('admin_users.name', DB::raw('count(evaluations.employee_evaluated) as total_evaluated'),'evaluations.employee_evaluated')
->leftJoin('admin_users', 'admin_users.id', '=', 'evaluations.employee_evaluated')
->groupBy('evaluations.employee_evaluated', 'admin_users.name')
->orderBy('total_evaluated', 'DESC')
->get('total_evaluated', 'admin_users.name');
$OfficerEvaluatedSummary = view('admin.charts.OfficerEvaluatedSummary', compact('eval'));
$row->column('12', new Box('Officer Evaluated Summary', $OfficerEvaluatedSummary));
})->row(function (Row $row) {
// $bar = view('admin.chartjs.doughnut');
// $row->column(1/3, new Box('Doughnut chart', $bar));
// $scatter = view('admin.chartjs.combo-bar-line');
// $row->column(1/3, new Box('Chart.js Combo Bar Line Chart', $scatter));
// $bar = view('admin.chartjs.line-stacked');
// $row->column(1/3, new Box('Chart.js Line Chart - Stacked Area', $bar));
});
}
}
- Blade
<?php
use Jxlwqq\DataTable\DataTable;
// table
$headers = ['Employee Evaluated', 'Total Evaluation', 'Action'];
$rows = json_decode($eval);
$style = ['table-bordered', 'table-hover', 'table-striped'];
$options = [
'paging' => true,
'lengthChange' => false,
'searching' => true,
'ordering' => true,
'info' => true,
'autoWidth' => true,
];
$dataTable = new DataTable($headers, $rows, $style, $options);
echo $dataTable->render();