/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(BlogRequest $request)
 {
     //
     $input = Request::all();
     Blog::create($input);
     return redirect('blogsAdmin');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Category $category, Request $request)
 {
     $this->validate($request, $this->rules);
     $input = Input::all();
     $category->id = Input::get('category_id');
     Blog::create($input);
     return Redirect::route('categories.show', $category->slug)->with('message', 'New blog post has been created!');
 }
 public function run()
 {
     \App\Blog::create(array('writer_id' => 1, 'title' => 'hey baba', 'content' => 'very bad'));
     \App\Blog::create(array('writer_id' => 1, 'title' => 'hey manika', 'content' => 'very bad'));
     \App\Blog::create(array('writer_id' => 2, 'title' => 'nil wakka', 'content' => 'very good'));
     \App\Blog::create(array('writer_id' => 3, 'title' => 'thor', 'content' => 'very but'));
     \App\Blog::create(array('writer_id' => 4, 'title' => 'hey nre', 'content' => 'very sin'));
 }
 public function run()
 {
     $faker = Factory::create();
     Blog::truncate();
     foreach (range(1, 100) as $index) {
         Blog::create(['title' => $faker->sentence(2), 'excerpt' => $faker->sentence(3), 'content' => $faker->sentence(20), 'published_at' => $faker->dateTime(), 'user_id' => 1]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $users = User::lists('id')->toArray();
     $categorys = Category::where('type_id', '=', Category::TYPE_BLOG)->lists('id')->toArray();
     $faker = Faker\Factory::create();
     foreach (range(1, 28) as $index) {
         Blog::create(['title' => 'blog ' . $faker->sentence(), 'body' => implode('<br>', $faker->paragraphs(16)), 'user_id' => $faker->randomElement($users), 'type_id' => Blog::TYPE_BLOG, 'category_id' => $faker->randomElement($categorys), 'last_comment_user_id' => $faker->randomElement($users)]);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * POST /
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $r)
 {
     $this->validate($r, ['title' => 'required', 'link' => '', 'content' => '']);
     $res = Blog::create(['title' => $r->get('title'), 'link' => $r->get('link'), 'content' => $r->get('content')]);
     if ($res) {
         $r->session()->flash('global', 'Запись сохранена');
         return $this->index();
     }
     return view('pages.blog.create')->withInput();
 }
 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postRegister(UserValidationRequest $request)
 {
     // extra validation specific to registering Users
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     Auth::login($this->create($request->except('blog_name')));
     $newBlog = Blog::create(['name' => $request->blog_name, 'user_id' => Auth::user()->id]);
     $newBlog->save();
     return redirect($this->redirectPath());
 }
Exemple #8
0
 public function storeNewBlog(Request $request)
 {
     $blog = new Blog();
     $id = $blog->create($request->all())->id;
     if ($request->hasFile('img')) {
         $extension = $request->file('img')->getClientOriginalExtension();
         $days = date("Ymd");
         $secs = date("His", strtotime('+1 hour'));
         $imgName = "blog_id_" . $id . "_" . $days . "_" . $secs . "." . $extension;
         $path = public_path() . '/upload/blogs';
         $image = $request->file('img');
         $request->file('img')->move($path, $imgName);
         $image = Blog::find($id);
         $image->img = $imgName;
         $image->save();
     }
     return redirect('/administration/blog/showAllBlogs');
 }
Exemple #9
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $validation = Validator::make($input, Blog::$blog_rules);
     if ($validation->passes()) {
         $image = Input::file('coverImage');
         $extension = $image->getClientOriginalExtension();
         $filename = sha1(time() . time()) . ".{$extension}";
         $upload_success = \Image::make($image)->resize(900, 600)->save(\Config::get('image.blog_image') . $filename);
         if ($upload_success) {
             Blog::create(array('summary' => Input::get('summary'), 'content' => Input::get('blogContent'), 'title' => Input::get('title'), 'coverImage' => $filename));
             return Redirect::to('adminPanel');
         }
     } else {
         $error = $validation->errors()->first();
         return Redirect::to('createBlog')->withInput(Input::all())->with(compact('error'));
     }
 }
 public function store(Request $request)
 {
     $rules = ['title' => 'required', 'content' => 'required', 'thumbnail' => 'mimes:jpeg,bmp,png,gif|max:1024'];
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return redirect('blog/create')->withErrors($validator)->withInput($request->all());
     } else {
         $data = $request->all();
         if ($request->hasFile('thumbnail')) {
             $file = $request->file('thumbnail');
             $file->move('postthumbnails', $file->getClientOriginalName());
             $data['thumbnail'] = $file->getClientOriginalName();
         }
         $data['created_by'] = Auth::user()->id;
         //dd($data);
         Blog::create($data);
         return redirect('blog/create')->with('success', 'The article has been published successfully');
     }
 }
 public function postBlog()
 {
     $blogData = Input::except('blogTags');
     $blogData['blogAuthor'] = 1;
     if ($blogData['blogDate'] == '') {
         $blogData['blogDate'] = date('Y-m-d H:i:s');
     }
     $validation = Validator::make($blogData, Blog::$postBlog);
     if ($validation->passes()) {
         $postBlog = Blog::create($blogData);
         $blogTags = Input::get('blogTags');
         foreach ($blogTags as $blogTagsData) {
             BlogTag::create(['blog_id' => $postBlog->id, 'user_id' => '1', 'tag_id' => $blogTagsData]);
         }
         $Response = array('success' => '1', 'blogId' => $postBlog->id);
     } else {
         $Response = array('success' => '0', 'err' => $validation->messages());
     }
     return $Response;
 }