Skip to content

Commit

Permalink
feat: add subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
halivert committed Jul 5, 2023
1 parent 419fb1e commit 3055ebd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/Enums/Subscription.php
@@ -0,0 +1,8 @@
<?php

namespace App\Enums;

enum Subscription: string
{
case Free = 'Free';
}
11 changes: 11 additions & 0 deletions app/Models/User.php
Expand Up @@ -2,6 +2,7 @@


namespace App\Models; namespace App\Models;


use App\Enums\Subscription;
use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
Expand Down Expand Up @@ -42,5 +43,15 @@ class User extends Authenticatable
protected $casts = [ protected $casts = [
'email_verified_at' => 'datetime', 'email_verified_at' => 'datetime',
'password' => 'hashed', 'password' => 'hashed',
'subscription' => Subscription::class,
];

/**
* The model's default values for attributes.
*
* @var array
*/
protected $attributes = [
'subscription' => Subscription::Free,
]; ];
} }
2 changes: 2 additions & 0 deletions database/factories/UserFactory.php
Expand Up @@ -2,6 +2,7 @@


namespace Database\Factories; namespace Database\Factories;


use App\Enums\Subscription;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str; use Illuminate\Support\Str;


Expand All @@ -24,6 +25,7 @@ public function definition(): array
'email_verified_at' => now(), 'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10), 'remember_token' => Str::random(10),
'subscription' => fake()->randomElement(Subscription::cases()),
]; ];
} }


Expand Down

0 comments on commit 3055ebd

Please sign in to comment.