Chatter just for members

Solved Posted In Laravel
  • daniel-kolbach 1 year ago
    I'm playing around with Chatter, trying to decide if i should go with a package or create a full blown forum my self. I like the package a lot, but i'm cannot make sense how the routes have been handled. I need to make the forum visible just to members of the web site. Where i can control that.
    
    Thanks for your time
    

    I'm playing around with Chatter, trying to decide if i should go with a package or create a full blown forum my self. I like the package a lot, but i'm cannot make sense how the routes have been handled. I need to make the forum visible just to members of the web site. Where i can control that.

    Thanks for your time

  • Best Answer

    (As selected by daniel-kolbach)

    mark 1 year ago
    You could add a global middleware for Chatter.    
    https://github.com/thedevdojo/chatter/blob/master/config/chatter.php#L284
    
    ----------
    Best Regards,    
    Mark Topper (Maintainer of [Laravel Voyager](https://laravelvoyager.com))    
    Mail: [[email protected]](mailto:[email protected])    
    *I am available for freelance work - [hire me](mailto:[email protected])*
    

    You could add a global middleware for Chatter.
    https://github.com/thedevdojo/chatter/blob/master/config/chatter.php#L284


    Best Regards,
    Mark Topper (Maintainer of Laravel Voyager)
    Mail: [email protected]
    I am available for freelance work - hire me

  • mark 1 year ago
    You could add a global middleware for Chatter.    
    https://github.com/thedevdojo/chatter/blob/master/config/chatter.php#L284
    
    ----------
    Best Regards,    
    Mark Topper (Maintainer of [Laravel Voyager](https://laravelvoyager.com))    
    Mail: [[email protected]](mailto:[email protected])    
    *I am available for freelance work - [hire me](mailto:[email protected])*
    

    You could add a global middleware for Chatter.
    https://github.com/thedevdojo/chatter/blob/master/config/chatter.php#L284


    Best Regards,
    Mark Topper (Maintainer of Laravel Voyager)
    Mail: [email protected]
    I am available for freelance work - hire me

  • daniel-kolbach 1 year ago
    Thanks for the answer, i have started to build my own forum.. I see what you are talking about. As that file is, the only one with 'web' authorization is global, all the others have a empty array. So i'm guessing if i put 'auth' on global it will only be available yo authorized users. is that correct?
    

    Thanks for the answer, i have started to build my own forum.. I see what you are talking about. As that file is, the only one with 'web' authorization is global, all the others have a empty array. So i'm guessing if i put 'auth' on global it will only be available yo authorized users. is that correct?

  • mark 1 year ago
    That is correct indeed.
    
    ----------
    Best Regards,    
    Mark Topper (Maintainer of [Laravel Voyager](https://laravelvoyager.com))    
    Mail: [[email protected]](mailto:[email protected])    
    *I am available for freelance work - [hire me](mailto:[email protected])*
    

    That is correct indeed.


    Best Regards,
    Mark Topper (Maintainer of Laravel Voyager)
    Mail: [email protected]
    I am available for freelance work - hire me

  • daniel-kolbach 1 year ago
    If i can pick your brain once more time. If i have a role_id in the user record, how whould you setup the middleware to restrict a couple of the routes to only users that have a role_id = 2, for example?
    New at Laravel, try to hit people for knodledge whenever i can.
    
    Thanks, i appreciate your time.
    

    If i can pick your brain once more time. If i have a role_id in the user record, how whould you setup the middleware to restrict a couple of the routes to only users that have a role_id = 2, for example? New at Laravel, try to hit people for knodledge whenever i can.

    Thanks, i appreciate your time.

  • mark 1 year ago
    You could create your own middleware, checking the role id :)
    
    Documentation on middleware: https://laravel.com/docs/5.6/middleware#defining-middleware
    
    It would be something like
    ```
        public function handle($request, Closure $next)
        {
            $user = auth()->check() ? auth()->user() : null;
    
            if (!$user OR $user->role_id != 2) {
                return redirect('home');
            }
    
            return $next($request);
        }
    ```
    
    ----------
    Best Regards,    
    Mark Topper (Maintainer of [Laravel Voyager](https://laravelvoyager.com))    
    Mail: [[email protected]](mailto:[email protected])    
    *I am available for freelance work - [hire me](mailto:[email protected])*
    

    You could create your own middleware, checking the role id :)

    Documentation on middleware: https://laravel.com/docs/5.6/middleware#defining-middleware

    It would be something like

        public function handle($request, Closure $next)
        {
            $user = auth()->check() ? auth()->user() : null;
    
            if (!$user OR $user->role_id != 2) {
                return redirect('home');
            }
    
            return $next($request);
        }
    

    Best Regards,
    Mark Topper (Maintainer of Laravel Voyager)
    Mail: [email protected]
    I am available for freelance work - hire me

  • daniel-kolbach 1 year ago
    Thanks sir
    

    Thanks sir

Please login or signup to leave a response.

Login

or Sign Up

Sign Up

or Login
×
Want to create your own SAAS?

I can teach you to create your own Software as a Service. Click here to learn more!

Visit SAAS Adventure!