本文整理汇总了PHP中app\Board::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Board::select方法的具体用法?PHP Board::select怎么用?PHP Board::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Board
的用法示例。
在下文中一共展示了Board::select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getIndex
public function getIndex()
{
if (!$this->option('adventureEnabled')) {
return abort(404);
}
$adventures = BoardAdventure::select('board_uri')->where('adventurer_ip', inet_pton(Request::ip()))->get();
$board_uris = [];
foreach ($adventures as $adventure) {
$board_uris[] = $adventure->board_uri;
}
$board = Board::select('board_uri')->whereNotIn('board_uri', $adventures)->wherePublic()->whereIndexed()->whereLastPost(48)->get();
if (count($board)) {
$board = $board->random(1);
$newAdventure = new BoardAdventure(['board_uri' => $board->board_uri, 'adventurer_ip' => inet_pton(Request::ip())]);
$newAdventure->expires_at = $newAdventure->freshTimestamp()->addHours(1);
$newAdventure->save();
} else {
$board = false;
}
return $this->view(static::VIEW_ADVENTURE, ['board' => $board]);
}
示例2: importInfinityRolesAndBoards
/**
* Imports users and creates roles based on addition data in that row.
*
* @return void
*/
public function importInfinityRolesAndBoards()
{
# BORROW SEEDERS
require base_path() . "/database/seeds/OptionSeeder.php";
require base_path() . "/database/seeds/PermissionSeeder.php";
require base_path() . "/database/seeds/RoleSeeder.php";
# DESTROY SEQUENCE
if (DB::connection() instanceof \Illuminate\Database\PostgresConnection) {
$this->comment("\tDropping role sequence.");
DB::statement("DROP SEQUENCE IF EXISTS roles_role_id_seq CASCADE;");
}
$PermissionSeeder = new \PermissionSeeder();
$PermissionSeeder->setCommand($this);
$PermissionSeeder->run();
$PermissionGroupSeeder = new \PermissionGroupSeeder();
$PermissionGroupSeeder->setCommand($this);
$PermissionGroupSeeder->run();
$OptionSeeder = new \OptionSeeder();
$OptionSeeder->setCommand($this);
$OptionSeeder->run();
$OptionGroupSeeder = new \OptionGroupSeeder();
$OptionGroupSeeder->setCommand($this);
$OptionGroupSeeder->run();
$RoleSeeder = new \RoleSeeder();
$RoleSeeder->setCommand($this);
$RoleSeeder->runMaster();
$RolePermissionSeeder = new \RolePermissionSeeder();
$RolePermissionSeeder->setCommand($this);
$RolePermissionSeeder->run();
\Artisan::call('cache:clear');
# REPAIR SEQUENCE
if (DB::connection() instanceof \Illuminate\Database\PostgresConnection) {
$this->comment("\tCreating role_id sequence again.");
DB::statement("CREATE SEQUENCE roles_role_id_seq;");
$pgSeqNext = DB::table('roles')->select(DB::raw("(MAX(\"role_id\") + 1) AS next"))->pluck("next");
DB::statement("ALTER SEQUENCE roles_role_id_seq OWNED BY \"roles\".\"role_id\" RESTART WITH {$pgSeqNext};");
DB::statement("ALTER TABLE roles ALTER COLUMN role_id SET DEFAULT nextval('roles_role_id_seq');");
}
# THEIR TABLES
$tBoardsTable = $this->tcon->table("boards")->join('board_create', 'boards.uri', '=', 'board_create.uri')->select('boards.*', 'board_create.time');
$tModsTable = $this->tcon->table("mods");
# BEGIN USER IMPORT
$this->info("\tImporting Users ...");
$userAdmin = null;
$userBoardRelationships = [];
$usersImported = 0;
$tModsTable->chunk(100, function ($mods) use(&$userAdmin, &$userBoardRelationships, &$usersImported) {
$this->line("\t\tHandling 100 users ...");
foreach ($mods as $mod) {
# CREATE USER
$user = new User(['username' => $mod->username, 'email' => property_exists($mod, "email") ? $mod->email ?: null : null, 'password' => null, 'password_legacy' => json_encode(['hasher' => "Vichan", 'hash' => $mod->password, 'salt' => $mod->salt])]);
// 8chan has an issue with duplicates.
try {
$saved = $user->save();
} catch (\Exception $e) {
$saved = false;
}
if ($saved) {
++$usersImported;
# REMEMBER ROLES
if ($mod->boards) {
// TODO
// Pull these values from config when formal importer created.
switch ($mod->type) {
// Janitor (Disabled)
case 10:
// Disabled
// Disabled
case 99:
$this->comment("\t\tMod {$user->username} is disabled.");
break;
// Board volunteer
// Board volunteer
case 19:
// Board owner
// Board owner
case 20:
if (!isset($userBoardRelationships[$mod->boards])) {
$userBoardRelationships[$mod->boards] = [];
}
$userBoardRelationships[$mod->boards][$user->user_id] = $mod->type;
break;
// Global volunteer
// Global volunteer
case 25:
$this->comment("\t\tSetting {$user->username} to Global Mod.");
$user->roles()->attach(Role::ID_MODERATOR);
break;
// Admin
// Admin
case 30:
$this->comment("\t\tSetting {$user->username} to Global Admin.");
$user->roles()->attach(Role::ID_ADMIN);
$userAdmin = $userAdmin ?: $user;
break;
//.........这里部分代码省略.........
示例3: getDetails
/**
* Returns basic board details.
*
* @return Response
*/
public function getDetails(Request $request)
{
$boardUris = Input::get('boards', []);
$boards = Board::select('board_uri', 'title')->whereIn('board_uri', $boardUris)->orderBy('board_uri', 'desc')->take(20)->get();
return $boards;
}