当前位置: 首页>>代码示例>>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;未经允许,请勿转载。