• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP app\Board类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中app\Board的典型用法代码示例。如果您正苦于以下问题:PHP Board类的具体用法?PHP Board怎么用?PHP Board使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Board类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: getBoardHistory

 public function getBoardHistory(Board $board, Post $post)
 {
     $posts = $board->posts()->with('op')->withEverything()->where('author_ip', $post->author_ip)->orderBy('post_id', 'desc')->paginate(15);
     foreach ($posts as $item) {
         $item->setRelation('board', $board);
     }
     return $this->view(static::VIEW_HISTORY, ['posts' => $posts, 'multiboard' => false]);
 }
开发者ID:GodOfConquest,项目名称:infinity-next,代码行数:8,代码来源:HistoryController.php


示例2: getPost

 /**
  * Returns a post to the client. 
  *
  * @var Board $board
  * @var Post  $post
  * @return Response
  */
 public function getPost(Board $board, Post $post)
 {
     // Pull the post.
     $post = $board->posts()->where('board_id', $post)->withEverything()->firstOrFail();
     if (!$post) {
         return abort(404);
     }
     return $post;
 }
开发者ID:JEWSbreaking8chan,项目名称:infinity-next,代码行数:16,代码来源:BoardController.php


示例3: getBoardHistory

 public function getBoardHistory(Board $board, Post $post)
 {
     if (!$this->user->canViewHistory($post)) {
         return abort(403);
     }
     $posts = $board->posts()->with('op')->withEverything()->where('author_ip', $post->author_ip)->orderBy('post_id', 'desc')->paginate(15);
     foreach ($posts as $item) {
         $item->setRelation('board', $board);
     }
     return $this->view(static::VIEW_HISTORY, ['posts' => $posts, 'multiboard' => false, 'ip' => ip_less($post->author_ip->toText())]);
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:11,代码来源:HistoryController.php


示例4: addRobotBan

 /**
  * Automatically adds a R9K ban to the specified board.
  *
  * @static
  * @param  \App\Board  $board  The board the ban is to be added in.
  * @param  binary|string|null  $ip  Optional. The IP to ban. Defaults to client IP.
  * @return static
  */
 public static function addRobotBan(Board $board, $ip = null)
 {
     $ip = new IP($ip);
     // Default time is 2 seconds.
     $time = 2;
     // Pull the ban that expires the latest.
     $ban = $board->bans()->whereIpInBan($ip)->whereRobot()->orderBy('expires_at', 'desc')->first();
     if ($ban instanceof static) {
         if (!$ban->isExpired()) {
             return $ban;
         }
         $time = $ban->created_at->diffInSeconds($ban->expires_at) * 2;
     }
     return static::create(['ban_ip_start' => $ip, 'ban_ip_end' => $ip, 'expires_at' => Carbon::now()->addSeconds($time), 'board_uri' => $board->board_uri, 'is_robot' => true, 'justification' => trans('validation.custom.unoriginal_content')]);
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:23,代码来源:Ban.php


示例5: getThreads

 /**
  * Returns a thread and its replies. 
  *
  * @param  \App\Board $board
  * @return Response
  */
 public function getThreads(Board $board)
 {
     // Determine what page we are on.
     $pages = $board->getPageCount();
     $response = [];
     for ($i = 0; $i < $pages; ++$i) {
         $pageArray = ['page' => $i, 'threads' => []];
         $threads = $board->getThreadsForIndex($i);
         foreach ($threads as $thread) {
             $pageArray['threads'][] = ['no' => (int) $thread->board_id, 'last_modified' => (int) $thread->bumped_last->timestamp];
         }
         $response[] = $pageArray;
     }
     return response()->json($response);
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:21,代码来源:BoardController.php


示例6: boardStats

 /**
  * Returns the information specified by boardStats
  *
  * @return array (indexes and vales based on $boardStats)
  */
 protected function boardStats()
 {
     $controller =& $this;
     $stats = Cache::remember('index.boardstats', 60, function () use($controller) {
         $stats = [];
         foreach ($controller->boardStats as $boardStat) {
             switch ($boardStat) {
                 case "boardIndexedCount":
                     $stats[$boardStat] = Board::whereIndexed()->count();
                     break;
                 case "startDate":
                     $stats[$boardStat] = Board::orderBy('created_at', 'desc')->take(1)->pluck('created_at')->format("M jS, Y");
                     break;
                 case "boardTotalCount":
                     $stats[$boardStat] = Board::count();
                     break;
                 case "postCount":
                     $stats[$boardStat] = Board::sum('posts_total');
                     break;
                 case "postRecentCount":
                     $stats[$boardStat] = Post::recent()->count();
                     break;
             }
         }
         return $stats;
     });
     return $stats;
 }
开发者ID:tmrwbo,项目名称:infinity-next,代码行数:33,代码来源:BoardStats.php


示例7: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('board_adventures', function (Blueprint $table) {
         $table->increments('adventure_id');
         $table->binary('adventurer_ip');
         $table->string('board_uri', 32);
         $table->integer('post_id')->unsigned()->nullable()->default(NULL);
         $table->timestamps();
         $table->timestamp('expires_at');
         $table->timestamp('expended_at')->nullable()->default(NULL);
         $table->foreign('board_uri')->references('board_uri')->on('boards')->onDelete('cascade')->onUpdate('cascade');
     });
     Schema::table('posts', function (Blueprint $table) {
         $table->integer('adventure_id')->unsigned()->nullable()->default(NULL)->after('locked_at');
         $table->foreign('adventure_id')->references('adventure_id')->on('board_adventures')->onDelete('set null')->onUpdate('cascade');
     });
     Schema::table('boards', function (Blueprint $table) {
         $table->timestamp('last_post_at')->nullable()->default(NULL)->after('updated_at');
     });
     Board::chunk(100, function ($boards) {
         foreach ($boards as $board) {
             $lastPost = $board->posts()->orderBy('created_at', 'desc')->limit(1)->get()->last();
             if ($lastPost) {
                 $board->last_post_at = $lastPost->created_at;
                 $board->save();
             }
         }
     });
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:34,代码来源:2015_08_31_021154_adventure_mode.php


示例8: boardStats

 /**
  * Returns the information specified by boardStats
  *
  * @return array (indexes and vales based on $boardStats)
  */
 protected function boardStats()
 {
     $controller =& $this;
     $stats = Cache::remember('index.boardstats', 60, function () use($controller) {
         $stats = [];
         foreach ($controller->boardStats as $boardStat) {
             switch ($boardStat) {
                 case "boardCount":
                     $stats[$boardStat] = Board::whereIndexed()->count();
                     break;
                 case "boardIndexedCount":
                     $stats[$boardStat] = Board::count();
                     break;
                 case "postCount":
                     $stats[$boardStat] = Board::sum('posts_total');
                     break;
                 case "postRecentCount":
                     $stats[$boardStat] = Post::recent()->count();
                     break;
             }
         }
         return $stats;
     });
     return $stats;
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:30,代码来源:BoardStats.php


示例9: getThread

 /**
  * Returns a thread and its replies to the client. 
  *
  * @var Board $board
  * @var integer|null $thread
  * @return Response
  */
 public function getThread(Request $request, Board $board, $thread)
 {
     if (is_null($thread)) {
         return abort(404);
     }
     $input = $request->only('updatesOnly', 'updateHtml', 'updatedSince');
     if (isset($input['updatesOnly'])) {
         $updatedSince = Carbon::createFromTimestamp($request->input('updatedSince', 0));
         $posts = Post::where('posts.board_uri', $board->board_uri)->withEverything()->where(function ($query) use($thread) {
             $query->where('posts.reply_to_board_id', $thread);
             $query->orWhere('posts.board_id', $thread);
         })->where(function ($query) use($updatedSince) {
             $query->where('posts.updated_at', '>=', $updatedSince);
             $query->orWhere('posts.deleted_at', '>=', $updatedSince);
         })->withTrashed()->orderBy('posts.created_at', 'asc')->get();
         if (isset($input['updateHtml'])) {
             foreach ($posts as $post) {
                 $appends = $post->getAppends();
                 $appends[] = "html";
                 $post->setAppends($appends);
             }
         }
         return $posts;
     } else {
         // Pull the thread.
         $thread = $board->getThreadByBoardId($thread);
         if (!$thread) {
             return abort(404);
         }
     }
     return $thread;
 }
开发者ID:nitogel,项目名称:infinity-next,代码行数:39,代码来源:BoardController.php


示例10: createBoard

 public function createBoard()
 {
     $table = json_encode([[['state' => 0], ['state' => 0], ['state' => 0]], [['state' => 0], ['state' => 0], ['state' => 0]], [['state' => 0], ['state' => 0], ['state' => 0]]]);
     $board = Board::create(['table' => $table, 'moves' => 0, 'finished' => false]);
     $player1 = Player::create(['user_id' => 1, 'board_id' => $board->id, 'winner' => null]);
     $player2 = Player::create(['user_id' => 1, 'board_id' => $board->id, 'winner' => null]);
     return redirect('/');
 }
开发者ID:NikaBuligini,项目名称:xo,代码行数:8,代码来源:HomeController.php


示例11: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $board = Board::find($id);
     if (!$board) {
         return \Response::json(['error' => ['message' => 'Board does not exist']], 404);
     }
     return \Response::json(['data' => $board->toArray()], 200);
 }
开发者ID:kylerdanielster,项目名称:Mello,代码行数:14,代码来源:BoardController.php


示例12: create

 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 public function create(array $data)
 {
     $user = User::create(['username' => $data['username'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
     // Create the user's personal pinboard
     if ($user) {
         $personalboard = Board::Create(['title' => 'My Personal Activities', 'body' => 'I will do these All Day! Erry Day!', 'shared_with' => 0, 'id_users' => $user->id]);
     }
     return $user;
 }
开发者ID:politicianmemeteam,项目名称:scrubtitles,代码行数:15,代码来源:AuthController.php


示例13: run

 public function run()
 {
     $this->command->info("Seeding boards.");
     if (Board::count() < 1) {
         $board = Board::firstOrCreate(['board_uri' => "test", 'title' => "Test", 'description' => "Discover software features on your own", 'created_by' => 1, 'operated_by' => 1]);
         $this->command->info("Success. At least one board exists now. Accessible at /test/.");
     } else {
         $this->command->info("Skipped. Site has at least one board.");
     }
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:10,代码来源:BoardSeeder.php


示例14: run

 public function run()
 {
     $this->command->info('Seeding role to user associations.');
     $userRoles = [['user_id' => 1, 'role_id' => Role::ID_ADMIN]];
     foreach (Board::get() as $board) {
         $userRoles[] = ['user_id' => $board->operated_by, 'role_id' => $board->getOwnerRole()->role_id];
     }
     foreach ($userRoles as $userRole) {
         UserRole::firstOrCreate($userRole);
     }
 }
开发者ID:Cipherwraith,项目名称:infinity-next,代码行数:11,代码来源:RoleSeeder.php


示例15: patchIndex

 /**
  * Validate and save changes.
  *
  * @return Response
  */
 public function patchIndex(BoardConfigRequest $request, Board $board)
 {
     $input = $request->all();
     $optionGroups = $request->getBoardOptions();
     foreach ($optionGroups as $optionGroup) {
         foreach ($optionGroup->options as $option) {
             $setting = BoardSetting::firstOrNew(['option_name' => $option->option_name, 'board_uri' => $board->board_uri]);
             $option->option_value = $input[$option->option_name];
             $setting->option_value = $input[$option->option_name];
             $setting->save();
         }
     }
     $board->title = $input['boardBasicTitle'];
     $board->description = $input['boardBasicDesc'];
     $board->is_overboard = isset($input['boardBasicOverboard']) && !!$input['boardBasicOverboard'];
     $board->is_indexed = isset($input['boardBasicIndexed']) && !!$input['boardBasicIndexed'];
     $board->is_worksafe = isset($input['boardBasicWorksafe']) && !!$input['boardBasicWorksafe'];
     $board->save();
     Event::fire(new BoardWasModified($board));
     return $this->view(static::VIEW_CONFIG, ['board' => $board, 'groups' => $optionGroups]);
 }
开发者ID:ee-ee,项目名称:infinity-next,代码行数:26,代码来源:ConfigController.php


示例16: __construct

 /**
  * @return void
  */
 public function __construct(UserManager $manager)
 {
     $this->userManager = $manager;
     $this->auth = $manager->auth;
     $this->registrar = $manager->registrar;
     $this->user = $manager->user;
     if ($this->option('boardListShow')) {
         View::share('boardbar', Board::getBoardListBar());
     }
     View::share('user', $this->user);
     $this->boot();
 }
开发者ID:Ryangr0,项目名称:infinity-next,代码行数:15,代码来源:Controller.php


示例17: putAdd

 /**
  * Adds new staff.
  *
  * @return Response
  */
 public function putAdd(Board $board)
 {
     if (!$board->canEditConfig($this->user)) {
         return abort(403);
     }
     $createUser = false;
     $roles = $this->user->getAssignableRoles($board);
     $rules = [];
     $existing = Input::get('staff-source') == "existing";
     if ($existing) {
         $rules = ['existinguser' => ["required", "string", "exists:users,username"], 'captcha' => ["required", "captcha"]];
         $input = Input::only('existinguser', 'captcha');
         $validator = Validator::make($input, $rules);
     } else {
         $createUser = true;
         $validator = $this->registrationValidator();
     }
     $castes = $roles->pluck('role_id');
     $casteRules = ['castes' => ["required", "array"]];
     $casteInput = Input::only('castes');
     $casteValidator = Validator::make($casteInput, $casteRules);
     $casteValidator->each('castes', ["in:" . $castes->implode(",")]);
     if ($validator->fails()) {
         return redirect()->back()->withInput()->withErrors($validator->errors());
     } else {
         if ($casteValidator->fails()) {
             return redirect()->back()->withInput()->withErrors($casteValidator->errors());
         } else {
             if ($createUser) {
                 $user = $this->registrar->create(Input::all());
             } else {
                 $user = User::whereUsername(Input::only('existinguser'))->firstOrFail();
             }
         }
     }
     $user->roles()->detach($roles->pluck('role_id')->toArray());
     $user->roles()->attach($casteInput['castes']);
     Event::fire(new UserRolesModified($user));
     return redirect("/cp/board/{$board->board_uri}/staff");
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:45,代码来源:StaffController.php


示例18: testModelAndViews

 /**
  * Tests the board model and depndant views.
  *
  * @return void
  */
 public function testModelAndViews()
 {
     // Get a board.
     $boards = Board::take(1)->get();
     // Get a board that cannot exist.
     // The maximum `board_uri` length should be, at most, 31.
     $noBoards = Board::where('board_uri', "12345678901234567890123456789012")->take(1)->get();
     $this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Collection", $boards);
     $this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Collection", $noBoards);
     $this->assertEquals(0, count($noBoards));
     if (count($boards)) {
         $this->board = $board = $boards[0];
         $this->assertInstanceOf("App\\Board", $board);
         // Test relationships
         $this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Relations\\HasMany", $board->posts());
         $this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Relations\\HasMany", $board->logs());
         $this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Relations\\HasMany", $board->threads());
         $this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Relations\\HasMany", $board->roles());
         // Test modern routes
         $response = $this->call('GET', url("{$board->board_uri}"));
         $this->assertEquals(200, $response->getStatusCode());
         $this->doBoardIndexAssertions();
         $response = $this->call('GET', url("{$board->board_uri}/1"));
         $this->assertEquals(200, $response->getStatusCode());
         $this->doBoardIndexAssertions();
         $response = $this->call('GET', url("{$board->board_uri}/catalog"));
         $this->assertEquals(200, $response->getStatusCode());
         $response = $this->call('GET', url("{$board->board_uri}/logs"));
         $this->assertEquals(200, $response->getStatusCode());
         $this->assertViewHas('board');
         $this->assertViewHas('logs');
         // Test legacy routes
         $legacyCode = env('LEGACY_ROUTES', false) ? 302 : 404;
         $response = $this->call('GET', url("{$board->board_uri}/index.html"));
         $this->assertEquals($legacyCode, $response->getStatusCode());
         $response = $this->call('GET', url("{$board->board_uri}/1.html"));
         $this->assertEquals($legacyCode, $response->getStatusCode());
         $response = $this->call('GET', url("{$board->board_uri}/catalog.html"));
         $this->assertEquals($legacyCode, $response->getStatusCode());
     } else {
         $this->assertEquals(0, Board::count());
     }
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:48,代码来源:BoardTest.php


示例19: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $firstPost = Post::orderBy('post_id', 'asc')->first()->pluck('created_at');
     $trackTime = clone $firstPost;
     $nowTime = Carbon::now()->minute(0)->second(0)->timestamp;
     $boards = Board::all();
     $this->comment("Reviewing all records.");
     while ($firstPost->timestamp < $nowTime) {
         $firstPost = $firstPost->addHour();
         $hourCount = 0;
         foreach ($boards as $board) {
             if ($board->posts_total > 0) {
                 $newRows = $board->createStatsSnapshot($firstPost);
                 $hourCount += count($newRows);
             }
         }
         if ($hourCount > 0) {
             $this->comment("\tAdded {$hourCount} new stat row(s) from " . $firstPost->diffForHumans());
         }
     }
 }
开发者ID:JEWSbreaking8chan,项目名称:infinity-next,代码行数:26,代码来源:RecordStatsAll.php


示例20: 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]);
 }
开发者ID:nitogel,项目名称:infinity-next,代码行数:21,代码来源:AdventureController.php



注:本文中的app\Board类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP app\Book类代码示例发布时间:2022-05-23
下一篇:
PHP app\Auth类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap