App\Models\Forum\TopicCover::findForUse PHP Method

findForUse() public static method

public static findForUse ( $id, $user )
    public static function findForUse($id, $user)
    {
        if ($user === null) {
            return;
        }
        $covers = static::select();
        if ($user->isAdmin() === false) {
            $covers->where('user_id', $user->user_id);
        }
        return $covers->find($id);
    }

Usage Example

Example #1
0
 public function store(HttpRequest $request, $forum_id)
 {
     $this->validate($request, ['title' => 'required', 'body' => 'required']);
     $forum = Forum::findOrFail($forum_id);
     $this->authorizePost($forum, null);
     $topic = Topic::createNew(['forum' => $forum, 'title' => $request->input('title'), 'poster' => Auth::user(), 'body' => $request->input('body'), 'notifyReplies' => false, 'cover' => TopicCover::findForUse(presence($request->input('cover_id')), Auth::user())]);
     Event::fire(new TopicWasCreated($topic, $topic->posts->last(), Auth::user()));
     return ujs_redirect(route('forum.topics.show', $topic));
 }
All Usage Examples Of App\Models\Forum\TopicCover::findForUse