Application.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App\Models;
  3. // use Illuminate\Contracts\Auth\MustVerifyEmail;
  4. use Illuminate\Database\Eloquent\Factories\HasFactory;
  5. use Illuminate\Foundation\Auth\User as Authenticatable;
  6. use Illuminate\Notifications\Notifiable;
  7. class User extends Authenticatable
  8. {
  9. /** @use HasFactory<\Database\Factories\UserFactory> */
  10. use HasFactory, Notifiable;
  11. /**
  12. * The attributes that are mass assignable.
  13. *
  14. * @var list<string>
  15. */
  16. protected $fillable = [
  17. 'user_id',
  18. 'course_id',
  19. 'start_date',
  20. 'payment_method',
  21. 'status',
  22. 'comment',
  23. ];
  24. protected function casts(): array
  25. {
  26. return [
  27. 'start_date' => 'date',
  28. ];
  29. }
  30. public function user(): belongsTo
  31. {
  32. return $this->hasMany(User::class);
  33. }
  34. public function course(): belongsTo
  35. {
  36. return $this->hasMany(Course::class);
  37. }
  38. public function canAddComment(): bool
  39. {
  40. return $this->status === "completed" && !$this->comment;
  41. }
  42. }