本文整理汇总了PHP中Author::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Author::all方法的具体用法?PHP Author::all怎么用?PHP Author::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Author
的用法示例。
在下文中一共展示了Author::all方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getIdNamePair
/**
* When editing or adding a new book, we need a select dropdown of authors to choose from
* A select is easy to generate when you have a key=>value pair to work with
* This method will generate a key=>value pair of author id => author name
*
* @return Array
*/
public static function getIdNamePair()
{
$authors = array();
$collection = Author::all();
foreach ($collection as $author) {
$authors[$author->id] = $author->name;
}
return $authors;
}
示例2: index
public function index()
{
$data = Author::all(['id', 'name']);
if (Datatable::shouldHandle()) {
return Datatable::collection($data)->showColumns('id', 'name')->addColumn('1', function ($model) {
$html = '<a href="' . route('admin.authors.edit', $model->id) . '" class="btn btnn"> <i class="mdi-editor-mode-edit"></i> </a>';
return $html;
})->addColumn('2', function ($model) {
$html = Form::open(['route' => ['admin.authors.destroy', $model->id], 'method' => 'delete']);
$html .= '<button class="btn btnn" type="submit"> <i class="mdi-action-delete"></i> </button>';
$html .= Form::close();
return $html;
})->searchColumns('name')->orderColumns('name')->make();
}
return View::make('authors.index')->withTitle('Penulis');
}
示例3: testFindWithHash
public function testFindWithHash()
{
$this->assertNotNull(Author::find(array('name' => 'Tito')));
$this->assertNotNull(Author::find('first', array('name' => 'Tito')));
$this->assertEquals(1, count(Author::find('all', array('name' => 'Tito'))));
$this->assertEquals(1, count(Author::all(array('name' => 'Tito'))));
}
示例4: test_find_with_hash
public function test_find_with_hash()
{
$this->assert_not_null(Author::find(array('name' => 'Tito')));
$this->assert_not_null(Author::find('first', array('name' => 'Tito')));
$this->assert_equals(1, count(Author::find('all', array('name' => 'Tito'))));
$this->assert_equals(1, count(Author::all(array('name' => 'Tito'))));
}
示例5: showAuthors
public function showAuthors()
{
$data = Author::all();
$this->throwError($data);
return Response::json($data);
}
示例6: index
function index()
{
global $twig;
$authors = new Author();
echo $twig->render('author_list.html', array('authors' => $authors->all()));
}
示例7: editUser
public function editUser($id = null)
{
if (Input::has('submit')) {
$id = Input::get('id');
$rules = array('password' => 'required', 'password2' => 'required|same:password', 'role' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->passes()) {
$user = User::find($id);
$user->password = Hash::make(Input::get('password'));
$user->idauthor = Input::get('author');
$user->role = Input::get('role');
$user->save();
return Redirect::to('admin/eduser/' . $id)->with('sukses', 'Ubah data User berhasil!');
} else {
return Redirect::to('admin/eduser/' . $id)->withErrors($validator)->withInput();
}
} else {
$user = User::find($id);
$act = 'edit';
$tmp = Author::all();
$authors = array();
$authors[0] = '-- PILIH AUTHOR --';
foreach ($tmp as $value) {
$authors[$value->id] = $value->authorname;
}
$role = array(1 => 'admin', 2 => 'contributor', 3 => 'viewer');
return View::make('admin.user', compact('user', 'act', 'authors', 'role'));
}
}
示例8: index
/**
* Get all Authors
*
* return array {@type Author}
*
* @view authorView
*
*/
public function index()
{
return Author::all();
}