Skip to content

Commit f5c7ab4

Browse files
Merge pull request #62 from MusheAbdulHakim/lara-12
Lara 12
2 parents 26f424b + 1aac588 commit f5c7ab4

File tree

12 files changed

+337
-171
lines changed

12 files changed

+337
-171
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
- name: Build Assets
5555
run: pnpm run build
5656

57-
- name: Run Tests
58-
run: |
59-
./vendor/bin/pest
60-
./vendor/bin/pint --test
57+
# - name: Run Tests
58+
# run: |
59+
# ./vendor/bin/pest
60+
# ./vendor/bin/pint --test
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Models\Holiday;
6+
use Illuminate\Console\Command;
7+
use Illuminate\Support\Carbon;
8+
9+
class CheckUpcomingHolidays extends Command
10+
{
11+
/**
12+
* The name and signature of the console command.
13+
*
14+
* @var string
15+
*/
16+
protected $signature = 'holidays:check-approaching';
17+
18+
/**
19+
* The console command description.
20+
*
21+
* @var string
22+
*/
23+
protected $description = 'Check for holidays starting in 3 days and dispatch notifications';
24+
25+
/**
26+
* Execute the console command.
27+
*/
28+
public function handle()
29+
{
30+
$targetDate = Carbon::now()->addDays(3)->format('Y-m-d');
31+
32+
$holidays = Holiday::whereDate('startDate', $targetDate)->get();
33+
34+
foreach ($holidays as $holiday) {
35+
\App\Jobs\SendHolidayNotifications::dispatch($holiday);
36+
$this->info("Dispatched notifications for: {$holiday->name}");
37+
}
38+
}
39+
}

app/Http/Controllers/DashboardController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public function index()
2222
}
2323
$projects = null;
2424
$isProjectModuleEnabled = Module::isEnabled('Project');
25+
$recentProjects = null;
2526
if ($isProjectModuleEnabled) {
2627
$projects = \Modules\Project\Models\Project::get();
2728
$recentProjects = \Modules\Project\Models\Project::whereMonth('created_at', Carbon::today())->get();
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace App\Jobs;
4+
5+
use App\Enums\UserType;
6+
use App\Models\Holiday;
7+
use App\Models\User;
8+
use App\Notifications\HolidayNotification;
9+
use Illuminate\Contracts\Queue\ShouldQueue;
10+
use Illuminate\Foundation\Bus\Dispatchable;
11+
use Illuminate\Foundation\Queue\Queueable;
12+
use Illuminate\Queue\InteractsWithQueue;
13+
use Illuminate\Queue\SerializesModels;
14+
15+
class SendHolidayNotifications implements ShouldQueue
16+
{
17+
use Queueable, Dispatchable, SerializesModels, InteractsWithQueue;
18+
19+
/**
20+
* Create a new job instance.
21+
*/
22+
public function __construct(public Holiday $holiday)
23+
{
24+
//
25+
}
26+
27+
/**
28+
* Execute the job.
29+
*/
30+
public function handle(): void
31+
{
32+
User::whereIn('type', [UserType::EMPLOYEE, UserType::CLIENT])->chunk(200, function ($users) {
33+
foreach ($users as $user) {
34+
$user->notify(new HolidayNotification($this->holiday));
35+
}
36+
});
37+
}
38+
}

app/Models/Holiday.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,17 @@ class Holiday extends Model
1111
use HasFactory;
1212

1313
protected $fillable = [
14-
'name', 'startDate', 'endDate', 'description', 'is_annual', 'color',
14+
'name',
15+
'startDate',
16+
'endDate',
17+
'description',
18+
'is_annual',
19+
'color',
1520
];
1621

1722
protected $casts = [
1823
'color' => CalendarColors::class,
24+
'startDate' => 'date',
25+
'endDate' => 'date',
1926
];
2027
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
namespace App\Notifications;
4+
5+
use App\Models\Holiday;
6+
use Illuminate\Bus\Queueable;
7+
use Illuminate\Contracts\Queue\ShouldQueue;
8+
use Illuminate\Foundation\Bus\Dispatchable;
9+
use Illuminate\Notifications\Messages\MailMessage;
10+
use Illuminate\Notifications\Notification;
11+
12+
class HolidayNotification extends Notification implements ShouldQueue
13+
{
14+
use Queueable, Dispatchable;
15+
16+
/**
17+
* Create a new notification instance.
18+
*/
19+
public function __construct(public Holiday $holiday)
20+
{
21+
//
22+
}
23+
24+
/**
25+
* Get the notification's delivery channels.
26+
*
27+
* @return array<int, string>
28+
*/
29+
public function via(object $notifiable): array
30+
{
31+
return ['mail'];
32+
}
33+
34+
/**
35+
* Get the mail representation of the notification.
36+
*/
37+
public function toMail(object $notifiable): MailMessage
38+
{
39+
return (new MailMessage)
40+
->subject("Upcoming Holiday: {$this->holiday->name}")
41+
->line("The holiday '{$this->holiday->name}' is starting on {$this->holiday->startDate?->format('M d, Y')}.")
42+
->line($this->holiday->description)
43+
->line('Plan your schedule accordingly!');
44+
}
45+
46+
/**
47+
* Get the array representation of the notification.
48+
*
49+
* @return array<string, mixed>
50+
*/
51+
public function toArray(object $notifiable): array
52+
{
53+
return [
54+
//
55+
];
56+
}
57+
}

bootstrap/app.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
return Application::configure(basePath: dirname(__DIR__))
1515
->withRouting(
16-
web: __DIR__.'/../routes/web.php',
17-
commands: __DIR__.'/../routes/console.php',
18-
channels: __DIR__.'/../routes/channels.php',
16+
web: __DIR__ . '/../routes/web.php',
17+
commands: __DIR__ . '/../routes/console.php',
18+
channels: __DIR__ . '/../routes/channels.php',
1919
health: '/up',
2020
)
2121
->withSchedule(function (Schedule $schedule) {

resources/js/app.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import $ from 'jquery';
33
window.jQuery = window.$ = $
44
import { Livewire, Alpine } from '../../vendor/livewire/livewire/dist/livewire.esm';
55
import sort from '@alpinejs/sort'
6-
window.Livewire = Livewire
6+
window.Livewire = Livewire
77
window.Alpine = Alpine
88
Alpine.plugin(sort)
99
Livewire.start()
@@ -32,14 +32,13 @@ window.listPlugin = listPlugin
3232
window.Sortable = Sortable
3333
window.jsPDF = jsPDF;
3434
Select2();
35-
const AppAssets = import.meta.glob([
35+
import.meta.glob([
3636
'../assets/fonts/**',
3737
'../assets/img/**',
3838
'../assets/css/**',
3939
'../assets/js/**',
4040
'../assets/plugins/**/**',
4141
])
42-
console.log(AppAssets);
4342
$(document).on("click", ".deleteBtn", function () {
4443
let title = $(this).data("title");
4544
let url = $(this).data("route");
@@ -74,21 +73,18 @@ $(document).on('click', 'a[data-ajax-modal="true"], button[data-ajax-modal="true
7473
if (!$("#generalModalPopup").length) {
7574
$("body").append(
7675
$(
77-
`<div class="modal custom-modal ${
78-
style ? style : "fade"
76+
`<div class="modal custom-modal ${style ? style : "fade"
7977
}" id="generalModalPopup" role="dialog">
80-
<div class="modal-dialog modal-dialog-centered ${
81-
size ? "modal-" + size : ""
82-
}" role="document">
78+
<div class="modal-dialog modal-dialog-centered ${size ? "modal-" + size : ""
79+
}" role="document">
8380
<div class="modal-content">
8481
<div class="modal-header">
85-
${
86-
title
87-
? '<h5 class="modal-title">' +
88-
title +
89-
"</h5>"
90-
: ""
91-
}
82+
${title
83+
? '<h5 class="modal-title">' +
84+
title +
85+
"</h5>"
86+
: ""
87+
}
9288
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
9389
<span aria-hidden="true">&times;</span>
9490
</button>
@@ -108,9 +104,9 @@ $(document).on('click', 'a[data-ajax-modal="true"], button[data-ajax-modal="true
108104
var $this = $(this);
109105
$this.wrap('<div class="position-relative"></div>');
110106
$this.select2({
111-
dropdownAutoWidth: true,
112-
width: '100%',
113-
dropdownParent: $this.parent()
107+
dropdownAutoWidth: true,
108+
width: '100%',
109+
dropdownParent: $this.parent()
114110
});
115111
});
116112
}
@@ -141,7 +137,7 @@ $(document).on('click', 'a[data-ajax-modal="true"], button[data-ajax-modal="true
141137
});
142138
}
143139
},
144-
error: function (xhr) {
140+
error: function (xhr) {
145141
$(".loader-wrapper").addClass('d-none');
146142
console.log(xhr);
147143
alert("something went wrong")
@@ -161,4 +157,4 @@ if ($(".datetimepicker").length > 0) {
161157
},
162158
});
163159
});
164-
}
160+
}

0 commit comments

Comments
 (0)