Passing data to the class #2666
joshblevins1985
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to pass search data to the class from the controller. Here is what I got so far but when I put the variables in to pass they do not go to the datatable class.
Controller
`public function narcoticLogs(NarcoticLogsDataTable $dataTable, $start = NULL , $end = NULL)
{
if(!$start){
$start = Carbon::now()->subMonth(1)->startOfDay();
}else{
$start = Carbon::parse($start)->startOfDay();
}
if(!$end){
$end = Carbon::now()->endOfDay();
}else{
$end = Carbon::parse($end)->endOfDay();
}
return $dataTable->render('logistics.narcoticLogs');
`<?php
namespace Vanguard\DataTables;
use Carbon\Carbon;
use Vanguard\NarcoticLog;
use Yajra\DataTables\Html\Button;
use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Html\Editor\Editor;
use Yajra\DataTables\Html\Editor\Fields;
use Yajra\DataTables\Services\DataTable;
class NarcoticLogsDataTable extends DataTable
{
/**
* Build DataTable class.
*
* @param mixed $query Results from query() method.
* @return \Yajra\DataTables\DataTableAbstract
*/
public function dataTable($query)
{
$query->where('companyId', auth()->user()->companyId)->orderBy('timeOut', 'desc');
}`
Beta Was this translation helpful? Give feedback.
All reactions