first commit

This commit is contained in:
2025-07-07 18:01:52 +05:45
commit 71241f5167
2095 changed files with 112735 additions and 0 deletions

70
app/Models/Countries.php Normal file
View File

@ -0,0 +1,70 @@
<?php
namespace App\Models;
use App\Models\Scopes\ActiveScope;
use App\Models\User;
use App\Traits\CreatedUpdatedBy;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Countries extends Model
{
use HasFactory, CreatedUpdatedBy;
protected $primaryKey = 'country_id';
public $timestamps = true;
protected $fillable = [
'title',
'alias',
'text',
'details',
'cover_photo',
'images',
'image_thumb',
'display_order',
'status',
'created_at',
'updated_at',
'seo_keywords',
'seo_title',
'seo_descriptions',
'og_tags',
'createdby',
'updatedby',
];
protected $appends = ['status_name'];
protected function getStatusNameAttribute()
{
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
}
protected static function booted():void{
static::addGlobalScope(new ActiveScope);
}
protected function createdBy(): Attribute
{
return Attribute::make(
get: fn($value) => User::find($value) ? User::find($value)->name : '',
);
}
protected function updatedBy(): Attribute
{
return Attribute::make(
get: fn($value) => User::find($value) ? User::find($value)->name : '',
);
}
public function articles(){
return $this->hasMany(Countryarticles::class,'countries_id');
}
public function institutions(){
return $this->hasMany(Institutions::class,'countries_id');
}
}