Skip to content

Commit

Permalink
Refactor model factories for better clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
tvup committed Oct 12, 2024
1 parent 51a73d6 commit b8f4963
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 10 deletions.
1 change: 0 additions & 1 deletion app/Http/Middleware/ProtectedRoutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public function handle($request, Closure $next, ...$guards): mixed
return redirect('/');
}

// @phpstan-ignore-next-line
return parent::handle($request, $next, ...$guards);

Check failure on line 17 in app/Http/Middleware/ProtectedRoutes.php

View workflow job for this annotation

GitHub Actions / build-test

Parameter #3 ...$guards of method Illuminate\Auth\Middleware\Authenticate::handle() expects string, array<string> given.
}
}
3 changes: 0 additions & 3 deletions app/Models/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
namespace App\Models;

use App\Enums\SourceEnum;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class BaseModel extends Model
{
use HasFactory;

protected $guarded = [];

public const SOURCE = SourceEnum::POWERUSE;
Expand Down
3 changes: 0 additions & 3 deletions app/Models/Charge.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Enums\SourceEnum;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;

/**
Expand All @@ -27,8 +26,6 @@
*/
class Charge extends BaseModel
{
use HasFactory;

protected $appends = ['source'];

public function getSourceAttribute(): ?SourceEnum
Expand Down
3 changes: 0 additions & 3 deletions app/Models/ChargePrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

Expand All @@ -18,8 +17,6 @@
*/
class ChargePrice extends Model
{
use HasFactory;

/**
* @return BelongsTo<Charge, ChargePrice>
*/
Expand Down
2 changes: 2 additions & 0 deletions app/Models/DatahubPriceList.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Models;

use Carbon\Carbon;
use Database\Factories\DatahubPriceListFactory;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
Expand Down Expand Up @@ -50,6 +51,7 @@
*/
class DatahubPriceList extends BaseModel
{
/** @use HasFactory<DatahubPriceListFactory> */
use HasFactory;

Check failure on line 55 in app/Models/DatahubPriceList.php

View workflow job for this annotation

GitHub Actions / build-test

PHPDoc tag @use contains generic type Illuminate\Database\Eloquent\Factories\HasFactory<Database\Factories\DatahubPriceListFactory> but trait Illuminate\Database\Eloquent\Factories\HasFactory is not generic.
use SoftDeletes;

Expand Down
2 changes: 2 additions & 0 deletions app/Models/MeteringPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Casts\CopenhagenDate;
use App\Enums\SourceEnum;
use Carbon\Carbon;
use Database\Factories\MeteringPointFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

Expand Down Expand Up @@ -40,6 +41,7 @@
*/
class MeteringPoint extends BaseModel
{
/** @use HasFactory<MeteringPointFactory> */
use HasFactory;

Check failure on line 45 in app/Models/MeteringPoint.php

View workflow job for this annotation

GitHub Actions / build-test

PHPDoc tag @use contains generic type Illuminate\Database\Eloquent\Factories\HasFactory<Database\Factories\MeteringPointFactory> but trait Illuminate\Database\Eloquent\Factories\HasFactory is not generic.

protected $appends = ['source'];
Expand Down
2 changes: 2 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Models;

use Carbon\Carbon;
use Database\Factories\UserFactory;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
Expand All @@ -26,6 +27,7 @@
*/
class User extends Authenticatable implements MustVerifyEmail
{
/** @use HasFactory<UserFactory> */
use HasApiTokens, HasFactory, Notifiable;

Check failure on line 31 in app/Models/User.php

View workflow job for this annotation

GitHub Actions / build-test

PHPDoc tag @use contains generic type Illuminate\Database\Eloquent\Factories\HasFactory<Database\Factories\UserFactory> but trait Illuminate\Database\Eloquent\Factories\HasFactory is not generic.

/**
Expand Down

0 comments on commit b8f4963

Please sign in to comment.