Esempio n. 1
0
 public function getThreadAttribute()
 {
     if ($this->type == 'Thread') {
         return \Christhompsontldr\Laraboard\Models\Thread::findOrFail($this->id);
     }
     return \Christhompsontldr\Laraboard\Models\Thread::findOrFail(self::ancestors()->where('type', 'Thread')->first()->id);
 }
 public function store(Request $request)
 {
     $board = Board::findOrFail($request->parent_id);
     $this->authorize('laraboard::thread-create', $board);
     $this->validate($request, ['name' => 'required|max:255', 'body' => 'required|max:4000']);
     $post = new Post();
     $post->name = $request->name;
     $post->body = $request->body;
     $post->type = 'Thread';
     $post->user_id = \Auth::user()->id;
     $post->save();
     $post->makeChildOf($board);
     $thread = Thread::findOrFail($post->id);
     return redirect()->route('thread.show', [$thread->board->category->slug, $thread->board->slug, $thread->slug, $thread->name_slug]);
 }