Renzo
Renzo
FFilament
Created by Renzo on 5/8/2024 in #❓┊help
Issue with ->multiple() method for select after v3.2.74 update
No description
7 replies
FFilament
Created by Renzo on 5/1/2024 in #❓┊help
Typing Test on a Resource
I'm thinking of adding a typing test on my resource, any tips on where to start? Any open source TT apps that I can use?
2 replies
FFilament
Created by Renzo on 4/24/2024 in #❓┊help
FileUpload field inside an Infolist
I have this UploadField on the form where users could upload files. Was wondering if I could show that file inside an infolist?
11 replies
FFilament
Created by Renzo on 4/24/2024 in #❓┊help
Getting rid of create button
Hi, I currently have 2 resource, MyApplicationResource & ReferralResource. I generated the ReferralResource but it uses the data from MyApplicationResource. Is there a way to get rid of the Create Referral button on my ReferralResource?
class ReferralResource extends Resource
{
protected static ?string $model = MyApplication::class;
class ReferralResource extends Resource
{
protected static ?string $model = MyApplication::class;
6 replies
FFilament
Created by Renzo on 2/13/2024 in #❓┊help
Rendering custom livewire page on a modal view
No description
2 replies
FFilament
Created by Renzo on 1/3/2024 in #❓┊help
Hiding a section based on Select field value
I have created a function where the 2nd section is hidden unless the Role selected from the 1st section is 'Vendor' which has an ID of '2'. It works fine, but when I edit a users with an existing 'Vendor' role. the 2nd section doesn't show up. I'd have to select a different role and select Vendor again for it to show up.
Group::make()
->schema([
Section::make()
->schema([
TextInput::make('name')->label('Full Name'),
TextInput::make('email')->label('Email'),
TextInput::make('password')->label('Password')
->password()
->dehydrateStateUsing(fn (string $state): string => Hash::make($state))
->dehydrated(fn (?string $state): bool => filled($state)),
Select::make('roles')
->native(false)
->relationship('roles', 'name')
->live()
->searchDebounce(500)
]),
Section::make()
->schema([
TextInput::make('user_rate')->label('Rate')
->numeric(),
TextInput::make('user_distance_rate')->label('Rate Per Distance')
->numeric(),
Toggle::make('user_preferred')->label('Preferred'),
])
->visible(fn (Get $get): bool => $get('roles') == 2)
]),
Group::make()
->schema([
Section::make()
->schema([
TextInput::make('name')->label('Full Name'),
TextInput::make('email')->label('Email'),
TextInput::make('password')->label('Password')
->password()
->dehydrateStateUsing(fn (string $state): string => Hash::make($state))
->dehydrated(fn (?string $state): bool => filled($state)),
Select::make('roles')
->native(false)
->relationship('roles', 'name')
->live()
->searchDebounce(500)
]),
Section::make()
->schema([
TextInput::make('user_rate')->label('Rate')
->numeric(),
TextInput::make('user_distance_rate')->label('Rate Per Distance')
->numeric(),
Toggle::make('user_preferred')->label('Preferred'),
])
->visible(fn (Get $get): bool => $get('roles') == 2)
]),
3 replies
FFilament
Created by Renzo on 10/10/2023 in #❓┊help
Twilio Integration
Hey guys, I've been trying add SMS notification everytime a new user is created. I've already added user_contact on my user schema also added values on E.164 format. I've also defined my twilio variables on .ENV file. TWILIO_ACCOUNT_SID=AC8c4bb20a1d51ae1a9a7134b1fb99eab2 TWILIO_AUTH_TOKEN=67ae0e279a32c1a4210a793368f35cb2 TWILIO_PHONE_NUMBER=+19389999868 For some reason, I'm not receiving any SMS, but I'm able to create data. Here's my Create code:
<?php

namespace App\Filament\Resources\UserResource\Pages;

use App\Filament\Resources\UserResource;
use App\Models\User;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
use Twilio\Rest\Client;

class CreateUser extends CreateRecord
{
protected static string $resource = UserResource::class;

protected function save(): void
{
parent::save(); // Save the user first

// Notify other users via SMS about the new user
$this->sendSmsNotification();
}

protected function sendSmsNotification(): void
{
$sid = config('services.twilio.sid');
$token = config('services.twilio.token');
$twilioPhoneNumber = config('services.twilio.phone_number');

$twilio = new Client($sid, $token);

// Here, I'm assuming you want to notify all other users. Adjust this as necessary.
$usersToNotify = User::whereNotNull('user_contact')->get();

foreach ($usersToNotify as $user) {
$twilio->messages->create(
$user->user_contact, // User's contact number in E.164 format
[
"body" => "A new work order has been created.",
"from" => $twilioPhoneNumber
]
);
}
}

protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('index');
}
}
<?php

namespace App\Filament\Resources\UserResource\Pages;

use App\Filament\Resources\UserResource;
use App\Models\User;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
use Twilio\Rest\Client;

class CreateUser extends CreateRecord
{
protected static string $resource = UserResource::class;

protected function save(): void
{
parent::save(); // Save the user first

// Notify other users via SMS about the new user
$this->sendSmsNotification();
}

protected function sendSmsNotification(): void
{
$sid = config('services.twilio.sid');
$token = config('services.twilio.token');
$twilioPhoneNumber = config('services.twilio.phone_number');

$twilio = new Client($sid, $token);

// Here, I'm assuming you want to notify all other users. Adjust this as necessary.
$usersToNotify = User::whereNotNull('user_contact')->get();

foreach ($usersToNotify as $user) {
$twilio->messages->create(
$user->user_contact, // User's contact number in E.164 format
[
"body" => "A new work order has been created.",
"from" => $twilioPhoneNumber
]
);
}
}

protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('index');
}
}
7 replies
FFilament
Created by Renzo on 9/25/2023 in #❓┊help
Notifications Issue
Anyone else experiencing notification issues (not displaying) after the update?
13 replies
FFilament
Created by Renzo on 9/1/2023 in #❓┊help
Table Data Visibility
I created a dispatch system in Laravel Filament where users can assign Workorders to Vendors. I get all my Vendors from my User model which has a 'role' of 'Vendor'. I've also set up a relationship between my User and Workorder model. Currently, all Workorders can be seen by the Vendors even if that WO is not assigned to them. I want to add a function where 'Vendors' can only see the Workorder that was assigned to them. Here's what I did which is throwing me an error of: Cannot use "::class" on value of type null public static function table(Table $table): Table { return $table ->query(function (Builder $query) { // Base query that fetches all work orders $baseQuery = $query->select('*')->from('workorders');
// If user is a Vendor, modify the base query to only include their work orders if (Auth::user()->hasRole('Vendor')) { return $baseQuery->where('user_id', Auth::id()); }
// Otherwise, return the base query return $baseQuery; })
4 replies
FFilament
Created by Renzo on 8/31/2023 in #❓┊help
Hide a Toggle field depending on Select option
For some reason, I can't make it work. Here's what I did: Select::make('roles') ->relationship('roles', 'name') ->live(), Toggle::make('is_admin') ->hidden(fn ($record) => !$record->roles->pluck('name')->contains('Vendor'))
41 replies
FFilament
Created by Renzo on 8/31/2023 in #❓┊help
Pass 'Select' field values to other fields.
I have a dropdown which displays all my customer addresses. Now I also have a field on my form called RadiusFilter which is basically an address text box. What i want to happend is for the RadiusFilter to be dependent on the SelectFilter (Which contains all the addresses of the customers). So let's say, I picked address '1' on the Select Filter, address '1' would automatically be inputted on the RadiusFilter textbox. SelectFilter::make('Customer') ->relationship('customer','cus_address'), RadiusFilter::make('radius') ->attribute('Customer'), MapIsFilter::make('map'), Sorry guys, been trying to find answers on the docs but I can't find anything.
8 replies