Open MattLoyeD opened 6 days ago
Hi @MattLoyeD,
What does your Category
model look like?
Thanks for your kind answer, here is the Model :
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Activitylog\LogOptions;
use Spatie\Translatable\HasTranslations;
use Staudenmeir\LaravelAdjacencyList\Eloquent\HasRecursiveRelationships;
class Category extends Model
{
use HasFactory;
use HasUuids;
use LogsActivity;
use HasTranslations;
use HasRecursiveRelationships;
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'description',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'hash' => 'string',
];
protected $translatable = [
'name',
'description'
];
protected $with = [
'descendants',
];
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()
->logOnly(['name']);
}
}
I do not get translated fields when using : Category::tree(3)->get()
Do the translations work correctly with a "normal" query like Category::all()
?
Hi,
I do not get translated fields when using :
Category::tree(3)->get()
Any idea on how to solve this ? I'll be glad to do a PR etc, but I did not succeed so far on getting it work along your nice package.
I tried this below but couldn't get it work as well :
See : https://spatie.be/docs/laravel-translatable/v6/basic-usage/getting-and-settings-translations