Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel datatable format date column

$projects = Project::select('id', 'name', 'date_start', 'date_end');
return Datatables::of($projects)
  ->editColumn('date_start', function ($request) {
    return $request->date_start->format('Y-m-d'); // human readable format
  })
  ->editColumn('date_end', function ($request) {
    return $request->date_end->format('Y-m-d'); // human readable format
  })
  ->filterColumn('date_start', function ($query, $keyword) {
    $query->whereRaw("DATE_FORMAT(date_start,'%Y-%m-%d') like ?", ["%$keyword%"]); //date_format when searching using date
  })
  ->filterColumn('date_end', function ($query, $keyword) {
    $query->whereRaw("DATE_FORMAT(date_end,'%Y-%m-%d') like ?", ["%$keyword%"]); //date_format when searching using date
  })
  ->make(true);
Comment

PREVIOUS NEXT
Code Example
Php :: lat long in laravel validation 
Php :: php remove stop words from string 
Php :: set session after login with laravel 
Php :: Laravel Password & Password_Confirmation Validation 
Php :: routing code in drupal 8 
Php :: how to check php version in php 
Php :: how to bulk insert array into sql php 
Php :: wordpress max post revision 
Php :: get image width and height in laravel 
Php :: get last letter in php 
Php :: laravel websockets onsubscribe 
Php :: php requuire once 
Php :: php uppercase with accent 
Php :: laravel foreign key constraint 
Php :: php check connection to database 
Php :: how to zip a folder using php 
Php :: phpcs ignore line warning 
Php :: display custom post type 
Php :: hide error in php 
Php :: cloudflare country 
Php :: send email template via php 
Php :: laravel foreach 
Php :: use php variable in html attributes 
Php :: change password function in laravel 
Php :: laravel validation mimes always fails 
Php :: retrieving a cookie in php 
Php :: do while php 
Php :: paginate relationship laravel7 
Php :: php override trait method and call it 
Php :: unlink is a directory laravel 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =