Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

DocumentTotal.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace App\Models\Document;
  3. use App\Traits\Blamable;
  4. use App\Traits\CompanyOwned;
  5. use Database\Factories\DocumentTotalFactory;
  6. use Illuminate\Database\Eloquent\Factories\Factory;
  7. use Illuminate\Database\Eloquent\Factories\HasFactory;
  8. use Illuminate\Database\Eloquent\Model;
  9. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  10. use Wallo\FilamentCompanies\FilamentCompanies;
  11. class DocumentTotal extends Model
  12. {
  13. use Blamable, CompanyOwned, HasFactory;
  14. protected $table = 'document_totals';
  15. protected $fillable = [
  16. 'company_id',
  17. 'document_id',
  18. 'type',
  19. 'code',
  20. 'name',
  21. 'subtotal',
  22. 'discount',
  23. 'tax',
  24. 'total',
  25. 'created_by',
  26. 'updated_by',
  27. ];
  28. public function company(): BelongsTo
  29. {
  30. return $this->belongsTo(FilamentCompanies::companyModel(), 'company_id');
  31. }
  32. public function createdBy(): BelongsTo
  33. {
  34. return $this->belongsTo(FilamentCompanies::userModel(), 'created_by');
  35. }
  36. public function updatedBy(): BelongsTo
  37. {
  38. return $this->belongsTo(FilamentCompanies::userModel(), 'updated_by');
  39. }
  40. public function document(): BelongsTo
  41. {
  42. return $this->belongsTo(Document::class);
  43. }
  44. public function scopeInvoice($query)
  45. {
  46. return $query->where('type', 'invoice');
  47. }
  48. public function scopeBill($query)
  49. {
  50. return $query->where('type', 'bill');
  51. }
  52. protected static function newFactory(): Factory
  53. {
  54. return DocumentTotalFactory::new();
  55. }
  56. }