PHP code example of maggomann / filament-model-translator
1. Go to this page and download the library: Download maggomann/filament-model-translator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
maggomann / filament-model-translator example snippets
use Maggomann\FilamentModelTranslator\FilamentModelTranslatorServicePlugin;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
...
->plugins([
FilamentModelTranslatorServicePlugin::make()
]);
}
}
public static function getModelLabel(): string;
public static function getPluralModelLabel(): string;
protected static function getNavigationGroup(): ?string;
namespace Maggomann\YourPackageFolder\Resources;
use Filament\Resources\Resource;
use Maggomann\FilamentModelTranslator\Contracts\TranslateableResources;
use Maggomann\FilamentModelTranslator\Traits\HasTranslateableResources;
class TranslateableResource extends Resource implements TranslateableResources
{
use HasTranslateableResources;
protected static ?string $translateableKey = 'your-package-name::';
public function transPackageKey(): ?string
{
return static::$translateableKey;
}
}
class LeagueResource extends TranslateableResource
{
protected static ?string $model = League::class;
class FederationResource extends TranslateableResource
{
protected static ?string $model = Federation::class;
namespace Maggomann\YourPackageFolder\Resources;
use Filament\Resources\Resource;
use Maggomann\FilamentModelTranslator\Contracts\TranslateableResources;
use Maggomann\FilamentModelTranslator\Traits\HasTranslateableResources;
class LeagueResource extends Resource implements TranslateableResources
{
use HasTranslateableResources;
protected static ?string $translateableKey = 'your-package-name::';
public function transPackageKey(): ?string
{
return static::$translateableKey;
}
protected static ?string $model = League::class;
namespace Maggomann\YourPackageFolder\Resources;
use Filament\Resources\Resource;
use Maggomann\FilamentModelTranslator\Contracts\TranslateableResources;
use Maggomann\FilamentModelTranslator\Traits\HasTranslateableResources;
class FederationResource extends Resource implements TranslateableResources
{
use HasTranslateableResources;
protected static ?string $translateableKey = 'your-package-name::';
public function transPackageKey(): ?string
{
return static::$translateableKey;
}
protected static ?string $model = Federation::class;
public static function getModelLabel(): string;
public static function getPluralModelLabel(): string;
namespace Maggomann\YourPackageFolder\Resources;
use Filament\Resources\RelationManagers\RelationManager;
use Maggomann\FilamentModelTranslator\Contracts\Translateable;
use Maggomann\FilamentModelTranslator\Traits\HasTranslateableRelationManager;
class TranslateableRelationManager extends RelationManager implements Translateable
{
use HasTranslateableRelationManager;
protected static ?string $translateablePackageKey = 'your-package-name::';
}
namespace Maggomann\YourPackageFolder\Resources\FederationResource\RelationManagers;
use Maggomann\YourPackageFolder\Resources\TranslateableRelationManager;
class LeaguesRelationManager extends TranslateableRelationManager
{
namespace Maggomann\YourPackageFolder\Resources\FederationResource\RelationManagers;
use Filament\Resources\RelationManagers\RelationManager;
use Maggomann\FilamentModelTranslator\Contracts\Translateable;
use Maggomann\FilamentModelTranslator\Traits\HasTranslateableRelationManager;
class LeaguesRelationManager extends RelationManager implements Translateable
{
use HasTranslateableRelationManager;
protected static ?string $translateablePackageKey = 'your-package-name::';
EloquentModel::transAttribute('your_attributes_key');
// Example
TextInput::make('name')
->label(Federation::transAttribute('name'))
->
namespace Maggomann\YourPackageFolder\Models;
use Illuminate\Database\Eloquent\Model;
use Maggomann\FilamentModelTranslator\Traits\HasTranslateableModel;
class TranslateableModel extends Model
{
use HasTranslateableModel;
protected static ?string $translateablePackageKey = 'your-package-name::';
}
namespace Maggomann\YourPackageFolder\Models;
class Federation extends TranslateableModel
{
namespace Maggomann\YourPackageFolder\Models;
use Illuminate\Database\Eloquent\Model;
use Maggomann\FilamentModelTranslator\Traits\HasTranslateableModel;
class Federation extends Model
{
use HasTranslateableModel;
protected static ?string $translateablePackageKey = 'your-package-name::';
console
lang
de
filament-model.php
en
filament-model.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.