Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .ddev/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ xdebug_enabled: false
additional_hostnames: []
additional_fqdns: []
database:
type: mariadb
version: "10.4"
type: mariadb
version: "10.4"
host_db_port: "32770"
use_dns_when_possible: true
composer_version: "2"
web_environment: []
Expand Down
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
[email protected]
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
Expand Down
2 changes: 1 addition & 1 deletion .env.testing
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ APP_URL="https://laravel.ddev.site"
DB_CONNECTION="mysql"
DB_HOST="db"
DB_PORT="3306"
DB_DATABASE="db_test"
DB_DATABASE="test"
DB_USERNAME="db"
DB_PASSWORD="db"

Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- (Bug fix, feature, changelog, release, docs update, etc. ) -->

**What is the new behavior?**
Fix [XXX-nnnn](https://mloru.atlassian.net/browse/XXX-nnnn)
<!-- Describe the new behavior -->

**Does this PR introduce a breaking change?**
No
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,36 @@ ddev start
ddev composer install
```

### Migrazione database
### Database migration

The project uses two database:

* For `local` environment: `db`
* For `testing` environment: `db_test`
* For `testing` environment: `test`

Migrations on `db_test` are not required since `LazilyRefreshDatabase` trait is used.
Migrations on `test` are not required since the `LazilyRefreshDatabase` trait is used.
See [Resetting The Database After Each Test](https://laravel.com/docs/5.7/database-testing#resetting-the-database-after-each-test)
for more information.

```shell
ddev exec php artisan migrate
ddev artisan migrate
```

### Run seeders

```shell
ddev exec php artisan db:seed
ddev artisan db:seed
```

To set up a fresh version of database and run seeders at the same time:

```shell
ddev exec php artisan migrate:fresh --seed
ddev artisan migrate:fresh --seed
```

## Styles and static analyzers

Run checks prior to commit
Run checks before committing:

```shell
ddev exec tools/static-analysis.sh
Expand All @@ -67,7 +67,7 @@ Fix style in project with PHP CS Fixer:
ddev exec tools/fix-style.sh
```

To run Php Insights with verbose output:
To run PHP Insights with verbose output:

```shell
ddev exec ./vendor/bin/phpinsights -v
Expand Down Expand Up @@ -104,7 +104,7 @@ By defaults, queues are sync:
QUEUE_CONNECTION=sync
```

It's possible to set the async with:
It's possible to set them as async with:

```dotenv
QUEUE_CONNECTION=redis
Expand All @@ -115,12 +115,12 @@ Redis is used as message queues manager.
### Local development

```shell
ddev exec php artisan queue:work
ddev artisan queue:work
```

### Test

During tests, queues are sync since in `.env.testing` there is:
During tests, queues are sync since `.env.testing` contains:

```dotenv
QUEUE_CONNECTION=sync
Expand Down
29 changes: 29 additions & 0 deletions app/Models/Product.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php declare(strict_types=1);

namespace App\Models;

use Cknow\Money\Casts\MoneyDecimalCast;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

/**
* Class Product.
*/
final class Product extends Model
{
use HasFactory;

/**
* {@inheritdoc}
*/
protected $casts = [
'price' => MoneyDecimalCast::class . ':EUR,true',
];

/**
* {@inheritdoc}
*/
protected $guarded = [
'id',
];
}
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "mloru/root-price-list",
"name": "rootclub/price-list",
"type": "project",
"description": "Simple project to display and manage the Root Club price list.",
"support": {
"issues": "https://github.com/mloru/root-price-list/issues",
"source": "https://github.com/mloru/root-price-list"
"issues": "https://github.com/rootclub/price-list/issues",
"source": "https://github.com/rootclub/price-list"
},
"keywords": [
"laravel",
Expand All @@ -19,6 +19,7 @@
"require": {
"php": "^8.3",
"ext-readline": "*",
"cknow/laravel-money": "^7.2",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.10",
"laravel/sanctum": "^3.3",
Expand Down
158 changes: 157 additions & 1 deletion composer.lock

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

41 changes: 41 additions & 0 deletions database/factories/ProductFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php declare(strict_types=1);

namespace Database\Factories;

use App\Models\Product;
use Cknow\Money\Money;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @template TModel of Product
*
* @extends Factory<TModel>
*/
class ProductFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var class-string<TModel>
*/
protected $model = Product::class;

/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->word(),

'price' => Money::EUR(
fake()->randomFloat(
nbMaxDecimals: 2,
max: 100
)
),
];
}
}
Loading