Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
martinoak committed Mar 13, 2024
2 parents dae0add + 7072379 commit 52caaaf
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 90 deletions.
43 changes: 43 additions & 0 deletions app/Console/Commands/InvalidateVouchersCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace App\Console\Commands;

use App\Models\Voucher;
use Illuminate\Console\Command;

class InvalidateVouchersCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:invalidate-vouchers';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Invalidate all vouchers past due';

/**
* Execute the console command.
*/
public function handle(): void
{
$file = fopen(storage_path('logs/cron.log'), 'a');
fwrite($file, date('Y-m-d H:i:s') . " [CRON] Invalidate vouchers started\n");

$vouchers = Voucher::all();
$counter = 0;
foreach ($vouchers as $voucher) {

if (strtotime($voucher->date) < time()) {
Voucher::where('hash', $voucher->hash)->update(['expired' => 1]);
}
}

fwrite($file, date('Y-m-d H:i:s') . " [CRON] Invalidated $counter vouchers\n");
}
}
5 changes: 5 additions & 0 deletions app/Http/Controllers/CronController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ public function bill(): void
{
Artisan::call('app:monthly-bill');
}

public function invalidateVouchers(): void
{
Artisan::call('app:invalidate-vouchers');
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/VouchersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class VouchersController extends Controller
public function index(): View
{
return view('admin.vouchers.index', [
'vouchers' => Voucher::where(['accepted' => 0])->get(),
'vouchers' => Voucher::where(['accepted' => 0, 'expired' => 0])->get(),
]);
}

Expand Down
28 changes: 28 additions & 0 deletions database/migrations/2024_03_13_194717_alter_vouchers_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('vouchers', function (Blueprint $table) {
$table->boolean('expired')->default(0)->after('price');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('vouchers', function (Blueprint $table) {
$table->dropColumn('expired');
});
}
};
95 changes: 26 additions & 69 deletions public/css/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,14 @@ video {
position: relative;
}

.end-2 {
inset-inline-end: 0.5rem;
}

.end-2\.5 {
inset-inline-end: 0.625rem;
}

.left-0 {
left: 0px;
}
Expand All @@ -1089,14 +1097,6 @@ video {
top: 0px;
}

.end-2 {
inset-inline-end: 0.5rem;
}

.end-2\.5 {
inset-inline-end: 0.625rem;
}

.top-3 {
top: 0.75rem;
}
Expand Down Expand Up @@ -1243,10 +1243,6 @@ video {
margin-top: auto;
}

.ms-3 {
margin-inline-start: 0.75rem;
}

.block {
display: block;
}
Expand Down Expand Up @@ -1335,6 +1331,10 @@ video {
width: 16.666667%;
}

.w-12 {
width: 3rem;
}

.w-2\/3 {
width: 66.666667%;
}
Expand Down Expand Up @@ -1367,22 +1367,14 @@ video {
width: 24rem;
}

.w-full {
width: 100%;
}

.w-12 {
width: 3rem;
}

.w-1\/4 {
width: 25%;
}

.w-\[120px\] {
width: 120px;
}

.w-full {
width: 100%;
}

.max-w-2xl {
max-width: 42rem;
}
Expand Down Expand Up @@ -1491,11 +1483,6 @@ video {
row-gap: 4rem;
}

.gap-x-4 {
-moz-column-gap: 1rem;
column-gap: 1rem;
}

.space-x-2 > :not([hidden]) ~ :not([hidden]) {
--tw-space-x-reverse: 0;
margin-right: calc(0.5rem * var(--tw-space-x-reverse));
Expand Down Expand Up @@ -1526,12 +1513,6 @@ video {
margin-bottom: calc(2rem * var(--tw-space-y-reverse));
}

.space-x-4 > :not([hidden]) ~ :not([hidden]) {
--tw-space-x-reverse: 0;
margin-right: calc(1rem * var(--tw-space-x-reverse));
margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse)));
}

.overflow-x-auto {
overflow-x: auto;
}
Expand Down Expand Up @@ -1903,6 +1884,11 @@ video {
color: rgb(21 128 61 / var(--tw-text-opacity));
}

.text-indigo-600 {
--tw-text-opacity: 1;
color: rgb(79 70 229 / var(--tw-text-opacity));
}

.text-indigo-700 {
--tw-text-opacity: 1;
color: rgb(67 56 202 / var(--tw-text-opacity));
Expand Down Expand Up @@ -1938,11 +1924,6 @@ video {
color: rgb(234 179 8 / var(--tw-text-opacity));
}

.text-indigo-600 {
--tw-text-opacity: 1;
color: rgb(79 70 229 / var(--tw-text-opacity));
}

.opacity-0 {
opacity: 0;
}
Expand Down Expand Up @@ -2068,20 +2049,6 @@ video {
color: rgb(255 255 255 / var(--tw-text-opacity));
}

.hover\:text-blue-700:hover {
--tw-text-opacity: 1;
color: rgb(29 78 216 / var(--tw-text-opacity));
}

.focus\:z-10:focus {
z-index: 10;
}

.focus\:outline-none:focus {
outline: 2px solid transparent;
outline-offset: 2px;
}

.focus\:ring-2:focus {
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
Expand All @@ -2104,11 +2071,6 @@ video {
--tw-ring-color: rgb(209 213 219 / var(--tw-ring-opacity));
}

.focus\:ring-gray-100:focus {
--tw-ring-opacity: 1;
--tw-ring-color: rgb(243 244 246 / var(--tw-ring-opacity));
}

:is(.dark .dark\:block) {
display: block;
}
Expand Down Expand Up @@ -2171,6 +2133,11 @@ video {
background-color: rgb(220 38 38 / var(--tw-bg-opacity));
}

:is(.dark .dark\:text-gray-200) {
--tw-text-opacity: 1;
color: rgb(229 231 235 / var(--tw-text-opacity));
}

:is(.dark .dark\:text-gray-400) {
--tw-text-opacity: 1;
color: rgb(156 163 175 / var(--tw-text-opacity));
Expand All @@ -2191,11 +2158,6 @@ video {
color: rgb(255 255 255 / var(--tw-text-opacity));
}

:is(.dark .dark\:text-gray-200) {
--tw-text-opacity: 1;
color: rgb(229 231 235 / var(--tw-text-opacity));
}

:is(.dark .odd\:dark\:bg-gray-900):nth-child(odd) {
--tw-bg-opacity: 1;
background-color: rgb(17 24 39 / var(--tw-bg-opacity));
Expand Down Expand Up @@ -2251,11 +2213,6 @@ video {
--tw-ring-color: rgb(31 41 55 / var(--tw-ring-opacity));
}

:is(.dark .dark\:focus\:ring-gray-700:focus) {
--tw-ring-opacity: 1;
--tw-ring-color: rgb(55 65 81 / var(--tw-ring-opacity));
}

@media (min-width: 640px) {
.sm\:ml-64 {
margin-left: 16rem;
Expand Down
35 changes: 15 additions & 20 deletions resources/views/admin/vouchers/validate.latte
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,27 @@
{block content}
<div class="p-4 sm:ml-64">
<div class="grid grid-cols-1 gap-4 mb-4">
<div class="flex justify-between rounded border-l-8 border-{$voucher['status']}-800 bg-{$voucher['status']}-300">
<h2 class="cell-title">{$voucher['message']}</h2>
<div class="flex justify-center gap-x-8 mr-2">
{if $voucher['status'] == 'green'}
<div>
<a href="{route('vouchers.use', ['hash' => $voucher['hash']])}"><button class="text-white bg-green-900 font-medium rounded-lg text-sm py-2 px-3 my-2">Uplatnit voucher</button></a>
</div>
<div>
<a href="{route('vouchers.index')}"><button class="text-white bg-blue-700 font-medium rounded-lg text-sm py-2 px-3 my-2">Neuplatňovat voucher</button></a>
</div>
{/if}
<div class="cell">
<div class="cell-content justify-between">
<h2 class="cell-title">{$voucher['message']}</h2>
<div class="flex justify-center gap-x-8 mr-2">
{if $voucher['status'] == 'green'}
<a href="{route('vouchers.use', ['hash' => $voucher['hash']])}" class="button-green">Uplatnit voucher</a>
<a href="{route('vouchers.index')}" class="button-blue">Neuplatňovat voucher</button></a>
{/if}
</div>
</div>
</div>
</div>
<div class="grid grid-cols-3 gap-4 mb-4">
<div class="flex flex-col justify-between rounded border-l-8 border-[#3056d3] bg-gray-100">
<h2 class="cell-title">Kód</h2>
<p class="cell-text"><i class="text-[#3056d3] fa-solid fa-hashtag icon"></i>{$voucher['hash']}</p>
<div class="cell-simple">
<i class="fa-solid fa-hashtag icon"></i>{$voucher['hash']}
</div>
<div class="flex flex-col justify-between rounded border-l-8 border-[#3056d3] bg-gray-100">
<h2 class="cell-title">Cena</h2>
<p class="cell-text"><i class="text-[#3056d3] fa-solid fa-dollar-sign icon"></i>{$voucher['price']|number:0,',', ' '},-</p>
<div class="cell-simple">
<i class="fa-solid fa-dollar-sign icon"></i>{$voucher['price']|number:0,',', ' '},-
</div>
<div class="flex flex-col justify-between rounded border-l-8 border-[#3056d3] bg-gray-100">
<h2 class="cell-title">Platnost</h2>
<p class="cell-text"><i class="fa-regular fa-clock text-[#3056d3] icon"></i>{$voucher['dateFrom']|date:'j. n. Y'} - {$voucher['dateTo']|date:'j. n. Y'}</p>
<div class="cell-simple">
<i class="fa-regular fa-clock icon"></i>{$voucher['dateFrom']|date:'j. n. Y'} - {$voucher['dateTo']|date:'j. n. Y'}
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@
Route::group(['prefix' => 'cron'], function () {
Route::any('today', [CronController::class, 'today'])->name('cron.today');
Route::any('bill', [CronController::class, 'bill'])->name('cron.bill');
Route::any('invalidate-vouchers', [CronController::class, 'invalidateVouchers'])->name('cron.invalidate-vouchers');
});

0 comments on commit 52caaaf

Please sign in to comment.