コード例 #1
0
ファイル: SubdootController.php プロジェクト: nehero/updoot
 function bundlePost($request)
 {
     $data = $request->except(['subdoot']);
     $slugify = new Slugify();
     $data['slug'] = $slugify->slugify($request->get('title'), '_');
     if (strlen($data['slug']) > 46) {
         $data['slug'] = substr($data['slug'], 0, 46);
     }
     //6 character string for a permalink
     $permalink = $this->generateRandomString();
     //Make sure the permalink is unique
     while (Post::wherePermalink($permalink)->exists()) {
         $permalink = $this->generateRandomString();
     }
     $data['permalink'] = $permalink;
     //Insert the post into the db
     $post = new Post($data);
     //Attach the post to the user who created it
     //$post->user()->associate(\App\User::find(Auth::user()->id));
     // $user = \App\User::find(Auth::user()->id);
     // $subdoot = Subdoot::find($request->get('subdoot'));
     // $user->posts()->save($post);
     // $subdoot->posts()->save($post);
     $post->user()->associate(\App\User::find(Auth::user()->id));
     $post->save();
     $post->subdoot()->associate(Subdoot::find($request->get('subdoot')));
     $post->save();
     //Attach the post to the subdoot it was submitted in
     //$post->subdoot()->associate(Subdoot::find($request->get('subdoot')));
     return $post;
 }
コード例 #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required', 'excerpt' => 'required|max:200', 'photo_description' => 'required', 'category_id' => 'required']);
     $post = new Post(array('title' => $request->get('title'), 'excerpt' => $request->get('excerpt'), 'body' => $request->get('textarea-body'), 'slug' => str_slug($request->get('title')), 'likes' => 0, 'opened' => 0, 'deleted' => 0, 'published_at' => $request->get('published_at') ? $request->get('published_at') : Carbon::now(), 'user_id' => Auth::user()->id, 'photo_description' => $request->get('photo_description'), 'category_id' => $request->get('category_id')));
     $post->save();
     if ($request->get('tags')) {
         foreach ($request->get('tags') as $tag_id) {
             $post_tags = new PostTags(array('post_id' => $post->id, 'tag_id' => $tag_id));
             $post_tags->save();
         }
     }
     if ($request->file('file')) {
         $path = $this->_post_photo_path;
         foreach ($request->file('file') as $file) {
             $name = uniqid() . "_" . $file->getClientOriginalName();
             // $coverAbsoluteFilePath = $file->getRealPath();
             //$coverExtension = $file->getClientOriginalExtension();
             // optimize (overwrite)
             //  $opt = new ImageOptimizer();
             // $opt->optimizeImage($coverAbsoluteFilePath, $coverExtension);
             $file->move($path, $name);
             $post->photos()->create(['name' => $name, 'path' => $path]);
             //unlink($path);
         }
         $post->save();
     }
     //flash()->error('Success!','Your flyer has been created');
     //flash()->overlay('Success!','Your flyer has been created');
     //flash()->overlay('Pavyko!','Naujiena sukurta!');
     //flash()->success('Success!','Your flyer has been created');
     return redirect()->back();
 }
コード例 #3
0
ファイル: PostController.php プロジェクト: unbolt/imp
 public function store(Request $request)
 {
     if ($request->thread_id) {
         $this->validate($request, ['content' => 'required']);
     } else {
         $this->validate($request, ['title' => 'required|max:255', 'content' => 'required']);
     }
     // Create a new post
     $post = new Post();
     $post->title = $request->title;
     $post->content = $request->content;
     $post->forum_id = $request->forum_id;
     $post->user_id = Auth::user()->id;
     $post->reply_on = Carbon::now();
     // Check if this is in response to another Thread
     if ($request->thread_id) {
         $post->thread_id = $request->thread_id;
     } else {
         // It's a new post, so add a slug for it
         $post->slug = str_slug($request->title, '-');
     }
     if ($post->save()) {
         // Post is made
         // Update users posts count
         $user = Auth::user();
         $user->increment('post_count');
         $user->save();
         // Update the thread if required
         if ($request->thread_id) {
             $thread = Post::find($request->thread_id);
             $thread->timestamps = false;
             $thread->reply_on = Carbon::now();
             $thread->save();
         }
         // Update the forum post count
         /*
         $forum = Forum::find($post->forum_id);
         
         if($post->thread_id) {
             // This is in reply to another post, update the post count
             $forum->increment('reply_count');
         } else {
             // This is a fresh post, update topic count
             $forum->increment('post_count');
         }
         
         $forum->save();
         */
         Session::flash('alert-success', 'Post made!');
     } else {
         Session::flash('alert-error', 'Could not create post.');
     }
     if ($post->slug) {
         // New post, send them to it
         return redirect('/thread/' . $post->id . '/' . $post->slug);
     } else {
         // Reply to post, send them back to it
         return back();
     }
 }
コード例 #4
0
 public function store(PostFormRequest $request)
 {
     $post = new Post(['title' => $request->get('title'), 'content' => $request->get('content'), 'slug' => Str::slug($request->get('title'), '-')]);
     $post->save();
     $post->categories()->sync($request->get('categories'));
     return redirect('/admin/posts/create')->with('status', 'The post has been created!');
 }
コード例 #5
0
 public function store(Request $request)
 {
     $post = new Post();
     $post->title = $request->title;
     $post->body = $request->body;
     $post->save();
 }
コード例 #6
0
 public function postAddContent()
 {
     $url = Input::get('url');
     if (strpos($url, 'youtube.com/watch?v=') !== FALSE) {
         $type = 'youtube';
         $pieces = explode("v=", $url);
         $mediaId = $pieces[1];
     } else {
         if (strpos($url, 'vimeo.com/channels/') !== FALSE) {
             $type = 'vimeo';
             $pieces = explode("/", $url);
             $mediaId = $pieces[5];
         } else {
             if (strpos($url, 'soundcloud.com/') !== FALSE) {
                 $type = 'soundcloud';
                 $mediaId = 'null';
             } else {
                 $type = 'other';
                 $mediaId = 'null';
             }
         }
     }
     $userId = Auth::id();
     $post = new Post();
     $post->url = $url;
     $post->type = $type;
     $post->userId = $userId;
     $post->mediaId = $mediaId;
     $post->save();
     return redirect('/content')->with('success', 'Post successfully created!');
 }
コード例 #7
0
 /** Save a naw post
  * @param Request $request
  * @return Response of the ajax request.
  */
 public function store(Request $request)
 {
     //ajax storage.
     //1. check if its out form.
     if (Session::token() !== Input::get('_token')) {
         return response()->json(array('message' => 'unauthorized attempt to sent a post'));
     }
     //get the oldest post id. this will be used to append to the post ul.
     $old_post = DB::table('posts')->max('id');
     //2. retreive the data in the form.
     $post = new Post();
     $post->title = Input::get('title');
     $post->body = Input::get('body');
     $post->post_author_id = Auth::id();
     if ($post->save()) {
         //get the profile image of the use.
         $profile_image_name = Profile::find(Auth::id())->pluck('profile_image_name');
         // create a json response and return it.
         $response = array('title' => $post->title, 'body' => $post->body, 'post_author_id' => $post->post_author_id, 'user_id' => Auth::id(), 'profile_image_name' => $profile_image_name, 'post_id' => $post->id, 'old_post' => $old_post, 'nickname' => $request->user()->nickname, 'message' => 'Your message has been posted', 'status' => 'success');
         return response()->json($response, 200);
     } else {
         //500 = Internal server error
         return response('Sorry, An Error Occurred. Please retry the request', 500);
     }
 }
コード例 #8
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');
 }
コード例 #9
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');
 }
コード例 #10
0
 public function store(PostsRequest $request)
 {
     $post = new Post();
     $post->title = $request->input('title');
     $post->content = $request->input('content');
     $post->save();
 }
コード例 #11
0
 /**
  *发帖
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     if (!Auth::check()) {
         return response()->json(['errno' => 2, 'msg' => 'require authentication']);
     }
     $title = $request->input('title');
     $content = $request->input('content');
     $subject_id = $request->input('subject_id');
     $ba_id = $request->input('ba_id');
     if (!$title || !$content || !$subject_id || !$ba_id) {
         return response()->json(['errno' => 3, 'msg' => 'need title ,content ,subject_id,ba_id']);
     }
     $post = new Post();
     $post->uid = Auth::user()->id;
     $post->title = $title;
     $post->content = $content;
     $post->pics = $request->input('pics');
     $post->subject_id = $subject_id;
     $post->ba_id = $ba_id;
     $post->at_users = $request->input('at_users');
     $post->last_comment_id = $post->uid;
     //$post->last_comment_at=time();
     $post->save();
     return response()->json(['errno' => 0, 'msg' => 'success', 'pid' => $post->pid]);
 }
コード例 #12
0
ファイル: Post.php プロジェクト: harmjanhaisma/clearboard
 /**
  * Create a new post
  * @param string $body Content of post, will be run through filters
  * @param integer $threadid Thread ID
  * @param integer| $posterid Poster's ID. Defaults to currently authenticated user
  * @param bool|false $hidden Is the post hidden from normal view?
  * @param bool|true $save Should the post be automatically saved into the database?
  * @return Post The resulting post object
  */
 public static function newPost($body, $threadid, $posterid = null, $hidden = false, $save = true)
 {
     // Check users rights
     if (!Auth::check() && $posterid === null) {
         abort(403);
         // 403 Forbidden
     }
     // Check thread
     $thread = Thread::findOrFail($threadid);
     if ($thread->locked) {
         abort(403);
         // 403 Forbidden
     }
     // Run post through filters
     $body = PostProcessor::preProcess($body);
     // Create new post
     $post = new Post();
     $post->thread_id = $threadid;
     $post->poster_id = Auth::user()->id;
     $post->body = $body;
     $post->hidden = $hidden;
     // defaults to false
     // Put post into database
     if ($save) {
         $post->save();
     }
     return $post;
 }
コード例 #13
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $post = new Post();
     $post->user_id = $request->user_id;
     $post->message = $request->message;
     $post->save();
 }
コード例 #14
0
 public function create()
 {
     // dd('asdasd');
     $post = new Post(['title' => 'My Awesome Blog Post', 'body' => 'My Body', 'user_id' => 1]);
     $post->save();
     // $post = Post::findOrFail(4);
     // dd($post->slug, $post->getSlug());
 }
コード例 #15
0
 public function store()
 {
     $post = new Post();
     $post->user_id = Auth::user()->id;
     $post->text = filter_var(input::get('post'), FILTER_SANITIZE_STRING);
     $post->save();
     return redirect('/home');
 }
コード例 #16
0
ファイル: StorePost.php プロジェクト: pastoralbanojr/BlogNow
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $post = new Post();
     $post->user_id = $this->user_id;
     $post->title = $this->title;
     $post->message = $this->message;
     $post->save();
 }
コード例 #17
0
ファイル: PostController.php プロジェクト: alnutile/demo
 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $post = new Post();
     $post->title = $request->input("title");
     $post->body = $request->input("body");
     $post->save();
     return redirect()->route('posts.index')->with('message', 'Item created successfully.');
 }
コード例 #18
0
ファイル: PostController.php プロジェクト: sukruthmk/cast
 public function savePost(Request $request)
 {
     $post = new Post();
     $post->message = $request->input('message');
     $post->user_id = Auth::id();
     $post->save();
     return response()->json($post);
 }
コード例 #19
0
 public function reschedule(Post $post)
 {
     $post->posted_at = $this->request->input('posted_at');
     $success = $post->save();
     $job = (new PublishPost($post))->onQueue('publish');
     $queued = $this->dispatch($job);
     return compact('success', 'queued');
 }
コード例 #20
0
 public function store(Request $request)
 {
     $post = new Post();
     $post->title = $request->title;
     $post->body = $request->body;
     $post->save();
     return redirect('/blog/archive');
 }
コード例 #21
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $post = new App\Post();
     $post->user_id = \Auth::user()->id;
     $post->content = $request->post_content;
     $post->save();
     return $post;
 }
コード例 #22
0
 public function create($name, $title)
 {
     $post = new Post();
     $post->name = $name;
     $post->title = $title;
     $post->save();
     return $post;
 }
コード例 #23
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);
 }
コード例 #24
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $post = new Post();
     $post->title = $request->title;
     $post->content = $request->content;
     $post->slug = $request->slug;
     $post->user_id = $request->user_id;
     $post->save();
 }
コード例 #25
0
 public function create()
 {
     $input = Request::all();
     $post = new Post();
     $post->title = $input['title'];
     $post->body = $input['body'];
     $post->save();
     return redirect("/posts");
 }
コード例 #26
0
 public function create(Request $request)
 {
     $this->validate($request, ['name' => 'required', 'topic' => 'required']);
     $post = new Post();
     $post->name = $request->input('name');
     $post->topic = $request->input('topic');
     $post->save();
     return response()->success(compact('post'));
 }
コード例 #27
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(PostFormRequest $request)
 {
     $post = new Post();
     $post->title = $request->input('title');
     $post->author = $request->input('author');
     $post->body = $request->input('body');
     $post->save();
     return redirect('posts');
 }
コード例 #28
0
 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|min:3', 'body' => 'required|max:250']);
     $post = new Post();
     $post->title = $request->input("title");
     $post->body = $request->input("body");
     $post->user_id = Auth::guest() ? 0 : 1;
     $post->save();
     return redirect()->route('posts.index')->with('message', 'Post created successfully.');
 }
コード例 #29
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $post = new Post();
     $post->user_id = $request->input('user_id');
     $post->is_look = $request->input('is_look');
     if (!$post->save()) {
         throw new BadRequestHttpException($post->getErrors());
     }
     return response()->json($post, 201);
 }
コード例 #30
0
 public function store(Request $request)
 {
     $input = $request->all();
     $post = new Post();
     $post->title = $input['title'];
     $post->slug = $input['slug'];
     $post->content = $input['content'];
     $post->save();
     return redirect('/');
 }