How do I make user or group only see their data?

    • Benjarong Inwongwan
      Participant
        # 2 years, 3 months ago

        Hello!

        I want to make the user or group assigned to the record can only see their data in the table except for role admin.
        How do I make it?

        Thank you.

      • laravel-bap
        Keymaster
          # 2 years, 3 months ago

          Hi,

          here is what you need to change.

          Edit File \Modules\Platform\Core\Helper\EntityAccessHelper

          change blockEntityOwnableAccess and around 66 line remove


          if ($entity->owner == null) {
          return false;
          }

          this will block access to sigle record that is not assigned.

          Edit File \Modules\Platform\Core\Datatable\Scope\OwnableEntityScope

          Around 48 line change code to


          if ($user->access_to_all_entity) {
          $query->orWhere(function ($query) use ($user, $entity) {
          $query->where(“$entity->table.owned_by_type”, ‘=’, null);
          });
          }

          You need to wrap code into if($user->access_to_all_entity). Each admin account should have access to all records.

          I think this should be enough.

      Viewing 1 reply thread

      You must be logged in to reply to this topic.