<?php
 namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Language extends Model { use HasFactory; protected $fillable = [ 'native_name', 'a2_iso', 'a3_iso', 'status', 'site_default', 'admin_default', ]; protected $casts = [ 'status' => 'boolean', 'site_default' => 'boolean', 'admin_default' => 'boolean', ]; public function scopeActive($query) { return $query->where('status', true); } public static function getSiteDefault() { return static::where('site_default', true)->first(); } public static function getSiteDefaultCode() { $defaultLanguage = static::getSiteDefault(); return $defaultLanguage ? $defaultLanguage->a2_iso : 'tr'; } public static function getAdminDefault() { return static::where('admin_default', true)->first(); } public static function getAdminDefaultCode() { $defaultLanguage = static::getAdminDefault(); return $defaultLanguage ? $defaultLanguage->a2_iso : 'en'; } } 