Files
new_raffles/Modules/CCMS/app/Models/Career.php
Subash 52732b0f09 feat: Implement Career Management Module
- Created CareerController for handling career-related CRUD operations.
- Added Career model with necessary attributes and relationships.
- Created migration for careers table with relevant fields.
- Developed views for creating, editing, and listing careers.
- Implemented DataTables for career listing with action buttons.
- Added routes for career management and integrated with sidebar.
- Created client-side career detail template and updated career listing page.
- Added helper functions to fetch active careers for display.
2025-08-22 13:52:06 +05:45

98 lines
2.1 KiB
PHP

<?php
namespace Modules\CCMS\Models;
use App\Traits\CreatedUpdatedBy;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Modules\CCMS\Traits\UpdateCustomFields;
use Modules\Document\Models\Document;
use App\Traits\AddToDocumentCollection;
class Career extends Model
{
use HasFactory, UpdateCustomFields, AddToDocumentCollection, CreatedUpdatedBy;
protected $fillable = [
'department',
'job_title',
'job_description',
'job_requirements',
'salary_range',
'location',
'position',
'start_date',
'end_date',
'status',
'createdby',
'updatedby',
'order',
];
protected function casts(): array
{
return [
'custom' => 'array',
];
}
protected function images(): Attribute
{
return Attribute::make(
get: function ($value) {
if (empty($value)) {
return [];
}
$parts = explode(',', $value);
return array_map(fn($part) => asset(trim($part)), $parts);
}
);
}
protected function image(): Attribute
{
return Attribute::make(
get: fn($value) => asset($value),
);
}
protected function banner(): Attribute
{
return Attribute::make(
get: fn($value) => asset($value),
);
}
protected function sidebarImage(): Attribute
{
return Attribute::make(
get: fn($value) => asset($value),
);
}
protected function iconImage(): Attribute
{
return Attribute::make(
get: fn($value) => asset($value),
);
}
public function children()
{
return $this->hasMany(Career::class, 'parent_id');
}
public function parent()
{
return $this->belongsTo(Career::class, 'parent_id');
}
public function documents()
{
return $this->morphMany(Document::class, 'documentable');
}
}