MRBUG
MRBUG
FFilament
Created by MRBUG on 10/20/2023 in #❓┊help
If Infolist Repeatable Entry has no data I want to show "No Data Found"
No description
2 replies
FFilament
Created by MRBUG on 10/19/2023 in #❓┊help
Download button for file's Inside Repeater.
how can we download the any type of file that is coming from s3. More details: Here is the model which i am using inside Repeater
MessageFile modal
protected $appends = [
'file_url',
];
public function getFileUrlAttribute()
{
if (config('filesystems.default') == 's3') {
return Storage::disk(config('filesystems.default'))->temporaryUrl('messages/' . $this->message_id . '/' . $this->hashname, now()->addMinutes(5));
} else {
return Storage::url('messages/' . $this->message_id . '/' . $this->hashname);
}
}
MessageFile modal
protected $appends = [
'file_url',
];
public function getFileUrlAttribute()
{
if (config('filesystems.default') == 's3') {
return Storage::disk(config('filesystems.default'))->temporaryUrl('messages/' . $this->message_id . '/' . $this->hashname, now()->addMinutes(5));
} else {
return Storage::url('messages/' . $this->message_id . '/' . $this->hashname);
}
}
i am using Action inside the MessageResource Like that
and i am getting the url but it it's saying file does'not exist and i this this approach is not good? ``` ->actions([ //other codes ->infolist([ RepeatableEntry::make('message.messageFiles') ->schema([ ImageEntry::make('fileurl')->height(80), TextEntry::make('size') ->suffixAction( Action::make('download') ->action(function (MessageFile $record, array $data) { if ($record->fileurl) { $dd = response()->download(storage_path($record->fileurl)); } else { Log::error('File not found: ' . $record->fileurl); Notification::make() ->title('File Not Found') ->danger() ->send();
11 replies
FFilament
Created by MRBUG on 10/17/2023 in #❓┊help
Tab as a new table ?
No description
2 replies
FFilament
Created by MRBUG on 10/17/2023 in #❓┊help
Relation on text area form?
No description
19 replies
FFilament
Created by MRBUG on 10/12/2023 in #❓┊help
name and avatar in one using prefix
i am using this code for that functionallity
Tables\Columns\ImageColumn::make('profile_photo')
->circular()->label('')->extraImgAttributes(['loading' => 'lazy'])->height(30)
->defaultImageUrl(fn (Model $record) => 'https://ui-avatars.com/api/?name=' . $record->name . '&color=ffffff&background=5a51ec')
->disk('s3')
->visibility('private'),
Tables\Columns\TextColumn::make('name')
->numeric()
->sortable()
->searchable()
->prefix(function (Model $record): HtmlString {
// Check if the profile_photo exists in S3
if ($record->profile_photo !== null && Storage::disk('s3')->exists($record->profile_photo)) {
$profilePhotoUrl = Storage::disk('s3')->url($record->profile_photo);
} else {
// If the profile_photo doesn't exist or is null, use a default image
$profilePhotoUrl = 'https://ui-avatars.com/api/?name=' . $record->name . '&color=ffffff&background=5a51ec';
}
// Create the image HTML tag
$imageTag = '<img src="' . $profilePhotoUrl . '" style="display: inline-block; border-radius: 9999px; width: 32px; height: 32px; margin-right: 0.5rem;"/>';

return new HtmlString($imageTag);
})
->html(),
Tables\Columns\ImageColumn::make('profile_photo')
->circular()->label('')->extraImgAttributes(['loading' => 'lazy'])->height(30)
->defaultImageUrl(fn (Model $record) => 'https://ui-avatars.com/api/?name=' . $record->name . '&color=ffffff&background=5a51ec')
->disk('s3')
->visibility('private'),
Tables\Columns\TextColumn::make('name')
->numeric()
->sortable()
->searchable()
->prefix(function (Model $record): HtmlString {
// Check if the profile_photo exists in S3
if ($record->profile_photo !== null && Storage::disk('s3')->exists($record->profile_photo)) {
$profilePhotoUrl = Storage::disk('s3')->url($record->profile_photo);
} else {
// If the profile_photo doesn't exist or is null, use a default image
$profilePhotoUrl = 'https://ui-avatars.com/api/?name=' . $record->name . '&color=ffffff&background=5a51ec';
}
// Create the image HTML tag
$imageTag = '<img src="' . $profilePhotoUrl . '" style="display: inline-block; border-radius: 9999px; width: 32px; height: 32px; margin-right: 0.5rem;"/>';

return new HtmlString($imageTag);
})
->html(),
it s my code i am doing this but why i am not able to get image s3 said me access denied why or any other method to get the user image and name at one place
4 replies
FFilament
Created by MRBUG on 10/11/2023 in #❓┊help
Get Name Of Table Column?
I think this is used to get data on the Table Column. From documentation
use Filament\Tables\Columns\TextColumn;

TextColumn::make('title')
->description(fn (Post $record): string => $record->description)
use Filament\Tables\Columns\TextColumn;

TextColumn::make('title')
->description(fn (Post $record): string => $record->description)
But i want little bit diffrent functionallity this is the code
Tables\Columns\ImageColumn::make('profile_photo')
->circular()->label('')->extraImgAttributes(['loading' => 'lazy'])->height(30)**->defaultImageUrl(url('https://ui-avatars.com/api/?name=' . 'full' . '&color=ffffff&background=5a51ec'))**,
Tables\Columns\TextColumn::make('name')
->numeric()
->sortable()->searchable(),
Tables\Columns\ImageColumn::make('profile_photo')
->circular()->label('')->extraImgAttributes(['loading' => 'lazy'])->height(30)**->defaultImageUrl(url('https://ui-avatars.com/api/?name=' . 'full' . '&color=ffffff&background=5a51ec'))**,
Tables\Columns\TextColumn::make('name')
->numeric()
->sortable()->searchable(),
Where i have name of user and Profile photo field so i want that if user has no profile photo he will get defaultImageUrl
->defaultImageUrl(url('https://ui-avatars.com/api/?name=' . ' USER NAME' . '&color=ffffff&background=5a51ec'))
->defaultImageUrl(url('https://ui-avatars.com/api/?name=' . ' USER NAME' . '&color=ffffff&background=5a51ec'))
and i want the name of user insted of USER NAME How can i get user name there thank you in advance ❤️.
11 replies
FFilament
Created by MRBUG on 10/10/2023 in #❓┊help
clickable widget with filter
No description
4 replies
FFilament
Created by MRBUG on 10/9/2023 in #❓┊help
clickable widget with filter
No description
1 replies
FFilament
Created by MRBUG on 10/9/2023 in #❓┊help
avatar from s3
How to get this avatar from s3?
This code is from the documentation.
https://filamentphp.com/docs/3.x/panels/users#setting-up-user-avatars
<?php

namespace App\Models;

use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasAvatar;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements FilamentUser, HasAvatar
{
// ...

public function getFilamentAvatarUrl(): ?string
{
return $this->avatar_url;
}
}
<?php

namespace App\Models;

use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasAvatar;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements FilamentUser, HasAvatar
{
// ...

public function getFilamentAvatarUrl(): ?string
{
return $this->avatar_url;
}
}
10 replies
FFilament
Created by MRBUG on 10/6/2023 in #❓┊help
Custom filter forms (From - Until Filter)
i am creating a filter for checking the data from the selected date to until selected date. And in documentation we have The custom filter It's cool. but I have another condition the date I want to filter is coming from another relation. OK my current resource name is Transaction. so I have a relation named payment and I am showing it's one field in transaction resource named payment_date so i can make a filter using documentation for transaction created_at column. like that
use Filament\Forms\Components\DatePicker;
use Filament\Tables\Filters\Filter;
use Illuminate\Database\Eloquent\Builder;

Filter::make('created_at')
->form([
DatePicker::make('created_from'),
DatePicker::make('created_until'),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['created_from'],
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '>=', $date),
)
->when(
$data['created_until'],
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '<=', $date),
);
})
use Filament\Forms\Components\DatePicker;
use Filament\Tables\Filters\Filter;
use Illuminate\Database\Eloquent\Builder;

Filter::make('created_at')
->form([
DatePicker::make('created_from'),
DatePicker::make('created_until'),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['created_from'],
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '>=', $date),
)
->when(
$data['created_until'],
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '<=', $date),
);
})
but i have a relation named payment and i want to filter its field payment_date in Transaction resource BTW i used this code
Filter::make('payment_date')
->form([
DatePicker::make('payment_date_from'),
DatePicker::make('payment_date_until'),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['payment_date_from'],
fn (Builder $query, $date): Builder => $query->whereDate('project.payment_date', '>=', $date),)
->when(
$data['payment_date_until'],
fn (Builder $query, $date): Builder => $query->whereDate('project.payment_date', '<=', $date),);
})
Filter::make('payment_date')
->form([
DatePicker::make('payment_date_from'),
DatePicker::make('payment_date_until'),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['payment_date_from'],
fn (Builder $query, $date): Builder => $query->whereDate('project.payment_date', '>=', $date),)
->when(
$data['payment_date_until'],
fn (Builder $query, $date): Builder => $query->whereDate('project.payment_date', '<=', $date),);
})
so how can i do that? THANKS IN ADVANCE.
9 replies
FFilament
Created by MRBUG on 10/6/2023 in #❓┊help
infolist
No description
4 replies
FFilament
Created by MRBUG on 10/5/2023 in #❓┊help
Infolist
No description
2 replies
FFilament
Created by MRBUG on 10/4/2023 in #❓┊help
clickable widget
No description
13 replies
FFilament
Created by MRBUG on 9/27/2023 in #❓┊help
how can we get data into select form, from 2 relations.
i have a select form, where i want to show names of users of the current project members and the client can Comment/message or talk with each other. so i want a data to select form where i want to show the current project members and client names currently i am using this where i am able to get project members names but not client name how can i get both data into one Select form. here i my current code
Forms\Components\Select::make('user_id') ->options(ProjectMember::where('project_id', '=', $this->ownerRecord->id)->pluck('freelancer_id', 'freelancer_id'))->searchable()->required() ->required()->columnSpanFull(),
here freelancer is user/projectMember so how can i get client name there and as well as i want to show freelancer.user.name not freelancer_id. thank you in advance.
11 replies
FFilament
Created by MRBUG on 9/26/2023 in #❓┊help
Looping names of members in a table.
in given image there is the users names are looping because of the relation but i want to do not loop it i want to put this one by one names how can we overide the relations looping functionallity. here is the codes this is the table code from where i am getting the data like given in image. ProjectMemberResource column data
ImageColumn::make('project.members.user.profile_photo_path') ->circular() ->grow(false) ->label(''), TextColumn::make('project.members.user.name') ->weight(FontWeight::Bold) ->searchable() ->label('User')->url(static fn (Model $record): string => FreelancerResource::getUrl('edit', ['record' => $record->freelancer_id])),
and here is the relation of projectMember model
class ProjectMember extends Model { use HasFactory; protected $guarded = ['id']; protected $touches = ['project']; public $timestamps = false; public function project(): BelongsTo { return $this->belongsTo(Project::class); } }
and here is the Project model where i have a relation members
public function members(): BelongsToMany { return $this->belongsToMany(Freelancer::class, 'project_members'); }
because of that above relation it is looping how can i solve by using filamentphp. thank you in fi 💌
1 replies
FFilament
Created by MRBUG on 9/22/2023 in #❓┊help
change color of money based on another column value
No description
4 replies
FFilament
Created by MRBUG on 9/13/2023 in #❓┊help
how can we change the table from user to admin for login page or login credential
any idea about this to change the login credentioal will get or create the admin users to go to the admin panel ??
5 replies
FFilament
Created by MRBUG on 9/7/2023 in #❓┊help
if user is admin
No description
6 replies
FFilament
Created by MRBUG on 9/6/2023 in #❓┊help
is_admin
No description
12 replies
FFilament
Created by MRBUG on 9/5/2023 in #❓┊help
how can i create a user clickable and send to the edit page of the user
hii I have a table Posts in filamentphp and in this table, i have a column where I am showing the user name who created a post so I want the user name clickable and when I click to the name of the user it will send/redirect me to the users edit page how can I get this functionality in filamentPHP version 3 . please help
4 replies