Exemplo n.º 1
0
 public function body()
 {
     $body = Purifier::clean($this->body);
     $body1 = str_replace('<p>', '', $body);
     $body2 = str_replace('</p>', '', $body1);
     return str_limit($body2, 300, '...');
     return $body2;
 }
Exemplo n.º 2
0
 public static function edit($post, $data)
 {
     try {
         if (!is_null($post) && $post->user->id == Auth::user()->id) {
             $post->name = $data['name'];
             $post->code = $data['code'];
             $post->public_date = date('Y-m-d H:i:s');
             $post->preview_text = Purifier::clean($data['preview_text']);
             $post->text = Purifier::clean($data['text']);
             $post->save();
         } else {
             return false;
         }
     } catch (Exception $e) {
         Log::info('Post:edit(): ' . $e->getMessage());
         return false;
     }
     return $post;
 }
Exemplo n.º 3
0
 public function putArticleUpdate($category, $article, Request $request)
 {
     $article = Article::all()->where('slug', strtolower($article))->first();
     $article->update(['title' => $request->input('title'), 'content' => Purifier::clean($request->input('content')), 'excerpt' => $request->input('excerpt'), 'category_id' => $request->input('category_id'), 'user_id' => Auth::user()->id]);
     $article->slug = $article->id . '-' . str_slug($article->title);
     if ($request->hasFile('thumbnail_link')) {
         $file = $request->file('thumbnail_link');
         $ext = $file->getClientOriginalExtension();
         $name = $article->slug . '.' . $ext;
         $manager = new ImageManager(['driver' => 'imagick']);
         $image = $manager->make($file->getRealPath());
         $image->save('uploads/articles/' . $name);
         $article->thumbnail_link = $name;
     }
     $article->save();
     return redirect('/article/' . $article->category->slug . '/' . $article->slug)->with('message', 'Article modifié avec succès.');
 }
Exemplo n.º 4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request $request
  * @param  int $id
  * @return Response
  */
 public function update(Request $request, $debate, $post)
 {
     $post = Post::find((int) $post);
     $params = $request->all();
     //dd($params);
     if (Auth::user()) {
         $params['user_id'] = Auth::user()->id;
     }
     $params['message'] = Purifier::clean($params['message']);
     $post->update($params);
     return redirect('/forum/' . $request->input('debate_id') . '/reponse')->with('message', 'Réponse modifiée avec succès.');
 }