2017-12-09 16 views
0

私は出席者ビューを作成してユーザの出席を表示しました。私はリンクとすべてを作成した後、私はこのエラーが発生しました!私はこれをどのように修正するのか分かりません。あなたは許可ポリシーを持っていません

これはUserControllerのコードです。

public function attendance() 
    { 
     $this->authorize('modifyUser', auth()->user()); 

     return view ('user.attendance'); 
    } 

は、これは私のUserPolicy.php

public function modifyUser(User $user, UserProfile $profile) 
    { 
     return $user->id === $profile->id; 

    } 

これは私の出席図です。

@extends('layouts.app') 
@section('content') 
    <div class="container"> 
     <div class="row"> 
      <div class="col-md-12"> 
       <h1><i class="fa fa-university"></i> Attendance</h1> 
      </div> 

      <div class="row"> 
       <table class="table table-bordered"> 
        <tr> 
         <th>No</th> 
         <th>Date</th> 
         <th>Time</th> 
         <th>Present</th> 
        </tr> 

        <?php $no=1; ?> 

        <tr> 
         <td>{{ $no++ }}</td> 
         <td>{{$user->attendance->date}}</td> 
         <td>{{$user->attendance->time}}</td> 
         <td>{{$user->attendance->present}}</td> 
        </tr> 
       </table> 
      </div> 
     </div> 
    </div> 
@stop 

その後、このエラーが発生しました。

enter image description here

+1

return句の前にポリシーに 'dd($ user-> id、$ profile-> id);'を入れてください。それは何を示していますか? –

+0

私はそのコードを既にポリシーに入れていますが、どうすればエラーをチェックできますか?申し訳ありませんが、私はlaravelに新しいです。 – Htoo

+1

同じリクエストを実行するだけです。 'You Do not Have Permission! 'の代わりに2つの整数がブラウザに表示されるはずです。 –

答えて

0

あなたはattendance/{id}ルートをヒットしている、とあなたは、定義されたパラメータなしでのみattendance()方法を持っています。

あなたのルートはどのように見えますか?

関連する問題