Unit.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  6. use Illuminate\Database\Eloquent\Relations\BelongsToMany;
  7. use Illuminate\Database\Eloquent\Relations\HasMany;
  8. use Illuminate\Database\Eloquent\SoftDeletes;
  9. /**
  10. * @property int $id
  11. * @property string $fantasy_name
  12. * @property string $social_reason
  13. * @property string $cnpj
  14. * @property string|null $state_registration
  15. * @property string $name_responsible
  16. * @property string $street
  17. * @property string|null $address_number
  18. * @property string $postal_code
  19. * @property string $neighborhood
  20. * @property string|null $complement
  21. * @property int $city_id
  22. * @property int $state_id
  23. * @property string $email
  24. * @property string|null $secondary_email
  25. * @property string $phone_number
  26. * @property string|null $cell_number
  27. * @property string|null $avatar_url
  28. * @property \Carbon\Carbon $created_at
  29. * @property \Carbon\Carbon $updated_at
  30. * @property \Carbon\Carbon|null $deleted_at
  31. * @property-read \App\Models\City $city
  32. * @property-read \App\Models\State $state
  33. */
  34. class Unit extends Model
  35. {
  36. use HasFactory, SoftDeletes;
  37. protected $table = 'units';
  38. protected $guarded = ['id'];
  39. protected $casts = [
  40. 'created_at' => 'datetime',
  41. 'updated_at' => 'datetime',
  42. 'deleted_at' => 'datetime',
  43. ];
  44. public function city(): BelongsTo
  45. {
  46. return $this->belongsTo(City::class, 'city_id');
  47. }
  48. public function state(): BelongsTo
  49. {
  50. return $this->belongsTo(State::class, 'state_id');
  51. }
  52. public function partners(): HasMany
  53. {
  54. return $this->hasMany(UnitPartner::class, 'unit_id');
  55. }
  56. public function franchisees(): BelongsToMany
  57. {
  58. return $this->belongsToMany(Franchisee::class, 'franchisee_units');
  59. }
  60. }