Ejemplo n.º 1
0
 public function store(Request $request)
 {
     $input = $request->input();
     $input['user_id'] = $this->currentUser->id;
     $post = Post::create($input);
     return redirect()->route('posts.show', $post->id);
 }
Ejemplo n.º 2
0
 public function run()
 {
     DB::table('Posts')->delete();
     Post::create(['name' => 'First Name', 'email' => '*****@*****.**', 'city' => 'City 1', 'content' => 'First Feedbuck 24', 'slag' => 'first-feed', 'published' => true, 'created_at' => time()]);
     Post::create(['name' => 'Second Name', 'email' => '*****@*****.**', 'city' => 'City 2', 'content' => 'Second Feedbuck 24', 'slag' => 'second-feed', 'published' => true, 'created_at' => time()]);
     Post::create(['name' => 'Third Name', 'email' => '*****@*****.**', 'city' => 'City 3', 'content' => 'Third Feedbuck 24sdsds', 'slag' => 'third-feed', 'published' => true, 'created_at' => time()]);
 }
Ejemplo n.º 3
0
 /**
  * 記事追加
  */
 public function postIndex(postsRequest $request)
 {
     $post = Post::create($request->all());
     $post->user_id = Auth::user()->id;
     $post->save();
     \Session::flash('flash_message', '新規追加しました。');
     return redirect('/');
 }
Ejemplo n.º 4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $posts = [['user_id' => 1, 'title' => '又一个shcms', 'content' => '欢迎你安装shcms,请开始体验吧!'], ['user_id' => 1, 'title' => 'shcms怎么用啊?', 'content' => '刚安装就报错了。请问怎么办?']];
     foreach ($posts as $post) {
         $model = \App\Model\Post::create($post);
         $this->command->info($model->id);
     }
 }
Ejemplo n.º 5
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $data = \Input::all();
     $data['user_id'] = \Auth::user()->id;
     $post = \App\Model\Post::create($data);
     $this->upExtDate($post);
     return back();
 }
Ejemplo n.º 6
0
 public function run()
 {
     DB::table('posts')->delete();
     $faker = Faker::create('ja_JP');
     for ($i = 0; $i < 10; $i++) {
         if ($i >= 5) {
             $categoryId = 2;
         } else {
             $categoryId = 1;
         }
         Post::create(['user_id' => 1, 'category_id' => $categoryId, 'title' => $faker->sentence(), 'content' => $faker->paragraph()]);
     }
 }