Course.php 766 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\Factories\HasFactory;
  5. use Illuminate\Foundation\Auth\User as Authenticatable;
  6. use Illuminate\Notifications\Notifiable;
  7. class Course extends Model
  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. 'name',
  18. 'description',
  19. 'price',
  20. ];
  21. public function application(): HasOne
  22. {
  23. return $ths->hasOne(Application::class);
  24. }
  25. public function getFormatPrice(): string
  26. {
  27. return number_format($this->price, 0, ",", " ") . " Руб";
  28. }
  29. }