Bagisto Forum

    Bagisto

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

    Prettus mismatch when issuing invoice via Tinker ( Prettus/Repository/Eloquent/BaseRepository::__construct() must be an instance of Illuminate/Container/Container )

    Knowledge Base
    2
    8
    1120
    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.
    • N
      nessuno last edited by nessuno

      Hi All,
      Please, trying to find an example of interacting with bagisto using Tinker ?
      Say opening an order ... ?
      Thanks in advance for your time!
      best,
      s

      N 1 Reply Last reply Reply Quote 0
      • N
        nessuno @nessuno last edited by

        For example ( I am actually trying to issue an invoice via tinker), as this:

        use Webkul\Sales\Repositories\OrderRepository; ( OK ! )

        $this_order = Webkul\Sales\Models\Order::where('id',262);
        => Illuminate\Database\Eloquent\Builder {#3862} ( OK ! )

        $a=new OrderItemRepository($this_order);
        TypeError: Argument 1 passed to Prettus/Repository/Eloquent/BaseRepository::__construct() must be an instance of Illuminate/Container/Container, instance of Illuminate/Database/Eloquent/Builder given on line 1

        My final goal is to reach the Invoice Controller method ( create/store ) to custom the invoice issuance flow ...

        any help appreciated !!
        thanks

        1 Reply Last reply Reply Quote 0
        • devansh-webkul
          devansh-webkul last edited by

          Hi @nessuno,

          Please share all the commands which you have ran in tinker.

          N 1 Reply Last reply Reply Quote 0
          • N
            nessuno @devansh-webkul last edited by

            @devansh-webkul
            Thanks for your reply.
            I am trying to issue invoice based on order via tinker ( or via cli or post api ) ...
            Yes, the above commands were issued in Tinker as also per below:

            1. use Webkul\Sales\Repositories\OrderRepository;
              OK in Tinker
            2. $this_order = Webkul\Sales\Models\Order::where('id',262);
              OK in Tinker ( replies => Illuminate\Database\Eloquent\Builder {#3862} )
            3. But when I try to initiate the repository using:
              $a=new OrderItemRepository($this_order);
              then Tinker replies:
              TypeError: Argument 1 passed to Prettus/Repository/Eloquent/BaseRepository::__construct() must be an instance of Illuminate/Container/Container, instance of Illuminate/Database/Eloquent/Builder given on line 1

            But I can't iterate with the repository ...

            Thanks for your help, appreciated !
            s

            1 Reply Last reply Reply Quote 0
            • devansh-webkul
              devansh-webkul last edited by

              Hi @nessuno,

              Did you go deeper? If you check the OrderItemRepository, you will see that this class is extends to Repository and further it is extend to BaseRepository.

              There you will see that, constructor is calling which needs an application instance. Because reflection API won't work there so you need to pass the application object manually.

              So just try this and let me know,

              $a = new OrderItemRepository(app(), $this_order);
              
              N 1 Reply Last reply Reply Quote 1
              • N
                nessuno @devansh-webkul last edited by nessuno

                @devansh-webkul
                I did go deeper, but your solution is better ...
                I ended up doing this:

                Route::get('custom_issue_invoice_by_order/{id}', 'InvoiceController@issue_invoice')->defaults('_config', [
                'repository' => 'Webkul\Sales\Repositories\OrderRepository',
                'resource' => 'Webkul\API\Http\Resources\Sales\Order',
                'authorization_required' => true
                ]);

                ( Which works, InvoiceController@issue_invoice_by_order is a custom version of InvoiceController@store; which essentially matches Interac / E-Transfers resulting in auto-payments without fees for the customers ... )

                But I like your solution better as with your way I might be able to get it via Tinker which is neat for interacting instead of APIing like I did ... Thanks @devansh-webkul you are a prince ! much appreciated.
                have a great day/night !
                s

                1 Reply Last reply Reply Quote 0
                • devansh-webkul
                  devansh-webkul last edited by

                  Hi @nessuno,

                  Thanks for the update.

                  Also, if you like our support, you may give us the review here:- https://www.trustpilot.com/review/bagisto.com

                  That would be grateful for us.

                  Thanks & Regards,
                  Devansh

                  1 Reply Last reply Reply Quote 1
                  • N
                    nessuno last edited by

                    For sure, .. done https://www.trustpilot.com/reviews/5fb7aa3c5e693f08f004dfd9

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post