Askancy
Askancy
FFilament
Created by Askancy on 1/29/2024 in #❓┊help
Modal in form Resource
In my Filament project, I would like to introduce a modal in the function form of my Resource to indicate the available shortcodes that my writers can use. How can I insert this button that opens a modal?
5 replies
FFilament
Created by Askancy on 12/18/2023 in #❓┊help
Filter in the table but with different model
On a page referencing a table in the "Giochi" model, I would need to insert a filter but referencing the "InfoGiochi" table, which would be a pivot table. The "Giochi" table contains the name of the game, while "InfoGiochi" contains other data such as the date. I would need to get the contents where the "data" column is empty. I have tried unsuccessfully with:
Filter::make('Senza Data')
->query(fn () => InfoGiochi::query()->where('data', null)),
Filter::make('Senza Data')
->query(fn () => InfoGiochi::query()->where('data', null)),
But I don't understand how to connect to a model other than Games...
4 replies
FFilament
Created by Askancy on 11/20/2023 in #❓┊help
Options for the RichEditor
How can I make the RichEditor menu scroll along with the page when the editor gets too big? How do I determine a max size of the Rich Editor? I could not find anything in the documentation that would allow these values to be changed....
4 replies
FFilament
Created by Askancy on 11/18/2023 in #❓┊help
uploader takes up too much space
No description
4 replies
FFilament
Created by Askancy on 11/10/2023 in #❓┊help
Function in aftersave() is not executed
I have this custom function:
CreateTopic('3', $record->titolo, $record->testo, '56')
CreateTopic('3', $record->titolo, $record->testo, '56')
When I use it as Action it works correctly:
Action::make('Generate Topic')
->label('')
->icon('far-comments')
->action(function (Articoli $record): void {
$cTopic = CreateTopic('3', $record->titolo, $record->testo, '56');
$id_topic = json_decode($cTopic->getBody());
},
Action::make('Generate Topic')
->label('')
->icon('far-comments')
->action(function (Articoli $record): void {
$cTopic = CreateTopic('3', $record->titolo, $record->testo, '56');
$id_topic = json_decode($cTopic->getBody());
},
For when I use it in CreateArticle.php as afterSave(), it doesn't execute--how come?
protected function afterSave(): void
{
if ($this->record->is_published === 'Published') {
$cTopic = CreateTopic('3', $this->record->titolo, $this->record->testo, '56');
$id_topic = json_decode($cTopic->getBody());
}
}
protected function afterSave(): void
{
if ($this->record->is_published === 'Published') {
$cTopic = CreateTopic('3', $this->record->titolo, $this->record->testo, '56');
$id_topic = json_decode($cTopic->getBody());
}
}
9 replies
FFilament
Created by Askancy on 11/8/2023 in #❓┊help
Steps of a Wizard in EDIT clickable
No description
7 replies
FFilament
Created by Askancy on 10/28/2023 in #❓┊help
How can I manipulate the response of a post create
Currently my slug system is generated via:
TextInput::make('title')
->required()
->live(onBlur: true)
->afterStateUpdated(fn (string $operation, $state, Forms\Set $set) => $operation === 'create' ? $set('slug', Str::slug($state)) : null),
TextInput::make('slug')
->disabled()
->dehydrated()
->required()
->unique(Article::class, 'slug', ignoreRecord: true),
TextInput::make('title')
->required()
->live(onBlur: true)
->afterStateUpdated(fn (string $operation, $state, Forms\Set $set) => $operation === 'create' ? $set('slug', Str::slug($state)) : null),
TextInput::make('slug')
->disabled()
->dehydrated()
->required()
->unique(Article::class, 'slug', ignoreRecord: true),
so if the item name is: Filamentphp is a package the slug becomes: filamentphp-is-a-package What I would like though, is that in the output it sends to the database, he would add the article id and the extension .html so I would like to become: 1574-filamentphp-is-a-package.html How can I manipulate the response of a post create?
8 replies
FFilament
Created by Askancy on 10/22/2023 in #❓┊help
must be a file of type: image/*.
No description
12 replies
FFilament
Created by Askancy on 10/19/2023 in #❓┊help
Admin pages don't appear
I put my project online with Filamentphp, however the resource pages in Admin do not appear,even though I have the files loaded correctly in \App\Filament\Resources, Am I forgetting something? Only installed plugins appear in the menu.
2 replies
FFilament
Created by Askancy on 10/15/2023 in #❓┊help
error after HasName statement
I need to indicate a different hasname, I followed the guide and in my User.php model I have:
<?php

namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
[...]
use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasName;


class User extends Authenticatable implements FilamentUser, HasName
[...]

public function getFilamentName(): string
{
return "{$this->name} {$this->last_name}";
}
<?php

namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
[...]
use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasName;


class User extends Authenticatable implements FilamentUser, HasName
[...]

public function getFilamentName(): string
{
return "{$this->name} {$this->last_name}";
}
But I get the error: Class App\Models\User contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Filament\Models\Contracts\FilamentUser::canAccessPanel) I get the error even if I only put FilamentUser, if I use HasName alone, I don't get the error
class User extends Authenticatable implements FilamentUser
class User extends Authenticatable implements FilamentUser
3 replies
FFilament
Created by Askancy on 10/13/2023 in #❓┊help
Create select with pivot relationship
I need to insert a Select with single selta in my project. The main model of the project is "Game", The select takes data from the Franchise_pivot table in which it has: -franchise_id -gioco_id And where it parses franchise_id (to return the name) in Franchise which is structured: -id -name How can I implement this select? Currently I have done:
Select::make('Franchise')
->label('Franchise:')
->relationship('franchise')
->searchable(),
Select::make('Franchise')
->label('Franchise:')
->relationship('franchise')
->searchable(),
Model "Game"
public function franchise(): belongsTo
{
return $this->belongsTo(Franchise_pivot::class, 'id', 'gioco_id');
}
public function franchise(): belongsTo
{
return $this->belongsTo(Franchise_pivot::class, 'id', 'gioco_id');
}
But the result is that I have the game id in the select, and not the franchise name
23 replies
FFilament
Created by Askancy on 10/9/2023 in #❓┊help
How can I add a condition in a form?
I have this code in my form:
return $form
->schema([
Section::make()
->schema([
Repeater::make('trofei')
->createItemButtonLabel('Add Achiviements')
->relationship('trofei')
->schema([
TextInput::make('nome'),
TextInput::make('descrizione'),
Select::make('valore')
->label('Piattaforme:')
->options([
'1' => 'Bronzo',
'2' => 'Argento',
'3' => 'Oro',
'4' => 'Platino',
])

])
])
->columns(1)
]);
return $form
->schema([
Section::make()
->schema([
Repeater::make('trofei')
->createItemButtonLabel('Add Achiviements')
->relationship('trofei')
->schema([
TextInput::make('nome'),
TextInput::make('descrizione'),
Select::make('valore')
->label('Piattaforme:')
->options([
'1' => 'Bronzo',
'2' => 'Argento',
'3' => 'Oro',
'4' => 'Platino',
])

])
])
->columns(1)
]);
I would need to do something like this:
if ($record->console_id == '4') {
Select::make('valore')
->label('Piattaforme:')
->options([
'1' => 'Bronzo',
'2' => 'Argento',
'3' => 'Oro',
'4' => 'Platino',
])
} else {
TextInput::make('valore'),
}
if ($record->console_id == '4') {
Select::make('valore')
->label('Piattaforme:')
->options([
'1' => 'Bronzo',
'2' => 'Argento',
'3' => 'Oro',
'4' => 'Platino',
])
} else {
TextInput::make('valore'),
}
4 replies
FFilament
Created by Askancy on 10/8/2023 in #❓┊help
Using an eloquent query for the form
I am using to compose the table, the model "component_pivot", while for the form I would need to use the model component, how can I do that?
protected static ?string $model = Component_pivot::class;
protected static ?string $model = Component_pivot::class;
For the form I would need to use this eloquent query:
\App\Models\Component::with('component_pivot')->where('group_id', '1')->get()
\App\Models\Component::with('component_pivot')->where('group_id', '1')->get()
4 replies
FFilament
Created by Askancy on 10/8/2023 in #❓┊help
Something similar to datatable for filamentphp?
I would like to do like what Datatables allows, click on the element and edit... Is there something similar in filamentphp?
7 replies
FFilament
Created by Askancy on 10/5/2023 in #❓┊help
Using custom function in a form
I have a page where I have a form textarea, in the textarea I have all the ids divided by comma example: qIcTM8WXFjk,8X2kIfS6fb8 These ids are processed through a function of mine:
function processMultipleVideos($request)
{
$all_id = explode(',', $request->id_video);

foreach ($all_id as $value) {
$all_idcode = Youtube::getVideoInfo($value);
$all_id_de = json_encode($all_idcode);
$video = new Video();
$video->id_video = $all_idcode->id;
$video->name= $all_idcode->snippet->title;
$video->save();
}
}
function processMultipleVideos($request)
{
$all_id = explode(',', $request->id_video);

foreach ($all_id as $value) {
$all_idcode = Youtube::getVideoInfo($value);
$all_id_de = json_encode($all_idcode);
$video = new Video();
$video->id_video = $all_idcode->id;
$video->name= $all_idcode->snippet->title;
$video->save();
}
}
How can I tell Filamentphp to use this function to post data? Also, how do I add a button next to "New Video" in the header? In the documentation I find only references to how to add buttons in tables
9 replies
FFilament
Created by Askancy on 9/30/2023 in #❓┊help
Repeater::simple does not exist
I am using a repeater with the simple method, but I get this error:
Section::make('Pro Cons')
->schema([
Repeater::make('Pro')
->simple(
TextInput::make('pro'),
),

Repeater::make('Cons')
->simple(
TextInput::make('cons'),
)
])
->collapsible(),
Section::make('Pro Cons')
->schema([
Repeater::make('Pro')
->simple(
TextInput::make('pro'),
),

Repeater::make('Cons')
->simple(
TextInput::make('cons'),
)
])
->collapsible(),
>Method Filament\Forms\Components\Repeater::simple does not exist. I also take this opportunity to ask, I currently have data within a saved sql column, each element is separated by |:
Little choice in weapons|IA sometimes unresponsive
Little choice in weapons|IA sometimes unresponsive
How should I convert it to fit filamentphp? I need to create an example pivot column:
Schema::create('review_pivot_cons', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('review_id');
$table->unsignedBigInteger('cons');
$table->timestamps();

$table->foreign('review_id')->references('id')->on('review')->onDelete('cascade');
});
Schema::create('review_pivot_cons', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('review_id');
$table->unsignedBigInteger('cons');
$table->timestamps();

$table->foreign('review_id')->references('id')->on('review')->onDelete('cascade');
});
could it work? In the case, how do I "populate" the textinputs?
8 replies
FFilament
Created by Askancy on 9/23/2023 in #❓┊help
Get image from S3 without full path in sql column
I am adapting a pre-existing custom admin to filamentphp, now I have images on an S3 structured like this: cdn.blabla.ext/namesite/gallery/{{$game_id}}/{{$image}} With the old admin I used:
$filename = rand().'-gallery.'.$request->file('image')->extension();
Storage::disk('s3')->putFileAs('namesite/gallery/'.$game_id, $request->file('image'), $filename, 'public');
$article->image = $filename;
$filename = rand().'-gallery.'.$request->file('image')->extension();
Storage::disk('s3')->putFileAs('namesite/gallery/'.$game_id, $request->file('image'), $filename, 'public');
$article->image = $filename;
To visualize it I would simply use:
<img src="{{\Storage::disk('s3')->url('namesite/gallery/'.$game_id.'/'.$article->image)}}">
<img src="{{\Storage::disk('s3')->url('namesite/gallery/'.$game_id.'/'.$article->image)}}">
But how does it work with filament? In the documentation I read: >The column in the database must contain the path to the image, relative to the root directory of its storage disk. Currently in the database I saved ONLY the name of the image, if I understand correctly I in the database should save: image = namesite/gallery/123/nameimage.png can I bypass this?
5 replies
FFilament
Created by Askancy on 9/21/2023 in #❓┊help
Multiple Select with BelongsToMany relationship
I'm just recently using Filamentphp and need to get into the mindset of how it works. I have two sql tables: Article Article_pivot_games In article_pivot_games I have the columns: - id -article_id -games_id now I need a multiple select, where he fills in the select with the names of the games that have the article_id equal to the id of the article I am editing.
Select::make('id_game[]')
->label('Games:')
->relationship('games', 'name')
->multiple()
->searchable()
->required(),
Select::make('id_game[]')
->label('Games:')
->relationship('games', 'name')
->multiple()
->searchable()
->required(),
in the model Article.php
public function games(): BelongsToMany
{
return $this->belongsToMany(Games::class, 'article_pivot_games', 'games_id');
}
public function games(): BelongsToMany
{
return $this->belongsToMany(Games::class, 'article_pivot_games', 'games_id');
}
However, how do I tell the select to use that function? Also am I using the right method? Before filamentphp I used a custom admin of my own, in which I had a column in Article with the id_games column containing "1,6,123,532," and I used this:
$pickup_games = explode(',', $articles->id_gioco);
$game_list = [];
foreach ($pickup_games as $pickup_game) {
$game_list [] = Games::where('id', $pickup_game)->first();
}
$pickup_games = explode(',', $articles->id_gioco);
$game_list = [];
foreach ($pickup_games as $pickup_game) {
$game_list [] = Games::where('id', $pickup_game)->first();
}
9 replies
FFilament
Created by Askancy on 8/21/2023 in #❓┊help
Multiple select displays only one item
6 replies
FFilament
Created by Askancy on 8/21/2023 in #❓┊help
Set text on the badge according to the value
I have this badge that takes from id_topic the topic number on the forum where comments are open. If id_topic is 0 then comments are closed, if it contains an id above 0 then comments are open. I have tried this, but inside the badge it always returns me the id of id_topic and not the words "open" or "close"
TextColumn::make('id_topic')
->badge(fn ($state): string => $state > 0 ? 'Open' : 'Close')
->color(fn ($state): string => $state > 0 ? 'success' : 'gray')
->label('Comments'),
TextColumn::make('id_topic')
->badge(fn ($state): string => $state > 0 ? 'Open' : 'Close')
->color(fn ($state): string => $state > 0 ? 'success' : 'gray')
->label('Comments'),
10 replies