Krayin Forum

    Krayin

    • Register
    • Login
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Getting error when. assign sales owner try to open that particular lead

    General Discussion
    4
    6
    674
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      aman last edited by

      ErrorException
      PHP 8.1.29
      10.48.20
      Undefined variable $userIds

      1 Reply Last reply Reply Quote 0
      • W
        wilmocar last edited by

        Same error here.

        when the lead it's assigned to user, these user can't open the lead.

        { $lead = $this->leadRepository->findOrFail($id); if ( $userIds = bouncer()->getAuthorizedUserIds() && ! in_array($lead->user_id, $userIds) ) { return redirect()->route('admin.leads.index'); } return view('admin::leads.view', compact('lead'));

        1 Reply Last reply Reply Quote 0
        • W
          wilmocar last edited by wilmocar

          Screenshot 2024-10-08 083643.png

          1 Reply Last reply Reply Quote 0
          • C
            chriscom78 last edited by

            I have the same error, too. I'm not sure if it's part of the same problem, but when I try to add a new lead with the non-admin account, I am not able to select the sales owner, so after the lead is created, the person who created it can not see it.

            In both cases, I guess it's a permitions problem and they need access to something I missed on that user group.

            1 Reply Last reply Reply Quote 0
            • C
              chriscom78 last edited by

              I have done the following to get it working - not sure if this will break something else but seems to be working so far 🙂

              in the LeadController.php
              n the get function
              replace:

              if ($userIds = bouncer()->getAuthorizedUserIds()) {
                  $query->whereIn('leads.user_id', $userIds);
              }
              

              with:

              $userIds = bouncer()->getAuthorizedUserIds() ?? [];
              if (!empty($userIds)) {
                  $query->whereIn('leads.user_id', $userIds);
              }
              

              and in the view function, replace:
              replace

              if (
                  $userIds = bouncer()->getAuthorizedUserIds()
                  && ! in_array($lead->user_id, $userIds)
              ) {
                  return redirect()->route('admin.leads.index');
              }
              

              with

              $userIds = bouncer()->getAuthorizedUserIds() ?? [];
              if (!empty($userIds) && !in_array($lead->user_id, $userIds)) {
                  return redirect()->route('admin.leads.index');
              
              1 Reply Last reply Reply Quote 0
              • I
                imjatinx last edited by

                GO TO : packages/Webkul/Admin/src/Http/Controllers/Lead/LeadController.php

                In view function

                Remove this :

                if (
                $userIds = bouncer()->getAuthorizedUserIds()
                && ! in_array($lead->user_id, $userIds)
                ) {
                return redirect()->route('admin.leads.index');
                }

                with:

                $userIds = bouncer()->getAuthorizedUserIds();

                if ($userIds && ! in_array($lead->user_id, $userIds)) {
                return redirect()->route('admin.leads.index');
                }

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Powered by NodeBB | Contributors