user list table
This commit is contained in:
@ -3,10 +3,14 @@ namespace app\controllers;
|
||||
|
||||
|
||||
use app\foo;
|
||||
use app\helpers\Debug;
|
||||
use app\models\Question;
|
||||
use app\models\User;
|
||||
use app\tables\columns\UserViewActionColumn;
|
||||
use Itguild\Tables\ListJsonTable;
|
||||
use kernel\Controller;
|
||||
use kernel\IGTabel\ListJsonTableEloquentCollection;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
class UserController extends Controller{
|
||||
public function actionCreate(): void
|
||||
@ -27,24 +31,27 @@ class UserController extends Controller{
|
||||
return Question::where('user_id', $user_id)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function actionIndex(): void
|
||||
{
|
||||
// $loader = new \Twig\Loader\FilesystemLoader(__DIR__.'/../views');
|
||||
// $twig = new \Twig\Environment($loader, ['cache' => 'app/views/cache']);
|
||||
$users = User::where(['role' => 1])->get();
|
||||
|
||||
$i = 0;
|
||||
foreach (User::all() as $user)
|
||||
{
|
||||
$userArr[$i++] = $user;
|
||||
}
|
||||
echo $this->twig->render('user_table.html.twig', ['userArr' => $userArr]);
|
||||
|
||||
$json = new foo();
|
||||
$userArr = $json->createJsonArray(User::labels(), $userArr, "form1");
|
||||
$table = new ListJsonTable($userArr);
|
||||
$table->create();
|
||||
$table->render();
|
||||
$this->twig->addFunction(new TwigFunction('table', function () use ($users){
|
||||
$dataProvider = new ListJsonTableEloquentCollection($users, [
|
||||
'model' => User::class,
|
||||
'perPage' => 5,
|
||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
'baseUrl' => "/admin/user",
|
||||
]);
|
||||
$table = new ListJsonTable($dataProvider->getJson());
|
||||
$table->addAction(UserViewActionColumn::class);
|
||||
$table->create();
|
||||
$table->render();
|
||||
}));
|
||||
|
||||
echo $this->twig->render('user_table.html.twig');
|
||||
}
|
||||
|
||||
public function actionView($id): void
|
||||
|
Reference in New Issue
Block a user