コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 30) as $index) {
         Post::create(['title' => $faker->sentence(5), 'body' => $faker->paragraph(4), 'publiced' => $faker->boolean()]);
     }
 }
コード例 #2
0
 public function run()
 {
     DB::table('posts')->delete();
     Post::create(['author' => 'Noah', 'email' => '*****@*****.**', 'subject' => 'This is great', 'body' => 'Hi everyone. Just testing out the API! This is wonderful!']);
     Post::create(['author' => 'Anonymous', 'email' => '*****@*****.**', 'subject' => 'I\'m not sure I like this', 'body' => 'This is the body of my post. It\'s great, isn\'t it?']);
     Post::create(['author' => 'NJFan', 'email' => '*****@*****.**', 'subject' => 'New Jersey', 'body' => 'New Jersey is a state in the United States of America.']);
 }
コード例 #3
0
ファイル: getLatestPosts.php プロジェクト: aboustayyef/ysn
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $hashtag = $this->argument('hashtag');
     $GetterClass = '\\App\\Getters\\' . $this->argument('provider') . 'Getter';
     $TransformerClass = 'App\\Transformers\\' . $this->argument('provider') . 'Transformer';
     $getter = new $GetterClass();
     $this->info('Getting posts from ' . $this->argument('provider'));
     $posts = $getter->getList($this->argument('howmany'), $this->argument('hashtag'));
     // transform posts
     foreach ($posts as $key => $post) {
         $transformer = new $TransformerClass($post);
         $currentPost = $transformer->get();
         // store if it doesn't already exist
         if (!Post::has($currentPost['post_id'])) {
             // check if post is popular enough
             if ($this->argument('qualityThreshold')) {
                 if ($transformer->isPopular($this->argument('qualityThreshold'))) {
                     Post::create($currentPost);
                 }
             } else {
                 Post::create($currentPost);
             }
         }
     }
     // Cache last 50 posts
     $this->comment('Caching last fifty posts');
     $lastFiftyPosts = \App\Post::orderBy('date_published', 'DESC')->take(50)->get();
     Cache::put('lastFiftyPosts', $lastFiftyPosts, 5);
 }
コード例 #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $regles = array('titre' => 'required|min:5|max:40', 'contenu' => 'required|min:200', 'chapo' => 'required|max:300', 'publie' => 'required', 'photo' => 'image');
     $validation = Validator::make(Request::all(), $regles);
     if ($validation->fails()) {
         return redirect()->back()->withErrors($validation)->withInput();
     } else {
         Request::input('publie') == 'oui' ? $publie = true : ($publie = false);
         $slug = Str::slug(Request::input('titre'));
         $photo = Input::file('photo');
         if ($photo != null && $photo->isValid()) {
             $destinationPath = public_path() . '\\uploads\\posts';
             // upload path
             $extension = $photo->getClientOriginalExtension();
             // getting image extension
             $fileName = uniqid('post' . $slug . '-') . '.' . $extension;
             // renameing image
             $uploadSuccess = $photo->move($destinationPath, $fileName);
             if ($uploadSuccess) {
                 $path = asset('uploads/posts') . '/' . $fileName;
             }
         } else {
             $photo = '';
         }
         $article = Post::create(['titre' => Request::input('titre'), 'contenu' => Request::input('contenu'), 'slug' => $slug, 'chapo' => Request::input('chapo'), 'publie' => $publie, 'photo' => $path]);
     }
     return redirect()->route('post.show', ['post' => $article->id]);
 }
コード例 #5
0
ファイル: PostsTableSeeder.php プロジェクト: nayed/lab
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create('fr_FR');
     foreach (range(1, 10) as $index) {
         Post::create(['user_id' => rand(1, 4), 'title' => $faker->sentence, 'body' => $faker->paragraph]);
     }
 }
コード例 #6
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $field = new StdClass();
     $field->type = "text";
     $field->name = "indredient1";
     $field->title = "Ingredient 1";
     $field->description = "Dit is de omschrijving";
     $field->validation = "required";
     $field->value = "Appels";
     $field1 = new StdClass();
     $field1->type = "textarea";
     $field1->name = "indredient2";
     $field1->title = "Indredient 2";
     $field1->description = "Dit is de omschrijving";
     $field1->validation = "required";
     $field1->value = "Bloem";
     $field2 = new StdClass();
     $field2->type = "hidden";
     $field2->name = "indredient3";
     $field2->title = "Indredient 3";
     $field2->description = "Dit is de omschrijving";
     $field2->validation = "required";
     $field2->value = "Kaneel";
     $data = array('indredient1' => $field, 'indredient2' => $field1, 'indredient3' => $field2);
     Post::create(["title" => "Appeltaart bakken", "content" => "Het meest eenvoudige appeltaart recept blijft het lekkerst. Dat gaat zeker op voor dit authentieke appeltaart recept van Koopmans. Met dit eenvoudige appeltaart recept maak je gemakkelijk deze Oudhollandse traktatie. Daar hoef je geen keukenprins of keukenprinses voor te zijn (maar dat mag natuurlijk wel). Volg het appeltaart recept op de achterkant en binnen twee uur heb je een heerlijke appeltaart op tafel staan. Ideaal als traktatie tijdens een verjaardagsfeestje voor jezelf of één van je kinderen, of gewoon zomaar, lekker bij de koffie. Met dit makkelijke appeltaart recept van Koopmans maak je iedereen blij. Jong én oud!", "url" => "appeltaart-bakken", "data" => "", "type" => "page"]);
     Post::create(["title" => "Lorem ipsum", "content" => "Lorem ipsum etc. etc.", "url" => "lorum-impsum", "data" => "", "type" => "page"]);
     Post::create(["title" => "Pagina van type Video", "content" => "Het meest eenvoudige appeltaart recept blijft het lekkerst. Dat gaat zeker op voor dit authentieke appeltaart recept van Koopmans. Met dit eenvoudige appeltaart recept maak je gemakkelijk deze Oudhollandse traktatie. Daar hoef je geen keukenprins of keukenprinses voor te zijn (maar dat mag natuurlijk wel). Volg het appeltaart recept op de achterkant en binnen twee uur heb je een heerlijke appeltaart op tafel staan. Ideaal als traktatie tijdens een verjaardagsfeestje voor jezelf of één van je kinderen, of gewoon zomaar, lekker bij de koffie. Met dit makkelijke appeltaart recept van Koopmans maak je iedereen blij. Jong én oud!", "url" => "appeltaart-bakken", "data" => "", "type" => "video"]);
     Post::create(["title" => "Post 1", "content" => "Lorem ipsum etc. etc.", "url" => "Nullam pharetra imperdiet tempor. Aliquam erat volutpat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed a dapibus augue. Donec suscipit lobortis dapibus. Nam felis tellus, finibus facilisis est ut, aliquet posuere urna. Quisque auctor quis magna ac vulputate. Etiam consequat nunc a leo elementum faucibus.", "data" => "", "type" => "post"]);
     Post::create(["title" => "Post 2", "content" => "Nullam pharetra imperdiet tempor. Aliquam erat volutpat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed a dapibus augue. Donec suscipit lobortis dapibus. Nam felis tellus, finibus facilisis est ut, aliquet posuere urna. Quisque auctor quis magna ac vulputate. Etiam consequat nunc a leo elementum faucibus.", "url" => "appeltaart-bakken", "data" => "", "type" => "post"]);
     Post::create(["title" => "Post 3", "content" => "Nullam pharetra imperdiet tempor. Aliquam erat volutpat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed a dapibus augue. Donec suscipit lobortis dapibus. Nam felis tellus, finibus facilisis est ut, aliquet posuere urna. Quisque auctor quis magna ac vulputate. Etiam consequat nunc a leo elementum faucibus.", "url" => "lorum-impsum", "data" => "", "type" => "post"]);
 }
コード例 #7
0
 public function store(Request $request)
 {
     $post = Post::create(['title' => $request->title, 'slug' => $request->slug, 'content' => $request->content, 'image' => $request->image, 'author' => $request->author]);
     foreach ($request->categories as $category) {
         $post_category = PostCategory::create(['post_id' => $post->id, 'cat_id' => $category]);
     }
 }
コード例 #8
0
ファイル: PostController.php プロジェクト: boosb/test
 /**
  * Store a newly created Post
  *
  * @param PostCreateRequest $request
  */
 public function store(PostCreateRequest $request)
 {
     //dd($request->all());
     Post::create($request->postFillData());
     //$post->syncTags($request->get('tags', []));
     return redirect()->route('admin.post.index')->withSuccess('新文章创建完成.');
 }
コード例 #9
0
ファイル: PostController.php プロジェクト: Yuth-Set/cms
 public function store(PostRequest $request)
 {
     // dd($request->all());
     $post = Post::create($request->all());
     $post->tags()->attach($request->input('tag_list'));
     return redirect('dash/post')->with('message', 'Post was create success.');
 }
コード例 #10
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     foreach (range(1, 10) as $number) {
         Post::create(['title' => '(db) post title ' . $number, 'content' => '(db) post content']);
     }
 }
コード例 #11
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|min:3|max:100', 'description' => 'required|min:10', 'visible' => 'required']);
     $data = $request->all();
     if ($request->file) {
         $validate = ImageHelper::validate($request->file, 2000000);
         if (!$validate['success']) {
             return response()->json([$validate['message']], 422);
         }
     }
     if (isset($data['files'])) {
         $validate_multiple = ImageHelper::validateMultiple($data['files'], 20000000);
         if (!$validate_multiple['success']) {
             return response()->json([$validate_multiple['message']], 422);
         }
     }
     if ($request->file) {
         $image = ImageHelper::create($data['file'], 600, 'admin/images/posts/');
         $data['image'] = $image['filename'];
     }
     $post = Post::create($data);
     if (isset($data['files'])) {
         $image_multiple = ImageHelper::createMultiple($data['files'], 600, 'admin/images/posts/');
         for ($i = 0; $i < count($data['files']); $i++) {
             $post->PostImages()->save(new PostImages(['name' => $image_multiple['filenames'][$i]]));
         }
     }
     return response()->json(['message' => 'Post successfully Created']);
 }
コード例 #12
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Post::create(['title' => $faker->sentence, 'body' => $faker->paragraph]);
     }
 }
コード例 #13
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $objects = factory(Post::class, 300)->make();
     foreach ($objects as $var) {
         Post::create($var->toArray());
     }
 }
コード例 #14
0
ファイル: PostController.php プロジェクト: Ruiming/blog
 /**
  * 存储文章到数据库
  *
  * @param PostCreateRequest $request
  */
 public function store(PostCreateRequest $request)
 {
     $post = Post::create($request->postFillData());
     $counts = Archive::where('name', '=', $request->archive)->first()->counts;
     $archive = Archive::where('name', '=', $request->archive)->update(['counts' => $counts + 1]);
     return redirect()->route('admin.post.index')->withSuccess('New Post Successfully Created.');
 }
コード例 #15
0
ファイル: DatabaseSeeder.php プロジェクト: bibanon/4archive
 public function run()
 {
     DB::table('update_records')->delete();
     DB::table('view_cache')->delete();
     DB::table('posts')->delete();
     DB::table('threads')->delete();
     ##################
     Thread::create(['id' => 1, 'thread_id' => 111111111, 'board' => 'a', 'updated_num' => 0, 'views' => '500', 'notice' => null, 'secret' => 'a719c9a1', 'takedown_reason' => null, 'tweeted_at' => null]);
     Post::create(['chan_id' => 111111111, 'thread_id' => 1, 'original_image_name' => 'Imgur.jpg', 'image_size' => 128000, 'image_width' => '535', 'image_height' => '535', 'thumb_width' => '250', 'thumb_height' => '250', 'image_url' => 'http://i.imgur.com/UmmyTUG.png', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 111111112, 'thread_id' => 1, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 111111113, 'thread_id' => 1, 'original_image_name' => 'Imgur 2.jpg', 'image_size' => 34000, 'image_width' => '500', 'image_height' => '466', 'thumb_width' => '116', 'thumb_height' => '125', 'image_url' => 'http://i.imgur.com/w6pQEvY.jpg', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 111111114, 'thread_id' => 1, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     ##################
     Thread::create(['id' => 2, 'thread_id' => 222222222, 'board' => 'b', 'updated_num' => 0, 'views' => '555', 'notice' => null, 'secret' => 'a719c9a1', 'takedown_reason' => null, 'tweeted_at' => null]);
     Post::create(['chan_id' => 222222222, 'thread_id' => 2, 'original_image_name' => 'Imgur.jpg', 'image_size' => 128000, 'image_width' => '535', 'image_height' => '535', 'thumb_width' => '250', 'thumb_height' => '250', 'image_url' => 'http://i.imgur.com/UmmyTUG.png', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 222222223, 'thread_id' => 2, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 222222224, 'thread_id' => 2, 'original_image_name' => 'Imgur 2.jpg', 'image_size' => 34000, 'image_width' => '500', 'image_height' => '466', 'thumb_width' => '116', 'thumb_height' => '125', 'image_url' => 'http://i.imgur.com/w6pQEvY.jpg', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 222222225, 'thread_id' => 2, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     ##################
     Thread::create(['id' => 3, 'thread_id' => 333333333, 'board' => 'g', 'updated_num' => 3, 'views' => '123', 'notice' => 'Admin note: This thread is garbage.', 'secret' => 'a719c9a1', 'takedown_reason' => null, 'tweeted_at' => null]);
     Post::create(['chan_id' => 333333333, 'thread_id' => 3, 'original_image_name' => 'Imgur.jpg', 'image_size' => 128000, 'image_width' => '535', 'image_height' => '535', 'thumb_width' => '250', 'thumb_height' => '250', 'image_url' => 'http://i.imgur.com/UmmyTUG.png', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 333333334, 'thread_id' => 3, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 333333335, 'thread_id' => 3, 'original_image_name' => 'Imgur 2.jpg', 'image_size' => 34000, 'image_width' => '500', 'image_height' => '466', 'thumb_width' => '116', 'thumb_height' => '125', 'image_url' => 'http://i.imgur.com/w6pQEvY.jpg', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 333333336, 'thread_id' => 3, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     ##################
     Thread::create(['id' => 4, 'thread_id' => 444444444, 'board' => 'q', 'updated_num' => 10, 'views' => '1250', 'notice' => null, 'secret' => 'a719c9a1', 'takedown_reason' => null, 'tweeted_at' => null, 'deleted_at' => DB::raw('NOW()')]);
     Post::create(['chan_id' => 444444444, 'thread_id' => 4, 'original_image_name' => 'Imgur.jpg', 'image_size' => 128000, 'image_width' => '535', 'image_height' => '535', 'thumb_width' => '250', 'thumb_height' => '250', 'image_url' => 'http://i.imgur.com/UmmyTUG.png', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 444444445, 'thread_id' => 4, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 444444446, 'thread_id' => 4, 'original_image_name' => 'Imgur 2.jpg', 'image_size' => 34000, 'image_width' => '500', 'image_height' => '466', 'thumb_width' => '116', 'thumb_height' => '125', 'image_url' => 'http://i.imgur.com/w6pQEvY.jpg', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 444444447, 'thread_id' => 4, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
 }
コード例 #16
0
ファイル: PostController.php プロジェクト: enhive/vev
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required', 'topic' => 'required|exists:topics,title', 'content' => 'required']);
     $post = Post::create($request->all());
     Score::create(['user_id' => Auth::user()->id, 'reference' => 'post', 'score' => 50]);
     return redirect()->to('posts/' . $post->slug);
 }
コード例 #17
0
ファイル: PostController.php プロジェクト: Iloveall/stihi
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create(Request $request)
 {
     $post = Post::create($request->all());
     $post->user()->associate($this->user);
     $post->save();
     return response()->json(['success' => true, 'data' => ['post' => $post->with('user')->orderBy('id', 'desc')->first()], 'messages' => ['Новый стишок успешно добавлен :)']], 200);
 }
コード例 #18
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|max:255', 'body' => 'required']);
     Post::create($request->all());
     Session::flash('flash_message', 'Post added!');
     return redirect('posts');
 }
コード例 #19
0
ファイル: PostController.php プロジェクト: ofcadavidm/larapp
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = $this->filterInput(Request::all());
     // Validation.
     if ($this->validator($input)->fails()) {
         return Redirect::to('blog/create')->withErrors($this->validator($input))->withInput($input);
     }
     // Add the user (author) id
     $input['user_id'] = \Auth::user()->id;
     // Create a new record.
     $newPost = Post::create($input);
     // Success in saving : create a slug, add meta tags and show new blog post.
     if (isset($newPost->id) && (int) $newPost->id > 0) {
         $slug = $input['slug'];
         // Save slug.
         $slugObj = new Slug(['post_id' => $newPost->id, 'slug' => $slug]);
         $newPost->slug()->save($slugObj);
         // Save meta.
         $metaObj = new Meta(['title' => $input['title'], 'description' => $input['description'], 'twitter_card' => $input['twitter_card'], 'og_title' => $input['og_title'], 'og_image' => $input['og_image'], 'og_description' => $input['og_description'], 'post_id' => $newPost->id]);
         $newPost->slug()->save($metaObj);
         return Redirect::to("blog/{$slug}")->with("success", "A new blog post was just created.");
     }
     // Problem saving.
     return Redirect::to("blog/create")->with("failure", "Problem saving the new blog post.")->withInput($input);
 }
コード例 #20
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Request::all();
     $input['published_at'] = Carbon::now();
     \App\Post::create($input);
     return redirect('posts');
 }
コード例 #21
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::Create();
     foreach (range(1, 10) as $seededItem) {
         User::create(['first_name' => $faker->name, 'last_name' => $faker->name, 'password' => Hash::make('123456'), 'type' => false, 'sex' => $faker->boolean(), 'email' => $faker->email, 'date_of_birth' => $faker->date('Y-m-d')]);
     }
     $users = User::all()->lists('id')->toArray();
     foreach (range(1, 100) as $seededItem) {
         Post::create(['user_id' => $faker->randomElement($users), 'body' => $faker->text, 'vote_count' => 0]);
     }
     $posts = Post::all()->lists('id')->toArray();
     Comment::create(['user_id' => $faker->randomElement($users), 'body' => $faker->text, 'vote_count' => 0, 'parent_id' => null]);
     foreach (range(1, 100) as $seededItem) {
         Post_Vote::create(['user_id' => $faker->randomElement($users), 'post_id' => $faker->randomElement($posts), 'up' => $faker->boolean()]);
         Comment::create(['user_id' => $faker->randomElement($users), 'parent_id' => $faker->randomElement(Comment::all()->lists('id')->toArray()), 'post_id' => $faker->randomElement($posts), 'body' => $faker->text, 'vote_count' => 0]);
         Tag::create(['name' => $faker->text, 'private' => $faker->boolean()]);
     }
     $comments = Comment::all()->lists('id')->toArray();
     $tags = Tag::all()->lists('id')->toArray();
     foreach (range(1, 100) as $seededItem) {
         Comment_Vote::create(['user_id' => $faker->randomElement($users), 'comment_id' => $faker->randomElement($comments), 'up' => $faker->boolean()]);
         Tag_User::create(['user_id' => $faker->randomElement($users), 'tag_id' => $faker->randomElement($tags)]);
         Post_Tag::create(['tag_id' => $faker->randomElement($tags), 'post_id' => $faker->randomElement($posts)]);
     }
 }
コード例 #22
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(StoreBlogPostRequest $request)
 {
     $post = Post::create($request->all());
     $tags = $request->input('tag_list') ? $request->input('tag_list') : [];
     $post->tags()->sync($this->syncUpTags($tags));
     return redirect('/blog');
 }
コード例 #23
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Requests\CreatePostRequest $request)
 {
     //
     //Dont forget to validate variables with the request method
     $post = new Post();
     $post->title = Input::get('title');
     $post->artist = Input::get('artist');
     $post->body = Input::get('body');
     Post::create($request->all());
     //get info on image if posted
     if (Input::hasFile('thumbnail')) {
         $file = Input::file('thumbnail');
         //get name of image
         $name = time() . '-' . $file->getClientOriginalName();
         $file = $file->move(public_path() . '/images/', $name);
         $post->thumbnail = $name;
         /*
         THE FOLLOWING ARE ALL THE OPTIONS YOU HAVE ACCESS TO:
         return [
         	'path' => $file->getRealPath(),
         	'size' => $file->getSize(),
         	//'mime' => $file->getMimeType(), not working
         	'name' => $file->getClientOriginalName(),
         	'extension' =>$file->getClientOriginalExtension()
         ];
         */
     } else {
         $post->thumbnail = 'blank_avatar.jpg';
     }
     $post->save();
     return redirect('posts');
 }
コード例 #24
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  CreatePostRequest  $request
  * @return Response
  */
 public function store(CreatePostRequest $request)
 {
     $filename = str_random(20) . '.' . $request->file('image')->getClientOriginalExtension();
     $request->file('image')->move(public_path() . '/uploads', $filename);
     $data = ["title" => $request->get('title'), "slug" => str_slug($request->get('title'), '-') . '-' . mt_rand(10000, 99999), "text" => nl2br($request->get('text')), "image" => $filename];
     Post::create($data);
     return redirect()->back()->with('message', '<strong>Success!</strong> Your post needs to be activated. It will take ~24h.');
 }
コード例 #25
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     $faker = Faker::create('zh_TW');
     foreach (range(1, 20) as $id) {
         Post::create(['title' => $faker->sentence, 'sub_title' => $faker->sentence, 'content' => $faker->paragraph, 'is_feature' => rand(0, 1), 'page_view' => rand(0, 200), 'created_at' => Carbon::now()->subDays(20 - $id), 'updated_at' => Carbon::now()->subDays(20 - $id)]);
     }
 }
コード例 #26
0
ファイル: PostsController.php プロジェクト: shawon922/blog
 public function store(CreatePostRequest $request)
 {
     $post = $request->all();
     //dd($post);
     Post::create($post);
     Session::flash('success', 'The post has been saved.');
     return redirect('posts');
 }
コード例 #27
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     $faker = Factory::create('zh_TW');
     foreach (range(20, 1) as $number) {
         Post::create(['title' => $faker->sentence, 'content' => $faker->paragraph, 'is_feature' => rand(0, 1), 'created_at' => Carbon::now()->subDays($number), 'updated_at' => Carbon::now()->subDays($number)]);
     }
 }
コード例 #28
0
ファイル: DatabaseSeeder.php プロジェクト: 4unkur/blog-saas
 public function run()
 {
     $faker = Faker\Factory::create();
     Post::truncate();
     foreach (range(1, 500) as $index) {
         Post::create(['title' => $faker->unique->sentence(1), 'body' => $faker->text(1000)]);
     }
 }
コード例 #29
0
 public function run()
 {
     $posts = [['title' => 'Some news', 'content' => 'Loads of content', 'user_id' => '1', 'venue_id' => '1'], ['title' => 'Some other news', 'content' => 'Loads more content', 'user_id' => '1', 'venue_id' => '1']];
     foreach ($posts as $post) {
         Post::create(['title' => $post['title'], 'content' => $post['content'], 'user_id' => $post['user_id'], 'venue_id' => $post['venue_id']]);
         $this->command->info('Creating ' . $post['title']);
     }
 }
コード例 #30
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $user = Auth::user();
     $posts = Post::all();
     $data = $request->all();
     Post::create(['content' => $data['content'], 'user_id' => $user->id]);
     return view('wall.index', compact('user', 'posts', 'data'));
 }