app/Http/Controllers/SampleController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index(Request  $request)
    {
        if($request->ajax())
        {
            $data = Sample_data::latest()->get();
            return DataTables::of($data)
            ->addColumn('action', function($data)
            {
                $button = '<button type="button" name="edit" id="'.$data->id.'" class="edit btn btn-primary btn-sm">Edit</button>';
                $button .= '&nbsp;&nbsp;&nbsp;<button type="button" name="edit" id="'.$data->id.'" class="delete btn btn-danger btn-sm">Delete</button>';
                return $button;
            })
                ->addColumn('checkBox', function ($data)
                {
                    $checkBox = '<input type="checkbox" name="checkBox" class="checkbox form-check-input" id="checkBoxes" value="'.$data->id.'" data-id="'.$data->id.'"/>';
                    return $checkBox;
                })
            ->rawColumns(['action','checkBox'])
            ->make(true);
            return DataTables::of($data)
                ->addColumn('checkbox', function($data)
                {
                    $checkBox = '<input type="checkbox" name="id[]" id="'.$data->id.'" class="checkbox"></input>';
                    return $checkBox;
                })
                ->rawColumns(['checkbox'])
                ->make(true);
        }
        return view('sample_data');
    }
public function index ( Request $ request ) { if ( $ request -> ajax ( ) ) { $ data = Sample_data :: latest ( ) -> get ( ) ; return DataTables :: of ( $ data ) -> addColumn ( 'action' , function ( $ data ) { $ button = '<button type="button" name="edit" id="' . $ data -> id . '" class="edit btn btn-primary btn-sm">Edit</button>' ; $ button .= '&nbsp;&nbsp;&nbsp;<button type="button" name="edit" id="' . $ data -> id . '" class="delete btn btn-danger btn-sm">Delete</button>' ; return $ button ; } ) -> addColumn ( 'checkBox' , function ( $ data ) { $ checkBox = '<input type="checkbox" name="checkBox" class="checkbox form-check-input" id="checkBoxes" value="' . $ data -> id . '" data-id="' . $ data -> id . '"/>' ; return $ checkBox ; } ) -> rawColumns ( [ 'action' , 'checkBox' ] ) -> make ( true ) ; } return view ( 'sample_data' ) ; }
Display a listing of the resource.
Display a listing of the resource .
// //            return DataTables::of($data) //                ->addColumn('checkbox', function($data) //                { //                    $checkBox = '<input type="checkbox" name="id[]" id="'.$data->id.'" class="checkbox"></input>'; //                    return $checkBox; //                }) //                ->rawColumns(['checkbox']) //                ->make(true);