0
votes

I install Auth in my laravel project. In my user table i define a role colum for define Teacher and Student. so in my blade page I want to give access some part for the teacher and hide that part for the student. But I can't do that. Here is my code: this part only for the teacher.

@if($user->role==Teacher)
<div class="">
<div class="">
    <div class="col-md-7 col-md-offset-3">
    {!! Form::open(['files'=>true])!!}
        <div class="panel panel-default">
            <div class="panel-heading">Submit your works</div>
                <div class="panel-body">
                    <div class="form-group>">
                        <label>Write a new title</label>
                            <textarea class="form-control" name="assainments" id="assainments"></textarea>
                    </div>
                </div>
                <div class="panel-footer clearfix">
                    <div class="row">
                       <div class="col-md-6">
                            <label for="file-upload" class="custom-file-upload">
                                    <i class="glyphicon glyphicon-paperclip"></i>
                            </label>
                                <input id="file-upload" name="status_file_upload" type="file"/>

                        </div>

                        <div class="col-md-6">
                            <button class="btn btn-info pull-right btn-am"><i class="fa fa-plus">Add works</i></button>
                        </div>


                    </div>
                </div>

            </div>
            @endif
1
to use $user in View you need to pass it in the view - jaysingkar
show me ur controller code - YaSh Chaudhary

1 Answers

1
votes

To use the $userin your view you need to pass it from the controller or the method from which you are calling the view.<br/> Or instead of$useryou can useAuth::user()`:

@if(Auth::user()->role==Teacher)