Viewing 1 post (of 1 total)
  • Author
    Posts
  • #557
    dan
    Participant

    Hi, I have an if statements such that the user can only edit if he owns the post. Snippet code as follows:

    @if( auth() -> user() == $post -> user )
    Edit
    @endif

    However this seems to be inconsistent. In some parts of the code it works , it some parts it doesn’t.

    Why cant we rely on this? I guess the best way to do it is to extract the ids as follows:

    @if( auth() -> user() -> id == $post -> user -> id)
    Edit
    @endif

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.