Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ yarn-error.log
/.nova
/.vscode
/.zed
/.vite
_ide_helper.php
_ide_helper_models.php
.phpstorm.meta.php
.php-cs-fixer.cache
17 changes: 17 additions & 0 deletions app/Models/BaseModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
*
*
* @method static \Illuminate\Database\Eloquent\Builder<static>|BaseModel newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|BaseModel newQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|BaseModel query()
* @mixin \Eloquent
*/
class BaseModel extends Model {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем вам пустой базовый класс?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

На случай, если нужно будет что-то добавить во все модели сразу. Не знаю, логирование какое-нибудь.

42 changes: 42 additions & 0 deletions app/Models/Category.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

namespace App\Models;

use Eloquent;
use Illuminate\Database\Eloquent\Relations\MorphOne;
use Illuminate\Support\Carbon;

/**
* Категории объявлений
*
* @property int $id
* @property string $name Название категории
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @method static \Illuminate\Database\Eloquent\Builder<static>|Category newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Category newQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Category query()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Category whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Category whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Category whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Category whereUpdatedAt($value)
* @property-read Image $image
* @mixin Eloquent
*/
class Category extends BaseModel
{
protected $fillable = [
'name',
];
protected $hidden = [
'created_at',
'updated_at',
];

public function image(): MorphOne
{
return $this->morphOne(Image::class, 'image');
}
}
63 changes: 63 additions & 0 deletions app/Models/City.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

declare(strict_types=1);

namespace App\Models;

use Eloquent;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Carbon;

/**
* Города
*
* @property int $id
* @property string $name Название города
* @property string $latitude Широта
* @property string $longitude Долгота
* @property int $timezone Часовой пояс
* @property int $country_id
* @property int $region_id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @method static \Illuminate\Database\Eloquent\Builder<static>|City newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|City newQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|City query()
* @method static \Illuminate\Database\Eloquent\Builder<static>|City whereCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|City whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|City whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|City whereLatitude($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|City whereLongitude($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|City whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|City whereRegionId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|City whereTimezone($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|City whereUpdatedAt($value)
* @property-read Country $country
* @property-read Region $region
* @mixin Eloquent
*/
class City extends BaseModel
{
protected $fillable = [
'name',
'latitude',
'longitude',
'timezone',
'country_id',
'region_id',
];
protected $hidden = [
'created_at',
'updated_at',
];

public function country(): BelongsTo
{
return $this->belongsTo(Country::class);
}

public function region(): BelongsTo
{
return $this->belongsTo(Region::class);
}
}
54 changes: 54 additions & 0 deletions app/Models/Country.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

declare(strict_types=1);

namespace App\Models;

use Eloquent;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Carbon;

/**
* Страны
*
* @property int $id
* @property string $name Название страны
* @property string $code
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @method static \Illuminate\Database\Eloquent\Builder<static>|Country newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Country newQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Country query()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Country whereCode($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Country whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Country whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Country whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Country whereUpdatedAt($value)
* @property-read Collection<int, City> $cities
* @property-read int|null $cities_count
* @property-read Collection<int, Region> $regions
* @property-read int|null $regions_count
* @mixin Eloquent
*/
class Country extends BaseModel
{
protected $fillable = [
'name',
'code',
];
protected $hidden = [
'created_at',
'updated_at',
];

public function regions(): HasMany
{
return $this->hasMany(Region::class);
}

public function cities(): HasMany
{
return $this->hasMany(City::class);
}
}
41 changes: 41 additions & 0 deletions app/Models/Currency.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace App\Models;

use Eloquent;
use Illuminate\Support\Carbon;

/**
* Валюты
*
* @property int $id
* @property string $name Название валюты
* @property string $code Код
* @property string $char Символ
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @method static \Illuminate\Database\Eloquent\Builder<static>|Currency newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Currency newQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Currency query()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Currency whereChar($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Currency whereCode($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Currency whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Currency whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Currency whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Currency whereUpdatedAt($value)
* @mixin Eloquent
*/
class Currency extends BaseModel
{
protected $fillable = [
'name',
'code',
'char',
];
protected $hidden = [
'created_at',
'updated_at',
];
}
54 changes: 54 additions & 0 deletions app/Models/Image.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

declare(strict_types=1);

namespace App\Models;

use Database\Factories\ImageFactory;
use Eloquent;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Support\Carbon;

/**
* Изображения
*
* @property int $id
* @property string $path Путь к изображению
* @property bool $main Основное изображение
* @property string $image_type
* @property int $image_id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @method static ImageFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder<static>|Image newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Image newQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Image query()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Image whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Image whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Image whereImageId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Image whereImageType($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Image whereMain($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Image wherePath($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Image whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Image whereUserId($value)
* @property-read \Illuminate\Database\Eloquent\Model|\Eloquent $image
* @mixin Eloquent
*/
class Image extends BaseModel
{
/** @use HasFactory<ImageFactory> */
use hasFactory;

protected $fillable = [
'path',
'main',
'image_type',
'image_id',
];

public function image(): MorphTo
{
return $this->morphTo();
}
}
Loading