How to call a static Method in Laravel Translatable package on per model basis

485 Views Asked by At

I am using this package for managing translations in a Laravel project. The resulting output of an API endpoint is as shown in the image with translation array.

In there documentation (link: https://docs.astrotomic.info/laravel-translatable/package/methods#static-disableautoloadtranslations) it is mentioned we can disable this translation array on entire project from config file or disable per model using this function static disableAutoloadTranslations(). I am not sure how to call this on a per model basis?

enter image description here

    namespace App\Models;
    use Astrotomic\Translatable\Translatable;
    use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Storage;

    class Category extends Model{
    
    use Translatable, SoftDeletes;
    public $translatedAttributes = ['title'];

    protected $guarded = ['id'];

    public $guard_name = 'admin';

    public function getIconAttribute($value)
    {
        return ($value != null) ? Storage::disk('public')->url($value) : null;
    }

    self::disableAutoloadTranslations();

}
0

There are 0 best solutions below