Skip to content

Commit

Permalink
Merge pull request #13 from ormelflores/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ormelflores authored Apr 24, 2024
2 parents 50110c5 + b0d723f commit 34612ee
Show file tree
Hide file tree
Showing 8 changed files with 392 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

PRINT_NODE_API_KEY=
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This project will be used for taking customer's order. It was built with Laravel
- Automated generation of receipt
- Generating reports
- Activity logs per user
- Direct printing of receipt
- Configurations:
- Category
- Products
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Controllers/TransactionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Actions\Transactions\GenerateReceipt;
use App\Http\Requests\Store\TransactionRequest;
use App\Http\Requests\Update\TransactionRequest as UpdateTransactionRequest;
use App\Jobs\PrintReceiptJob;
use App\Models\Transaction;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
Expand Down Expand Up @@ -39,6 +40,8 @@ public function store(TransactionRequest $request): RedirectResponse

GenerateReceipt::run($transaction);

PrintReceiptJob::dispatch($transaction);

return back();
}

Expand Down
40 changes: 40 additions & 0 deletions app/Jobs/PrintReceiptJob.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Jobs;

use App\Models\Transaction;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Rawilk\Printing\Facades\Printing;

class PrintReceiptJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

/**
* Create a new job instance.
*/
public function __construct(protected Transaction $transaction)
{
//
}

/**
* Execute the job.
*/
public function handle(): void
{
$printers = Printing::printers();

if (isset($printers[0]))
{
Printing::newPrintTask()
->printer($printers[0]->id())
->url($this->transaction->receipt->file)
->send();
}
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"laravel/framework": "^11.1",
"laravel/sanctum": "^4.0",
"laravel/tinker": "^2.7",
"rawilk/laravel-printing": "^3.0",
"spatie/laravel-permission": "^6.4",
"tightenco/ziggy": "^1.0"
},
Expand Down
257 changes: 256 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 34612ee

Please sign in to comment.