Advertisement
Guest User

Untitled

a guest
Mar 1st, 2021
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Providers;
  4.  
  5. use Illuminate\Contracts\Auth\Access\Gate as GateContract;
  6. use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
  7.  
  8. use App\User;
  9. use App\Article;
  10.  
  11. use App\Policies\ArticlePolicy;
  12.  
  13. class AuthServiceProvider extends ServiceProvider
  14. {
  15. /**
  16. * The policy mappings for the application.
  17. *
  18. * @var array
  19. */
  20. protected $policies = [
  21. Article::class => ArticlePolicy::class
  22. ];
  23.  
  24. /**
  25. * Register any application authentication / authorization services.
  26. *
  27. * @param \Illuminate\Contracts\Auth\Access\Gate $gate
  28. * @return void
  29. */
  30. // public function boot(GateContract $gate)
  31. // {
  32. // $this->registerPolicies($gate);
  33. //
  34. // /*
  35. // //$gate->define('add-article',ClassName@func);
  36. // $gate->define('add-article',function(User $user) {
  37. //
  38. // foreach($user->roles as $role) {
  39. //
  40. // if($role->name == 'Admin') {
  41. // return TRUE;
  42. // }
  43. //
  44. // }
  45. //
  46. // return FALSE;//FALSE
  47. //
  48. // });
  49. //
  50. //
  51. // $gate->define('update-article', function (User $user, $article) {
  52. //
  53. // foreach($user->roles as $role) {
  54. // if($role->name == 'Admin') {
  55. // if($user->id == $article->user_id) {
  56. // return TRUE;
  57. // }
  58. // }
  59. // }
  60. //
  61. // return FALSE;
  62. //
  63. // });
  64. //*/
  65. // //
  66. // }
  67. }
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement