data table
This commit is contained in:
parent
8cb1b317d3
commit
8f80a58f78
@ -29,4 +29,6 @@ public function get(?int $user_id = null): LengthAwarePaginator;
|
||||
public function setStudyDate(string $from, ?string $to = null): self;
|
||||
|
||||
public function setReceiveDate(string $from, ?string $to = null): self;
|
||||
|
||||
public function setReportDate(string $from, ?string $to = null): self;
|
||||
}
|
||||
|
@ -35,6 +35,10 @@ abstract class WorklistBase implements IUserStudyLister
|
||||
|
||||
private ?string $receiveDateTo = null;
|
||||
|
||||
private ?string $reportDateFrom = null;
|
||||
|
||||
private ?string $reportDateTo = null;
|
||||
|
||||
public function setRadiologist(int $radiologist_id): self
|
||||
{
|
||||
$this->radiologist_id = $radiologist_id;
|
||||
@ -211,12 +215,14 @@ private function applyLocked(Builder $query): Builder
|
||||
|
||||
private function applyDateFilter(Builder $query, string $column, string $from, ?string $to): Builder
|
||||
{
|
||||
if (filled($from)) {
|
||||
$start = Carbon::parse($from);
|
||||
|
||||
if (filled($to)) {
|
||||
$end = Carbon::parse($to);
|
||||
$query = $query->whereBetween($column, [$start->toDateString(), $end->toDateString()]);
|
||||
$query = $query->whereBetween($column, [$start->toDateString(), Carbon::parse($to)->toDateString()]);
|
||||
} else {
|
||||
$query = $query->where($column, '>=', $start->toDateString());
|
||||
$query = $query->where($column, '=', $start->toDateString());
|
||||
}
|
||||
}
|
||||
|
||||
return $query;
|
||||
@ -230,7 +236,11 @@ private function applyDateFilters(Builder $query): Builder
|
||||
}
|
||||
|
||||
if (filled($this->receiveDateFrom)) {
|
||||
$query = $this->applyDateFilter($query, 'receive_date', $this->receiveDateFrom, $this->receiveDateTo);
|
||||
$query = $this->applyDateFilter($query, 'received_at', $this->receiveDateFrom, $this->receiveDateTo);
|
||||
}
|
||||
|
||||
if (filled($this->reportDateFrom)) {
|
||||
$query = $this->applyDateFilter($query, 'reported_at', $this->reportDateFrom, $this->reportDateTo);
|
||||
}
|
||||
|
||||
return $query;
|
||||
@ -251,4 +261,12 @@ public function setReceiveDate(string $from, ?string $to = null): self
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setReportDate(string $from, ?string $to = null): self
|
||||
{
|
||||
$this->reportDateFrom = $from;
|
||||
$this->reportDateTo = $to;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
82
app/DataTables/WorklistDataTable.php
Normal file
82
app/DataTables/WorklistDataTable.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
|
||||
use App\Models\Worklist;
|
||||
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
|
||||
use Yajra\DataTables\EloquentDataTable;
|
||||
use Yajra\DataTables\Html\Builder as HtmlBuilder;
|
||||
use Yajra\DataTables\Html\Button;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use Yajra\DataTables\Services\DataTable;
|
||||
|
||||
class WorklistDataTable extends DataTable
|
||||
{
|
||||
/**
|
||||
* Build the DataTable class.
|
||||
*
|
||||
* @param QueryBuilder $query Results from query() method.
|
||||
*/
|
||||
public function dataTable(QueryBuilder $query): EloquentDataTable
|
||||
{
|
||||
return (new EloquentDataTable($query))
|
||||
->addColumn('action', 'worklist.action')
|
||||
->setRowId('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the query source of dataTable.
|
||||
*/
|
||||
public function query(Worklist $model): QueryBuilder
|
||||
{
|
||||
return $model->newQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional method if you want to use the html builder.
|
||||
*/
|
||||
public function html(): HtmlBuilder
|
||||
{
|
||||
return $this->builder()
|
||||
->setTableId('worklist-table')
|
||||
->columns($this->getColumns())
|
||||
->minifiedAjax()
|
||||
// ->dom('Bfrtip')
|
||||
->orderBy(1)
|
||||
->selectStyleSingle()
|
||||
->buttons([
|
||||
Button::make('excel'),
|
||||
Button::make('csv'),
|
||||
Button::make('pdf'),
|
||||
Button::make('print'),
|
||||
Button::make('reset'),
|
||||
Button::make('reload'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the dataTable columns definition.
|
||||
*/
|
||||
public function getColumns(): array
|
||||
{
|
||||
return [
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(60)
|
||||
->addClass('text-center'),
|
||||
Column::make('id'),
|
||||
Column::make('add your columns'),
|
||||
Column::make('created_at'),
|
||||
Column::make('updated_at'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filename for export.
|
||||
*/
|
||||
protected function filename(): string
|
||||
{
|
||||
return 'Worklist_'.date('YmdHis');
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@
|
||||
"sentry/sentry-laravel": "^4.10",
|
||||
"spatie/laravel-permission": "^6.10",
|
||||
"vinkla/hashids": "^12.0",
|
||||
"yajra/laravel-datatables": "^11.0",
|
||||
"yajra/laravel-datatables-oracle": "^11.1"
|
||||
},
|
||||
"require-dev": {
|
||||
|
2
resources/js/worklist.js
Normal file
2
resources/js/worklist.js
Normal file
@ -0,0 +1,2 @@
|
||||
import './bootstrap';
|
||||
import 'laravel-datatables-vite';
|
@ -1,7 +1,7 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import {defineConfig} from 'vite';
|
||||
import laravel from 'laravel-vite-plugin';
|
||||
import html from '@rollup/plugin-html';
|
||||
import { glob } from 'glob';
|
||||
import {glob} from 'glob';
|
||||
|
||||
/**
|
||||
* Get Files from a directory
|
||||
@ -11,9 +11,14 @@ import { glob } from 'glob';
|
||||
function GetFilesArray(query) {
|
||||
return glob.sync(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Js Files
|
||||
*/
|
||||
// Ppp JS Files
|
||||
const appJsFiles = GetFilesArray('resources/js/*.js');
|
||||
|
||||
|
||||
// Page JS Files
|
||||
const pageJsFiles = GetFilesArray('resources/assets/js/*.js');
|
||||
|
||||
@ -57,7 +62,8 @@ export default defineConfig({
|
||||
input: [
|
||||
'resources/css/app.css',
|
||||
'resources/assets/css/demo.css',
|
||||
'resources/js/app.js',
|
||||
//'resources/js/app.js',
|
||||
...appJsFiles,
|
||||
...pageJsFiles,
|
||||
...vendorJsFiles,
|
||||
...LibsJsFiles,
|
||||
|
Loading…
Reference in New Issue
Block a user