本文整理汇总了PHP中app\models\Author::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Author::findAll方法的具体用法?PHP Author::findAll怎么用?PHP Author::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Author
的用法示例。
在下文中一共展示了Author::findAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
public function actionIndex()
{
$this->view->news = Article::findAllWithGenerator();
$this->view->table = (new AdminDataTable(Author::findAll(), [function ($model) {
return $model->getName();
}, function ($model) {
return $model->getEmail();
}]))->render();
$this->view->display(__DIR__ . '/../../templates/admin.php');
}
示例2: actionSave
/**
* Экшен для сохранения новости
*/
protected function actionSave()
{
$article = \App\Models\Article::giveOne($_POST['id']);
if (false === $article) {
throw new \App\Exceptions\ObjectNotFound('Запрашиваемый объект не найден');
}
$article->fill($_POST);
$article->author = \App\Models\Author::giveOne($_POST['author_id']);
try {
$article->save();
$this->redirect('/admin');
} catch (\App\MultiException $ex) {
$this->view->article = $article;
$this->view->authors = \App\Models\Author::findAll();
$this->view->errors = $ex;
$this->view->display(__DIR__ . '/../../templates/admin/news/tmp_edit.php');
}
}
示例3: actionEdit
protected function actionEdit()
{
$id = $_GET['id'] ?? false;
if (false !== $id) {
if (false === ($article = \App\Models\News::findByID($id))) {
throw new \App\Exceptions\NotFound($_SERVER['REQUEST_URI']);
}
} else {
$article = new \App\Models\News();
}
if (!empty($_POST)) {
try {
$article->fillByPost($_POST);
} catch (MultiException $e) {
$this->view->display('edit.php', ['article' => $article, 'authors' => \App\Models\Author::findAll(), 'errors' => $e]);
exit(0);
}
$this->redirectIf('/admin/news/index', $article->save());
}
$this->view->display('edit.php', ['article' => $article, 'authors' => \App\Models\Author::findAll()]);
}
示例4: actionAuthors
protected function actionAuthors()
{
$authors = Author::findAll();
$table = new AdminDataTable($authors, [function (Author $author) {
return $author->firstname;
}, function (Author $author) {
return $author->lastname;
}, function (Author $author) {
return $author->email;
}]);
$this->view->render('/admin/authors.html', ['authors' => $table->render()]);
}
示例5: gettype
<?php
/**
* Подключение файла автозагрузки
*/
require_once __DIR__ . '/../../autoload.php';
$view = new \App\View();
$view->title = 'Админ-панель';
$view->content = 'Контент';
$view->authors = \App\Models\Author::findAll();
/*
foreach($view->authors as $key => $value) {
echo gettype($value) . '<br>';
if (!is_object($value) && !is_array($value)) {
continue;
}
echo ++$key . '). ';
$iter = new App\MyIterator($value);
foreach ($iter as $k => $v) {
if (!is_object($v) && !is_array($v)) {
echo $k . ' = ' . $v . '; ';
continue;
}
$iter2 = new App\MyIterator($v);
foreach ($iter2 as $k2 => $v2) {
echo $k2 . ' = ' . $v2 . '; ';
}