vahnmarty
vahnmarty
FFilament
Created by vahnmarty on 9/5/2024 in #❓┊help
Filter with value having dash '-' is not properly working
Thanks, this one worked.
Tables\Filters\SelectFilter::make('academic_year_applying_for__c')
->label('Academic Year')
->options(function(){
$array = ['2024 - 2025', '2025 - 2026'];
$options = [];

foreach($array as $years){
$encoded_string = htmlentities($years, ENT_QUOTES, 'UTF-8');
$options[$encoded_string] = $encoded_string;
}

return $options;

})
Tables\Filters\SelectFilter::make('academic_year_applying_for__c')
->label('Academic Year')
->options(function(){
$array = ['2024 - 2025', '2025 - 2026'];
$options = [];

foreach($array as $years){
$encoded_string = htmlentities($years, ENT_QUOTES, 'UTF-8');
$options[$encoded_string] = $encoded_string;
}

return $options;

})
4 replies
FFilament
Created by vahnmarty on 8/13/2024 in #❓┊help
How to reuse a Form Field?
Well this one works:
<?php

namespace App\Forms\Components;

use App\Rules\PhoneNumberRule;
use Filament\Forms\Components\Field;
use Filament\Forms\Components\TextInput;

class PhoneInput
{
public static function make($variable)
{
return TextInput::make($variable)
->minLength(10)
->maxLength(14)
->mask('(999) 999-9999')
->stripCharacters(['(', ')', ' ', '-'])
->numeric()
->rules([ new PhoneNumberRule, 'doesnt_start_with:1'])
->validationMessages([
'doesnt_start_with' => 'Phone Number cannot begin with 1.',
]);
}
}
<?php

namespace App\Forms\Components;

use App\Rules\PhoneNumberRule;
use Filament\Forms\Components\Field;
use Filament\Forms\Components\TextInput;

class PhoneInput
{
public static function make($variable)
{
return TextInput::make($variable)
->minLength(10)
->maxLength(14)
->mask('(999) 999-9999')
->stripCharacters(['(', ')', ' ', '-'])
->numeric()
->rules([ new PhoneNumberRule, 'doesnt_start_with:1'])
->validationMessages([
'doesnt_start_with' => 'Phone Number cannot begin with 1.',
]);
}
}
Just wondering if this is the correct way?
4 replies
FFilament
Created by vahnmarty on 8/1/2024 in #❓┊help
How to access Model $record when using ->visible() or ->hidden()?
Yea you are right.
12 replies
FFilament
Created by vahnmarty on 8/1/2024 in #❓┊help
How to access Model $record when using ->visible() or ->hidden()?
hmmm, I think I'm implementing the wrong way. the hidden/visible function of TextColumn is to hide everything from that column.
12 replies
FFilament
Created by vahnmarty on 8/1/2024 in #❓┊help
How to access Model $record when using ->visible() or ->hidden()?
I'm getting Call to a member function verified() on null
12 replies
FFilament
Created by vahnmarty on 7/31/2024 in #❓┊help
How to apply <novalidate> to Action Modals
yes, I tried the js way:
// Select all forms on the page
const forms = document.querySelectorAll('form');

// Iterate over each form and add the novalidate attribute
forms.forEach(form => {
form.setAttribute('novalidate', true);
});
// Select all forms on the page
const forms = document.querySelectorAll('form');

// Iterate over each form and add the novalidate attribute
forms.forEach(form => {
form.setAttribute('novalidate', true);
});
but everytime i click the action button, the attributes gone.
7 replies
FFilament
Created by vahnmarty on 5/7/2024 in #❓┊help
Is there an easy way to transform all labels to a different format instead of ucfirst (default) ?
that is what I have mentioned.
5 replies
FFilament
Created by vahnmarty on 3/21/2024 in #❓┊help
Unable to upload images more than 2MB.
Ah, it was a php.ini issue. Since I'm using Herd, all I did was edit the config file and restart services.
upload_max_filesize=5M
post_max_size=5M
upload_max_filesize=5M
post_max_size=5M
3 replies
FFilament
Created by vahnmarty on 3/21/2024 in #❓┊help
sortable() in second-level relationship
I fixed this by updating my ListRecord Resource, ListApplicationStatuses.php
protected function getTableQuery(): Builder
{
return ApplicationStatus::join('applications', 'application_status.application_id', 'applications.id');
}
protected function getTableQuery(): Builder
{
return ApplicationStatus::join('applications', 'application_status.application_id', 'applications.id');
}
3 replies
FFilament
Created by vahnmarty on 2/26/2024 in #❓┊help
Apply changes to field's sibling from Repeater
I think this one is working
->afterStateUpdated(function(Closure $get, Closure $set, $state){

if($state == 1)
{
$parentsRepeater = $get('../../parents');

foreach($parentsRepeater as $repeaterItemUuid => $parentItem){
if($get('id') != $parentItem['id'])
{
# Backend
$parentModel = ParentModel::find($parentItem['id']);
$parentModel->is_primary_contact = false;
$parentModel->save();

# Frontend
$set('../../parents.'. $repeaterItemUuid.'.is_primary_contact', 0);
}

}
}

$this->autoSaveParent($get('id'),'is_primary_contact', $state);
}),
->afterStateUpdated(function(Closure $get, Closure $set, $state){

if($state == 1)
{
$parentsRepeater = $get('../../parents');

foreach($parentsRepeater as $repeaterItemUuid => $parentItem){
if($get('id') != $parentItem['id'])
{
# Backend
$parentModel = ParentModel::find($parentItem['id']);
$parentModel->is_primary_contact = false;
$parentModel->save();

# Frontend
$set('../../parents.'. $repeaterItemUuid.'.is_primary_contact', 0);
}

}
}

$this->autoSaveParent($get('id'),'is_primary_contact', $state);
}),
3 replies
FFilament
Created by vahnmarty on 7/15/2023 in #❓┊help
How to modify ToggleColumn function?
ToggleColumn::make('is_primary')
->label('Primary Owner')
->updateStateUsing(function (Account $record, $state): void {
$record->is_primary = $state;
$record->save();

$parents = Account::where('account_id', $record->account_id )
->where('id', '!=', $record->id)
->update([
'is_primary' => !$state
]);
})
ToggleColumn::make('is_primary')
->label('Primary Owner')
->updateStateUsing(function (Account $record, $state): void {
$record->is_primary = $state;
$record->save();

$parents = Account::where('account_id', $record->account_id )
->where('id', '!=', $record->id)
->update([
'is_primary' => !$state
]);
})
7 replies
FFilament
Created by vahnmarty on 9/19/2023 in #❓┊help
How to easily change the placeholder text on Search?
No description
10 replies
FFilament
Created by vahnmarty on 9/19/2023 in #❓┊help
How to easily change the placeholder text on Search?
This is was my solution: I created filament.css and filament.js and added it to my AppServiceProvider. AppServiceProvider.php
Filament::registerScripts([
asset('js/filament.js'),
]);

Filament::registerViteTheme('resources/css/filament.css');
Filament::registerScripts([
asset('js/filament.js'),
]);

Filament::registerViteTheme('resources/css/filament.css');
filament.css
@import '../../vendor/filament/filament/resources/css/app.css';

.filament-tables-search-input input{
@apply max-w-full;
width: 420px;
}
@import '../../vendor/filament/filament/resources/css/app.css';

.filament-tables-search-input input{
@apply max-w-full;
width: 420px;
}
filament.js
document.addEventListener('DOMContentLoaded', function () {
if(isUri('admin/applications')){
return changeSearchPlaceholder('First Name, Last Name, Email or Phone');
}

if(isUri('admin/children')){
return changeSearchPlaceholder('First Name, Last Name, School, Email or Phone');
}

if(isUri('admin/users')){
return changeSearchPlaceholder('First Name, Last Name or Email');
}
});


function isUri($uri)
{
var currentURL = window.location.href;

// Define the URI you want to check
var targetURI = $uri;

// Check if the current URL contains the target URI
return currentURL.indexOf(targetURI) !== -1;

}

function changeSearchPlaceholder($placeholder)
{
var searchInput = document.querySelector('.filament-tables-search-input');

// Check if the element exists
if (searchInput) {
// Find the <input> element within the searchInput element
var inputElement = searchInput.querySelector('input');

// Check if the <input> element exists
if (inputElement) {
// Change the placeholder attribute of the <input> element
inputElement.placeholder = $placeholder;
}
}
}
document.addEventListener('DOMContentLoaded', function () {
if(isUri('admin/applications')){
return changeSearchPlaceholder('First Name, Last Name, Email or Phone');
}

if(isUri('admin/children')){
return changeSearchPlaceholder('First Name, Last Name, School, Email or Phone');
}

if(isUri('admin/users')){
return changeSearchPlaceholder('First Name, Last Name or Email');
}
});


function isUri($uri)
{
var currentURL = window.location.href;

// Define the URI you want to check
var targetURI = $uri;

// Check if the current URL contains the target URI
return currentURL.indexOf(targetURI) !== -1;

}

function changeSearchPlaceholder($placeholder)
{
var searchInput = document.querySelector('.filament-tables-search-input');

// Check if the element exists
if (searchInput) {
// Find the <input> element within the searchInput element
var inputElement = searchInput.querySelector('input');

// Check if the <input> element exists
if (inputElement) {
// Change the placeholder attribute of the <input> element
inputElement.placeholder = $placeholder;
}
}
}
10 replies
FFilament
Created by vahnmarty on 9/19/2023 in #❓┊help
How to easily change the placeholder text on Search?
Ohh..
10 replies
FFilament
Created by vahnmarty on 9/3/2023 in #❓┊help
Prevent Logout when changing Admin Password
Up
5 replies
FFilament
Created by vahnmarty on 8/30/2023 in #❓┊help
Filament v3 - Vite Issue
20 replies
FFilament
Created by vahnmarty on 8/30/2023 in #❓┊help
Filament v3 - Vite Issue
Oh I got it now. It says Create a new tailwind.config.js file and add the Filament preset (includes the Filament color scheme and the required Tailwind plugins): emphasis on ADD. I thought I'm going to replace everything lol.
20 replies
FFilament
Created by vahnmarty on 8/30/2023 in #❓┊help
Filament v3 - Vite Issue
Yes, I checked that. "Existing Laravel Project"
20 replies
FFilament
Created by vahnmarty on 8/30/2023 in #❓┊help
Filament v3 - Vite Issue
It's actually a laravel 9, just upgraded laravel 10. And installed Filament v3.
20 replies
FFilament
Created by vahnmarty on 8/30/2023 in #❓┊help
Filament v3 - Vite Issue
maybe it's a PostCSS v8 issue?
20 replies