Lỗi underfined job trong laravel

đây là file table.blade.php :slight_smile:

 <div class="table-condensed table-hover">
    <table class="table" id="jobs-table">
        <thead>
            <tr>
        @if(Auth::check() && (Auth::user()->id == $job->user_id || Auth::user()->id == Auth::user()->role_id <3 ))
                <th> Status </th>
                <th colspan="3">Action</th>
        @endif
            </tr>
        </thead>
        <tbody>
        @foreach($jobs as $job)
            <tr>
            <td>
                    <a href="{!! route('jobs.show', [$job->id]) !!}" class="text-bold lead">
                         {!! $job->title !!}
                    </a>
                    <br/>
                    <span>
                        <i class="fa-map-marker"></i>
                        {!! $job->work_type !!} | {!! $job->job_type !!}
                    </span>
            <br/>
                        <i class="fa-usr-plus"></i>
            @if(Auth::check() && (Auth::user()->id == $job->user_id || Auth::user()->id == Auth::user()->role_id <3 ))
                <a href="/users/{!! $job->user['id']  !!}" class="text-muted text:hover">{!! $job->user['name'] !!}</a>
            @endif
             | <a href="/organisations/{!! $job->organisation['id'] !!}" class="text-muted text:hover">{!! $job->organisation['name'] !!}</a>
               | <a href="/countries/{!! $job->country_id !!}" class="text-muted text:hover" >{!! $job->country['name'] !!}</a>
            </td>
            @if(Auth::check() && (Auth::user()->id == $job->user_id || Auth::user()->id == Auth::user()->role_id <3 ))
            <td>{!! $job->status !!}</td>
                <td>
                    <!--kiem tra ai duoc quyen xoa -->   
                    {!! Form::open(['route' => ['jobs.destroy', $job->id], 'method' => 'delete']) !!}
                    <div class='btn-group'>  
                        <a href="{!! route('jobs.edit', [$job->id]) !!}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-edit"></i></a>
                        {!! Form::button('<i class="glyphicon glyphicon-trash"></i>',
                         ['type' => 'submit', 'class' => 'btn btn-danger btn-xs',
                          'onclick' => "return confirm('Are you sure?')"]) !!}
                    </div>
                    {!! Form::close() !!}               
                </td>
                @endif
            </tr>
        @endforeach
        </tbody>
    </table>
</div>

Em thấy nó báo lỗi chỗ này:

 @if(Auth::check() && (Auth::user()->id == $job->user_id || Auth::user()->id == Auth::user()->role_id <3 ))
                <th> Status </th>
                <th colspan="3">Action</th>
        @endif

Làm sao để fix lỗi vậy các anh?

Biến $job chưa được khởi tạo

3 Likes

lam the nao khoi tao bien. nhu trong cai nay. em moi hoc nen khong ro lam

Mới học mà viết khá đấy! Nhưng sao viết ra được mà không sửa được chứ? :thinking:
Nghi vấn sao chép! :smiling_imp:

Cách đơn giản là xóa dòng @if@endif của nó đi!

4 Likes

sủa đc rồi anh ơi, em chưa khai báo thằng model use ở trên. ngáo quá à haha

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?