Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public function updatePostagem(User $user, Departamento $departamento)
  2. {
  3. return $user->id == $departamento->user_id;
  4. }
  5.  
  6. public function user()
  7.  
  8. {
  9. return $this->belongsto(User::class);
  10. }
  11.  
  12. public function departamento(){
  13. return $this->belongsTo(Departamento::class);
  14. }
  15.  
  16. protected $policies = [
  17. Postagem::class => PostagemPolicy::class,
  18. ];
  19.  
  20. public function updatePostagem(User $user, Departamento $departamento)
  21. {
  22. return $user->id == $departamento->user_id;
  23. }
  24.  
  25. $postagem = Postagem::findOrFail($id);
  26.  
  27. $findDepartamento = Departamento::findOrFail($postagem->departamento->id);
  28.  
  29. if (Gate::denies('updatePostagem', $postagem->departamento)) {
  30. return redirect()->back()->with('error', 'Você não tem permição para fazer a atualização. Pois você nao é o dono desse artigo');
  31. }
  32.  
  33. public function updatePostagem(User $user, Departamento $departamento)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement