Skip to content

Commit

Permalink
Merge pull request #21 from NickMous/feature/add-notifications
Browse files Browse the repository at this point in the history
Feature/add notifications
  • Loading branch information
NickMous authored Aug 13, 2024
2 parents 17bd81d + 6947ae1 commit 66e7ea6
Show file tree
Hide file tree
Showing 24 changed files with 1,538 additions and 573 deletions.
9 changes: 9 additions & 0 deletions .ddev/commands/web/check-all
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

## Description: Check all commands
## Usage: check-all
## Example: ddev check-all

php vendor/bin/pest
php vendor/bin/phpstan analyse
php vendor/bin/phpcs
6 changes: 2 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ env:

on:
push:
branches: [ main ]
branches: [main]

jobs:
laravel-tests:

runs-on: ubuntu-latest

services:
Expand All @@ -33,7 +32,7 @@ jobs:
steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: '8.3'
php-version: "8.3"
- uses: actions/checkout@v3
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
Expand Down Expand Up @@ -65,7 +64,6 @@ jobs:
runs-on: ubuntu-latest

steps:

- name: Activate maintenance mode 🛠️
uses: appleboy/ssh-action@master
with:
Expand Down
57 changes: 28 additions & 29 deletions .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ name: Laravel Pest Tests

on:
pull_request:
branches: [ "main" ]
branches: ["main"]

jobs:
laravel-tests:

runs-on: ubuntu-latest

services:
Expand All @@ -26,30 +25,30 @@ jobs:
--health-retries=3
steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: '8.3'
- uses: actions/checkout@v3
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install Composer Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Install NPM Dependencies
run: npm install
- name: Run build
run: npm run build
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Execute tests (Unit and Feature tests) via Pest
env:
DB_CONNECTION: mariadb
DB_DATABASE: test
DB_USERNAME: test_user
DB_PASSWORD: test_password
run: vendor/bin/pest
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: "8.3"
- uses: actions/checkout@v3
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install Composer Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Install NPM Dependencies
run: npm install
- name: Run build
run: npm run build
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Execute tests (Unit and Feature tests) via Pest
env:
DB_CONNECTION: mariadb
DB_DATABASE: test
DB_USERNAME: test_user
DB_PASSWORD: test_password
run: vendor/bin/pest
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Ignore artifacts:
build
coverage
composer.json
composer.lock
public/vendor
.ddev
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:

- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).

Laravel is accessible, powerful, and provides tools required for large, robust applications.

Expand All @@ -35,19 +35,19 @@ We would like to extend our thanks to the following sponsors for funding Laravel

### Premium Partners

- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[WebReinvent](https://webreinvent.com/)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
- **[Jump24](https://jump24.co.uk)**
- **[Redberry](https://redberry.international/laravel/)**
- **[Active Logic](https://activelogic.com)**
- **[byte5](https://byte5.de)**
- **[OP.GG](https://op.gg)**
- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[WebReinvent](https://webreinvent.com/)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
- **[Jump24](https://jump24.co.uk)**
- **[Redberry](https://redberry.international/laravel/)**
- **[Active Logic](https://activelogic.com)**
- **[byte5](https://byte5.de)**
- **[OP.GG](https://op.gg)**

## Contributing

Expand Down
13 changes: 7 additions & 6 deletions app/Console/Commands/SendTestNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SendTestNotification extends Command implements PromptsForMissingInput
*
* @var string
*/
protected $signature = 'app:send-test-notification {user} {status=success}';
protected $signature = 'app:send-test-notification {user} {status=success} {amount=1}';

/**
* The console command description.
Expand All @@ -25,18 +25,19 @@ class SendTestNotification extends Command implements PromptsForMissingInput
*/
protected $description = 'Send a test notification to an user';

private $user;

/**
* Execute the console command.
*/
public function handle()
{
$this->user = User::findOrFail($this->argument('user'));
$this->info("Sending a test notification to user {$this->argument('user')} with status {$this->argument('status')}.");
$user = User::findOrFail($this->argument('user'));
$this->info('Sending '.$this->argument('amount')." test notification(s) to user {$this->argument('user')} with status {$this->argument('status')}.");
$this->info('Sleeping for 5 seconds...');
sleep(5);
$this->user->notify(new TestNotification($this->argument('status')));
for ($i = 0; $i < $this->argument('amount'); $i++) {
$user->notify(new TestNotification($this->argument('status')));
sleep(1);
}
}

protected function promptForMissingArgumentsUsing()
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/Notifications/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Index extends Component
#[On('notificationReceived')]
public function mount()
{
$this->notifications = auth()->user()->notifications()->get();
$this->notifications = auth()->user()->notifications()->read()->get();
$this->unread = auth()->user()->notifications()->unread()->get();
}

Expand Down
Binary file added bun.lockb
Binary file not shown.
Loading

0 comments on commit 66e7ea6

Please sign in to comment.