Skip to content

Commit 29a2b2f

Browse files
committed
init
1 parent 39f76cb commit 29a2b2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+888
-559
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github: :vendor_name
1+
github: ElegantEngineeringTech

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
blank_issues_enabled: false
22
contact_links:
33
- name: Ask a question
4-
url: https://github.com/:vendor_slug/:package_name/discussions/new?category=q-a
4+
url: https://github.com/elegantly/laravel-banhammer/discussions/new?category=q-a
55
about: Ask the community for help
66
- name: Request a feature
7-
url: https://github.com/:vendor_slug/:package_name/discussions/new?category=ideas
7+
url: https://github.com/elegantly/laravel-banhammer/discussions/new?category=ideas
88
about: Share ideas for new features
99
- name: Report a security issue
10-
url: https://github.com/:vendor_slug/:package_name/security/policy
10+
url: https://github.com/elegantly/laravel-banhammer/security/policy
1111
about: Learn how to notify us for sensitive bugs

.github/workflows/update-changelog.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Changelog
22

3-
All notable changes to `:package_name` will be documented in this file.
3+
All notable changes to `laravel-banhammer` will be documented in this file.

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) :vendor_name <author@domain.com>
3+
Copyright (c) Elegantly <quentin.gabriele@gmail.com>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 73 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,102 @@
1-
# :package_description
1+
# This is my package laravel-banhammer
22

3-
[![Latest Version on Packagist](https://img.shields.io/packagist/v/:vendor_slug/:package_slug.svg?style=flat-square)](https://packagist.org/packages/:vendor_slug/:package_slug)
4-
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/:vendor_slug/:package_slug/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/:vendor_slug/:package_slug/actions?query=workflow%3Arun-tests+branch%3Amain)
5-
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/:vendor_slug/:package_slug/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/:vendor_slug/:package_slug/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
6-
[![Total Downloads](https://img.shields.io/packagist/dt/:vendor_slug/:package_slug.svg?style=flat-square)](https://packagist.org/packages/:vendor_slug/:package_slug)
7-
<!--delete-->
8-
---
9-
This repo can be used to scaffold a Laravel package. Follow these steps to get started:
3+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/elegantly/laravel-banhammer.svg?style=flat-square)](https://packagist.org/packages/elegantly/laravel-banhammer)
4+
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/elegantly/laravel-banhammer/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/elegantly/laravel-banhammer/actions?query=workflow%3Arun-tests+branch%3Amain)
5+
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/elegantly/laravel-banhammer/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/elegantly/laravel-banhammer/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
6+
[![Total Downloads](https://img.shields.io/packagist/dt/elegantly/laravel-banhammer.svg?style=flat-square)](https://packagist.org/packages/elegantly/laravel-banhammer)
107

11-
1. Press the "Use this template" button at the top of this repo to create a new repo with the contents of this skeleton.
12-
2. Run "php ./configure.php" to run a script that will replace all placeholders throughout all the files.
13-
3. Have fun creating your package.
14-
4. If you need help creating a package, consider picking up our <a href="https://laravelpackage.training">Laravel Package Training</a> video course.
15-
---
16-
<!--/delete-->
17-
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
18-
19-
## Support us
20-
21-
[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/:package_name.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/:package_name)
22-
23-
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
24-
25-
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
8+
A simple package to ban an model (users, teams...).
269

2710
## Installation
2811

2912
You can install the package via composer:
3013

3114
```bash
32-
composer require :vendor_slug/:package_slug
15+
composer require elegantly/laravel-banhammer
3316
```
3417

35-
You can publish and run the migrations with:
18+
First, publish the config with:
3619

3720
```bash
38-
php artisan vendor:publish --tag=":package_slug-migrations"
39-
php artisan migrate
21+
php artisan vendor:publish --tag="banhammer-config"
4022
```
4123

42-
You can publish the config file with:
24+
Then define the bannable models in the config file like this:
25+
26+
```php
27+
use Elegantly\Banhammer\Models\Ban;
28+
use Illuminate\Foundation\Auth\User;
29+
30+
return [
31+
32+
'model_ban' => Ban::class,
33+
34+
'model_user' => User::class,
35+
36+
'bannables' => [
37+
\App\Models\User::class,
38+
// \App\Models\Team::class
39+
],
40+
41+
];
42+
43+
```
44+
45+
Next, publish and run the migrations with:
4346

4447
```bash
45-
php artisan vendor:publish --tag=":package_slug-config"
48+
php artisan vendor:publish --tag="banhammer-migrations"
49+
php artisan migrate
4650
```
4751

48-
This is the contents of the published config file:
52+
Finally schedule the command from `bootstrap/app.php` with:
4953

5054
```php
51-
return [
52-
];
55+
use Illuminate\Foundation\Application;
56+
use Illuminate\Console\Scheduling\Schedule;
57+
use Elegantly\Banhammer\Commands\DenormalizeBannableCommand;
58+
59+
return Application::configure(basePath: dirname(__DIR__))
60+
// ...
61+
->withSchedule(function (Schedule $schedule) {
62+
$schedule->command(DenormalizeBannableCommand::class)->everyMinute();
63+
})
64+
->create();
5365
```
5466

55-
Optionally, you can publish the views using
67+
Or from `routes/console.php` with:
5668

57-
```bash
58-
php artisan vendor:publish --tag=":package_slug-views"
69+
```php
70+
use Illuminate\Support\Facades\Schedule;
71+
use Elegantly\Banhammer\Commands\DenormalizeBannableCommand;
72+
73+
Schedule::command(DenormalizeBannableCommand::class)->everyMinute();
5974
```
6075

6176
## Usage
6277

78+
### Prepare your models:
79+
80+
```php
81+
namespace App\Models;
82+
83+
use Elegantly\Banhammer\Models\Concerns\Bannable;
84+
use Elegantly\Banhammer\Models\Contracts\BannableContract;
85+
use Illuminate\Foundation\Auth\User as Authenticatable;
86+
87+
class User extends Authenticatable implements BannableContract
88+
{
89+
use Bannable;
90+
}
91+
```
92+
6393
```php
64-
$variable = new VendorName\Skeleton();
65-
echo $variable->echoPhrase('Hello, VendorName!');
94+
$user->ban(
95+
level: 0,
96+
reason: "spam",
97+
from: now(),
98+
until: null,
99+
);
66100
```
67101

68102
## Testing
@@ -85,8 +119,8 @@ Please review [our security policy](../../security/policy) on how to report secu
85119

86120
## Credits
87121

88-
- [:author_name](https://github.com/:author_username)
89-
- [All Contributors](../../contributors)
122+
- [Quentin Gabriele](https://github.com/QuentinGab)
123+
- [All Contributors](../../contributors)
90124

91125
## License
92126

composer.json

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
2-
"name": ":vendor_slug/:package_slug",
3-
"description": ":package_description",
2+
"name": "elegantly/laravel-banhammer",
3+
"description": "Ban any model in your Laravel App",
44
"keywords": [
5-
":vendor_name",
5+
"Elegantly",
66
"laravel",
7-
":package_slug"
7+
"laravel-banhammer"
88
],
9-
"homepage": "https://github.com/:vendor_slug/:package_slug",
9+
"homepage": "https://github.com/elegantly/laravel-banhammer",
1010
"license": "MIT",
1111
"authors": [
1212
{
13-
"name": ":author_name",
14-
"email": "author@domain.com",
13+
"name": "Quentin Gabriele",
14+
"email": "quentin.gabriele@gmail.com",
1515
"role": "Developer"
1616
}
1717
],
@@ -30,28 +30,44 @@
3030
"pestphp/pest-plugin-laravel": "^3.0",
3131
"phpstan/extension-installer": "^1.3||^2.0",
3232
"phpstan/phpstan-deprecation-rules": "^1.1||^2.0",
33-
"phpstan/phpstan-phpunit": "^1.3||^2.0",
34-
"spatie/laravel-ray": "^1.35"
33+
"phpstan/phpstan-phpunit": "^1.3||^2.0"
3534
},
3635
"autoload": {
3736
"psr-4": {
38-
"VendorName\\Skeleton\\": "src/",
39-
"VendorName\\Skeleton\\Database\\Factories\\": "database/factories/"
37+
"Elegantly\\Banhammer\\": "src/",
38+
"Elegantly\\Banhammer\\Database\\Factories\\": "database/factories/"
4039
}
4140
},
4241
"autoload-dev": {
4342
"psr-4": {
44-
"VendorName\\Skeleton\\Tests\\": "tests/",
45-
"Workbench\\App\\": "workbench/app/"
43+
"Elegantly\\Banhammer\\Tests\\": "tests/",
44+
"Workbench\\App\\": "workbench/app/",
45+
"Workbench\\Database\\Factories\\": "workbench/database/factories/",
46+
"Workbench\\Database\\Seeders\\": "workbench/database/seeders/"
4647
}
4748
},
4849
"scripts": {
49-
"post-autoload-dump": "@composer run prepare",
50+
"post-autoload-dump": [
51+
"@clear",
52+
"@prepare",
53+
"@composer run prepare"
54+
],
5055
"prepare": "@php vendor/bin/testbench package:discover --ansi",
5156
"analyse": "vendor/bin/phpstan analyse",
5257
"test": "vendor/bin/pest",
5358
"test-coverage": "vendor/bin/pest --coverage",
54-
"format": "vendor/bin/pint"
59+
"format": "vendor/bin/pint",
60+
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
61+
"build": "@php vendor/bin/testbench workbench:build --ansi",
62+
"serve": [
63+
"Composer\\Config::disableProcessTimeout",
64+
"@build",
65+
"@php vendor/bin/testbench serve --ansi"
66+
],
67+
"lint": [
68+
"@php vendor/bin/pint --ansi",
69+
"@php vendor/bin/phpstan analyse --verbose --ansi"
70+
]
5571
},
5672
"config": {
5773
"sort-packages": true,
@@ -63,10 +79,10 @@
6379
"extra": {
6480
"laravel": {
6581
"providers": [
66-
"VendorName\\Skeleton\\SkeletonServiceProvider"
82+
"Elegantly\\Banhammer\\BanhammerServiceProvider"
6783
],
6884
"aliases": {
69-
"Skeleton": "VendorName\\Skeleton\\Facades\\Skeleton"
85+
"Banhammer": "Elegantly\\Banhammer\\Facades\\Banhammer"
7086
}
7187
}
7288
},

config/banhammer.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Elegantly\Banhammer\Models\Ban;
6+
use Illuminate\Foundation\Auth\User;
7+
8+
return [
9+
10+
'model_ban' => Ban::class,
11+
12+
'model_user' => User::class,
13+
14+
'bannables' => [
15+
// \App\Models\User::class
16+
],
17+
18+
];

config/skeleton.php

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)