コード例 #1
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');
 }
コード例 #2
0
 /**
  * Store a newly created Post in storage.
  *
  * @param CreatePostRequest $request
  *
  * @return Response
  */
 public function store(CreatePostRequest $request)
 {
     $input = $request->all();
     $post = $this->postRepository->create($input);
     Flash::success('Post saved successfully.');
     return redirect(route('posts.index'));
 }
コード例 #3
0
ファイル: PostsController.php プロジェクト: shawon922/blog
 public function update($id, CreatePostRequest $request)
 {
     $editedPost = $request->all();
     $post = Post::find($id);
     $post->update($editedPost);
     Session::flash('success', 'The post has been updated.');
     return redirect('posts');
 }
コード例 #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreatePostRequest $req)
 {
     $input = $req->all();
     $input['author_id'] = \Auth::id();
     // Set author ID
     // Create post
     Post::create($input);
     return redirect('/');
 }
コード例 #5
0
ファイル: ArticleController.php プロジェクト: jamesddube/blog
 public function store(CreatePostRequest $request)
 {
     $request->merge(['image_header_url' => 'assets/image', 'user_id' => 1, 'slug' => Str::slug($request->input('title'))]);
     $post = new Article($request->all());
     $fileName = $post->savePicture($request->file('image'));
     $post->image_header_url = url($fileName);
     $user = User::find(1);
     return $user->articles()->save($post);
 }
コード例 #6
0
 public function store(CreatePostRequest $request)
 {
     $post = new Post();
     $post->title = $request->title;
     $post->body = $request->body;
     $post->user_id = $request->user()->id;
     $post->save();
     return redirect('/blog/' . $post->slug);
 }
コード例 #7
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\CreatePostRequest $request)
 {
     $user_id = Sentinel::getUser()->id;
     $lastest = PostService::getLatestSubmit($user_id);
     if (diff_timestamp($lastest->created_at) < 1 * 60) {
         return redirect()->back()->with('error', '도배 방지를 위해, 1분 이내에 글을 연속적으로 작성하실 수 없습니다.');
     }
     $post = PostService::createPost($request->all());
     return redirect()->route('posts.show', $post->id);
 }
コード例 #8
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreatePostRequest $request, Post $post)
 {
     if (Auth::user()) {
         $post = new Post($request->all());
         Auth::user()->posts()->save($post);
     } else {
         $post = new Post();
         $post->create($request->all());
     }
     return redirect()->back()->with(['success' => 'Post cadastrado com sucesso!']);
 }
コード例 #9
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreatePostRequest $request, Post $post)
 {
     $request->merge(['slug' => str_slug($request->get('title')), 'display' => 1]);
     $store = $post->create($request->all());
     $tags = tags_to_array($request->get('tags'));
     foreach ($tags as $tag) {
         $tag = Tag::firstOrCreate(['name' => $tag]);
         $store->tags()->attach($tag);
     }
     return redirect(route('admin.posts'));
 }
コード例 #10
0
ファイル: PostController.php プロジェクト: skull213/Klarity
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(\App\Http\Requests\CreatePostRequest $request)
 {
     $input = \Request::all();
     $input['user_id'] = \Auth::user()->id;
     $post = \App\Models\Post::create($input);
     foreach ($input['labels'] as $labelID) {
         $post->labels()->attach($labelID);
     }
     //move file for temp location productphotos
     $fileName = \Carbon\Carbon::now()->timestamp . "_post.jpg";
     $request->file('photo')->move('images', $fileName);
     $post->photo = $fileName;
     $post->save();
     //add a new post
     return redirect('posts/' . $post->id);
 }
コード例 #11
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreatePostRequest $request)
 {
     try {
         $inputs = $request->all();
         unset($inputs['_token']);
         $photo = $request->file('photo');
         if ($photo) {
             //Upload Image
             $uploaded_path = FileUpload::upload($photo);
             $inputs['photo'] = $uploaded_path;
         }
         Post::create($inputs);
         return redirect()->to('/crm/post/')->withMessage(Generate::success_message('Success', 'Created Successfully'));
     } catch (Exception $e) {
         return redirect()->to('/crm/post/')->withMessage(Generate::error_message('Failed', $e->getMessage()));
     }
 }
コード例 #12
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  CreatePostRequest $request
  * @return Response
  */
 public function store(CreatePostRequest $request, $category_id)
 {
     // save post
     $post = new Post();
     $post->fill($request->all());
     $post->category_id = $category_id;
     $post->save();
     // if have attachment, create the attachment record
     if ($request->hasFile('attachment')) {
         // generate filename based on UUID
         $filename = Uuid::generate();
         $extension = $request->file('attachment')->getClientOriginalExtension();
         $fullfilename = $filename . '.' . $extension;
         // store the file
         Image::make($request->file('attachment')->getRealPath())->resize(null, 640, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         })->save(public_path() . '/attachments/' . $fullfilename);
         // attachment record
         $attachment = new Attachment();
         $attachment->post_id = $post->id;
         $attachment->original_filename = $request->file('attachment')->getClientOriginalName();
         $attachment->filename = $fullfilename;
         $attachment->mime = $request->file('attachment')->getMimeType();
         $attachment->save();
     }
     return redirect('category/' . $category_id . '/posts');
 }
コード例 #13
0
ファイル: PostsController.php プロジェクト: jrafaelca/infrea
 /**
  * Store a newly created resource in storage.
  *
  * @param CreatePostRequest $request
  * @return Response
  */
 public function store(CreatePostRequest $request)
 {
     $post = new Post();
     $post->fill($request->all());
     $post->user_id = Auth::id();
     if ($request->hasFile('image')) {
         $file = $request->file('image');
         $patch = 'images/posts/';
         $name = $post->title . '.' . $file->getClientOriginalExtension();
         $image = $patch . $name;
         Image::make($file)->fit(1140, 400)->save($image);
         $post->image = $image;
     }
     $post->save();
     $message = trans('messages.post_created_successfully');
     Flash::success($message);
     return redirect()->route('admin.posts.index');
 }
コード例 #14
0
 /**
  * Store a newly created Post in storage.
  *
  * @param CreatePostRequest $request
  *
  * @return Response
  */
 public function store(CreatePostRequest $request)
 {
     $input = $request->all();
     $input['objectId'] = 'Post' . str_random(10);
     if ($request->file('image')) {
         $image = $this->uploadImage($request->file('image'), '/posts_photo/');
         $input['image'] = $image['resize_url'][0];
     }
     if ($request->file("audioFile")) {
         $input['audioFile'] = $this->uploadAudio($request->file('audioFile'), '/posts_audio/');
     }
     $post = $this->postRepository->create($input);
     $device_list = [];
     $gcm = Gcm::all();
     foreach ($gcm as $key => $value) {
         $device_list[] = PushNotification::Device($value->reg_id);
     }
     $message['title'] = $input['title'];
     $message['message'] = $input['content'];
     $devices = PushNotification::DeviceCollection($device_list);
     $message = PushNotification::Message(json_encode($message), array());
     $collection = PushNotification::app('appNameAndroid')->to($devices)->send($message);
     Flash::success('Post saved successfully.');
     return redirect(route('posts.index'));
 }
コード例 #15
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.');
 }
コード例 #16
0
 public function store(CreatePostRequest $request)
 {
     $draft = $draft = Post::where('author_id', Auth::user()->active_contact->id)->where("status_id", "=", POST_DRAFT_STATUS_ID)->where("ticket_id", $request->get("ticket_id"))->first();
     $post = $draft ? $draft : new Post();
     $post->ticket_id = $request->get('ticket_id');
     $post->post = $request->get('post');
     $post->author_id = Auth::user()->active_contact->id;
     $post->status_id = $request->get('is_public') ? POST_PUBLIC_STATUS_ID : POST_PRIVATE_STATUS_ID;
     $post->ticket_status_id = $request->get('status_id');
     if (isset($post->updated_at)) {
         $post->created_at = $post->updated_at;
     }
     $post->save();
     $ticket_updated = $this->updateTicket($request);
     EmailsManager::sendPost($post->id, $ticket_updated, $request->get('emails'));
     SlackManager::sendPost($post, $ticket_updated);
     return redirect()->route('tickets.show', $request->input('ticket_id'))->with('successes', ['Post created successfully']);
 }
コード例 #17
0
 function update(CreatePostRequest $request, $id)
 {
     $post = Post::findOrFail($id);
     $post->update($request->all());
     return redirect('posts');
 }
コード例 #18
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreatePostRequest $request)
 {
     $post = auth()->user()->posts()->create($request->all());
     $post->tags()->sync(!$request->input('tag_list') ? [] : $request->input('tag_list'));
     return redirect('posts');
 }
コード例 #19
0
 /**
  * Update the specified Post in storage.
  *
  * @param  int    $id
  * @param CreatePostRequest $request
  *
  * @return Response
  */
 public function update($id, CreatePostRequest $request)
 {
     $post = $this->postRepository->findPostById($id);
     if (empty($post)) {
         Flash::error('Post not found');
         return redirect(route('admin.posts.index'));
     }
     $post = $this->postRepository->update($post, $request->all());
     Flash::message('Post updated successfully.');
     return redirect(route('admin.posts.index'));
 }
コード例 #20
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreatePostRequest $request)
 {
     //dd($request->title);
     Post::create($request->all());
     return redirect('/posts')->with(['success' => 'Post criado com sucesso!']);
 }
コード例 #21
0
 public function storePost($id, CreatePostRequest $request)
 {
     \Auth::user()->post()->create(['article_id' => $id, 'post' => $request->input('store_post')]);
     flash()->success('Udało Ci się dodać odpowiedź do artykułu!');
     return redirect('/admin/article/' . $id . '');
 }
コード例 #22
0
 /**
  * @param CreatePostRequest $request
  * @param Dispatcher $dispatcher
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(CreatePostRequest $request, Dispatcher $dispatcher)
 {
     $dispatcher->dispatch(new PublishStatus($request->all()['status'], \Auth::user()));
     \Flash::message('Your status has been updated');
     return Redirect::back();
 }