當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Helper::appendZero方法代碼示例

本文整理匯總了PHP中app\helpers\Helper::appendZero方法的典型用法代碼示例。如果您正苦於以下問題:PHP Helper::appendZero方法的具體用法?PHP Helper::appendZero怎麽用?PHP Helper::appendZero使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\helpers\Helper的用法示例。


在下文中一共展示了Helper::appendZero方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     for ($count = 1; $count <= 10; $count++) {
         $thread_id = rand(1, DB::table('threads')->count());
         $position = Helper::appendZero($count, 5);
         $user_id = rand(1, DB::table('users')->count());
         DB::table('replies')->insert(['thread_id' => $thread_id, 'user_id' => $user_id, 'content' => str_random(100), 'position' => $position . ',', 'depth' => 0]);
         DB::table('threads')->where('id', $thread_id)->increment('comment_count');
         DB::table('users')->where('id', $user_id)->increment('comment_count');
         $author_id = DB::table('threads')->where('id', $thread_id)->first()->author_id;
         DB::table('notifications')->insert(['type' => 1, 'user_id' => $author_id, 'content_id' => $count]);
     }
     for ($count = 11; $count <= 30; $count++) {
         $parent_id = rand(1, DB::table('replies')->count());
         $parent = DB::table('replies')->where('id', $parent_id)->first();
         $position = $parent->position . Helper::appendZero($count, 5) . ',';
         $thread_id = $parent->thread_id;
         $user_id = rand(1, DB::table('users')->count());
         DB::table('replies')->insert(['thread_id' => $thread_id, 'user_id' => $user_id, 'content' => str_random(100), 'parent_id' => $parent_id, 'depth' => $parent->depth + 1, 'position' => $position]);
         DB::table('threads')->where('id', $thread_id)->increment('comment_count');
         DB::table('users')->where('id', $user_id)->increment('comment_count');
         $author_id = DB::table('threads')->where('id', $thread_id)->first()->author_id;
         DB::table('notifications')->insert(['type' => 1, 'user_id' => $author_id, 'content_id' => $thread_id]);
     }
 }
開發者ID:rkkautsar,項目名稱:CuapCuap,代碼行數:30,代碼來源:RepliesTableSeeder.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $thread_id
  * @param  int  $parent_id
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request, $thread_id, $parent_id = null)
 {
     $user_id = Auth::user()->id;
     $position = '';
     $depth = 0;
     $thread = DB::table('threads')->where('id', $thread_id)->first();
     if ($thread == null) {
         abort(404);
     }
     if ($parent_id != null) {
         $parent = DB::table('replies')->where('id', $parent_id)->first();
         if ($parent == null || $parent->thread_id != $thread_id) {
             abort(404);
         }
         $position = $parent->position;
         $depth = $parent->depth + 1;
     }
     // Validation
     $this->validate($request, ['content' => 'string|required']);
     $content = $request->input('content');
     $id = DB::table('replies')->insertGetId(['thread_id' => $thread_id, 'user_id' => $user_id, 'parent_id' => $parent_id, 'content' => $content, 'depth' => $depth]);
     $position = $position . Helper::appendZero($id, 5) . ',';
     DB::table('replies')->where('id', $id)->update(['position' => $position]);
     DB::table('threads')->where('id', $thread_id)->increment('comment_count');
     DB::table('users')->where('id', $user_id)->increment('comment_count');
     $author_id = DB::table('threads')->where('id', $thread_id)->first()->author_id;
     DB::table('notifications')->insert(['type' => 1, 'user_id' => $author_id, 'content_id' => $thread_id]);
     return redirect('/thread/' . $thread_id);
 }
開發者ID:rkkautsar,項目名稱:CuapCuap,代碼行數:37,代碼來源:ReplyController.php


注:本文中的app\helpers\Helper::appendZero方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。