• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
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
1.9k
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 7 Jan 2021, 23:59 7 Jan 2021, 23:06

    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 7 Jan 2021, 23:43 Reply Quote 0
    • N
      nessuno @nessuno last edited by 7 Jan 2021, 23:43

      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 8 Jan 2021, 05:21

        Hi @nessuno,

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

        N 1 Reply Last reply 8 Jan 2021, 10:33 Reply Quote 0
        • N
          nessuno @devansh-webkul last edited by 8 Jan 2021, 10:33

          @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 8 Jan 2021, 13:31

            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 8 Jan 2021, 15:47 Reply Quote 1
            • N
              nessuno @devansh-webkul last edited by nessuno 8 Jan 2021, 16:08 8 Jan 2021, 15:47

              @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 11 Jan 2021, 06:14

                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
                • 9 days later
                • N
                  nessuno last edited by 20 Jan 2021, 11:07

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

                  1 Reply Last reply Reply Quote 0
                  5 out of 8
                  • First post
                    5/8
                    Last post