Files
hoshpoint-backend/app/Models/Template.php
soheil khaledabadi ae974c2afa feat: add ApiResponse trait for standardized API responses
chore: update composer dependencies to include phppresentation

chore: update composer.lock after adding phppresentation

feat: create categories migration for category management

feat: create templates migration for template storage

feat: create template generations migration for tracking template usage

feat: create template keys migration for template customization

feat: create notifications migration for user notifications

feat: update API routes for categories, templates, and user profile management

docs: update API documentation to include new endpoints for profile and wallet
2026-07-07 01:03:12 +03:30

64 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
#[Fillable([
'category_id',
'title',
'slug',
'description',
'file_path',
'thumbnail_path',
'is_active',
'created_by',
])]
class Template extends Model
{
/**
* @return BelongsTo<Category, $this>
*/
public function category(): BelongsTo
{
return $this->belongsTo(Category::class);
}
/**
* @return BelongsTo<User, $this>
*/
public function creator(): BelongsTo
{
return $this->belongsTo(User::class, 'created_by');
}
/**
* @return HasMany<TemplateKey, $this>
*/
public function keys(): HasMany
{
return $this->hasMany(TemplateKey::class)->orderBy('sort_order');
}
/**
* @return HasMany<TemplateGeneration, $this>
*/
public function generations(): HasMany
{
return $this->hasMany(TemplateGeneration::class)->latest();
}
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'is_active' => 'boolean',
];
}
}