0
、() :( これは私のdataControllerlaravel 5.2パスIDを()
です<?php
namespace App\Http\Controllers;
use App\topic; //use model topic
use Illuminate\Http\Request;
use Yajra\Datatables\Datatables; //datatable
use App\Http\Requests;
use Carbon\Carbon;
class dataController extends Controller
{
public function listPerintah($list,Request $request)
{
switch ($list) {
case 'delete':
$id = $request['id'];
$topic = topic::find($id);
$topic->delete();
return $topic->name.'Berhasil Dihapus';
break;
default:
return view('datatable.index');
break;
}
}
//dataTable
public function listData(Request $request)
{
$table = topic::select(['topics.*', 'users.name as user_name'])
->join('users', 'users.id', '=', 'topics.user_id')
->get();
$datatables = Datatables::of($table);
if($keyword = $request->get('search')['value'])
{
$datatables->filterColumn('rownum', 'whereRaw', '@rownum + 1 like ?', ["%{$keyword}%"]);
}
return $datatables
->editColumn('user_name', function($table) {
return 'Oleh: '. $table->user_name;
})
->editColumn('created_at', function($table) {
return Carbon::parse($table->created_at)->format('d F Y H:i:s');
})
->addColumn('action',function($table){
return
'<a title="hapus" href="javascript:" onclick="deleteBtn('.$table->id.',\''.$table->title.'\')" class="btn btn-fill btn-xs btn-danger"><span class="fa fa-remove"></span></a>
<a title="ubah" href="'.url("datatable/edit?id=".$table->id).'"
class="btn btn-xs btn-primary"><span class="fa fa-pencil"></span>
</a>' ;
})
->make(true);
}
}