Milos
Milos

Reputation: 602

Laravel - user status

I'm working on small Laravel project (5.8 version) and I need my user to have a status table. I created my status table $table->smallInteger('status')->default(0); and all I need now is if I change status to 1 my user should have a button for Post, but if I change it to 0 back again it needs to disappear. Here is my home.blade.php:

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">Dashboard</div>

                <div class="card-body">
                    @if (session('status'))
                        <div class="alert alert-success" role="alert">
                            {{ session('status') }}
                        </div>
                    @endif

                    You are logged in!
                    </br></br>
                        @if($user->autoplac == 1)
                            <a href="" class="btn btn-primary">New post +</a>
                        @endif
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

It shows me Undefined variable: user. How can I solve this problem? Thanks!

Upvotes: 0

Views: 271

Answers (1)

MrEvers
MrEvers

Reputation: 1072

You can always check the current logged in user with Auth::user(), so you could put your button inside an if statement

@if(Auth::user()->status)

Upvotes: 2

Related Questions