Download Laravel-xCRUD Integration Full Code that includes this full demo
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ButtonsController extends Controller
{
public function index()
{
$xcrud = Xcrud_get_instance();
$xcrud->table('base_fields');
$xcrud->columns('text,date,bool');
$xcrud->create_action('publish', 'publish_action'); // action callback, function publish_action() in functions.php
$xcrud->create_action('unpublish', 'unpublish_action');
$xcrud->button('#', 'unpublished', 'icon-close glyphicon glyphicon-remove', 'xcrud-action',
array( // set action vars to the button
'data-task' => 'action',
'data-action' => 'publish',
'data-primary' => '{id}'),
array( // set condition ( when button must be shown)
'bool',
'!=',
'1')
);
$xcrud->button('#', 'published', 'icon-checkmark glyphicon glyphicon-ok', 'xcrud-action', array(
'data-task' => 'action',
'data-action' => 'unpublish',
'data-primary' => '{id}'), array(
'bool',
'=',
'1'));
$render = $xcrud->render();
return view('xcrud_simple', ['render' => $render]);
}
}
# | Text | Date | Bool | |
---|---|---|---|---|
1 | Test test | Yes | published View Edit Remove | |
2 | Test | 28.09.2013 | No | unpublished View Edit Remove |
3 | Test test test | 30.11.2032 | No | unpublished View Edit Remove |
4 | Text | Yes | published View Edit Remove | |
5 | ttt | 01.01.1970 | Yes | published View Edit Remove |
6 | No | unpublished View Edit Remove | ||
7 | No | unpublished View Edit Remove | ||
8 | No | unpublished View Edit Remove | ||
9 | No | unpublished View Edit Remove | ||
10 | No | unpublished View Edit Remove |