brownbear1773
brownbear1773
FFilament
Created by brownbear1773 on 11/1/2024 in #❓┊help
Advanced Table Plugin global views
Using Filament plugin Advanced Tables. I have a user that is registered to two teams. I create a view called SimpleView on one of the teams making it global and public. I approve that view but it does not show on the user's other team. Why and how should I resolve?
4 replies
FFilament
Created by brownbear1773 on 10/17/2024 in #❓┊help
Fileupload does not trigger camera on mobile CHROME
FileUpload::make('image_path')
->label('Image')
->image()
->directory('uploads/images')
->maxSize(2048)
->imagePreviewHeight('150px')
->imageEditor()
->extraAttributes([
'accept' => 'image/*',
'capture' => 'environment',
'style' => 'cursor: pointer;',
'onclick' => <<<JS
(function() {
const imageUrl = this.closest('div').querySelector('input[type=hidden]').value;
const modal = document.createElement('div');
modal.style.position = 'fixed';
modal.style.top = '0';
modal.style.left = '0';
modal.style.width = '100%';
modal.style.height = '100%';
modal.style.backgroundColor = 'rgba(0, 0, 0, 0.9)';
modal.style.zIndex = '1000';
modal.style.display = 'flex';
modal.style.justifyContent = 'center';
modal.style.alignItems = 'center';
const img = document.createElement('img');
img.src = imageUrl;
img.style.maxWidth = '90%';
img.style.maxHeight = '90%';
modal.onclick = () => {
modal.remove();
};
modal.appendChild(img);
document.body.appendChild(modal);
}).call(this); JS
]),
FileUpload::make('image_path')
->label('Image')
->image()
->directory('uploads/images')
->maxSize(2048)
->imagePreviewHeight('150px')
->imageEditor()
->extraAttributes([
'accept' => 'image/*',
'capture' => 'environment',
'style' => 'cursor: pointer;',
'onclick' => <<<JS
(function() {
const imageUrl = this.closest('div').querySelector('input[type=hidden]').value;
const modal = document.createElement('div');
modal.style.position = 'fixed';
modal.style.top = '0';
modal.style.left = '0';
modal.style.width = '100%';
modal.style.height = '100%';
modal.style.backgroundColor = 'rgba(0, 0, 0, 0.9)';
modal.style.zIndex = '1000';
modal.style.display = 'flex';
modal.style.justifyContent = 'center';
modal.style.alignItems = 'center';
const img = document.createElement('img');
img.src = imageUrl;
img.style.maxWidth = '90%';
img.style.maxHeight = '90%';
modal.onclick = () => {
modal.remove();
};
modal.appendChild(img);
document.body.appendChild(modal);
}).call(this); JS
]),
I have this code and have tried it on several mobile browsers. All seem to trigger the camera/gallery choice for the source except chrome. In chrome seems I can only select media from gallery. What am I missing?
2 replies
FFilament
Created by brownbear1773 on 9/30/2024 in #❓┊help
Calling livewire component from xdata
I am writing a ResizeableTextColumn component for use in Filament Resource table This is a sample of usage
return $table
->columns([
ResizeableTextColumn::make('name')
->searchable()
->sortable(),
return $table
->columns([
ResizeableTextColumn::make('name')
->searchable()
->sortable(),
This is an example of my code and I need to emit back to the server to persist the user defined width (attached) and the livewire listener
<?php

namespace App\Livewire;

use Livewire\Component;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Session;
class TableColumnResizer extends Component
{
public $tableName;

protected $listeners = ['updateColumnWidth']; // Listen for the emitted event

public function mount($tableName)
{
$this->tableName = "column_widths";
}

public function updateColumnWidth(string $columnName, int $width)
{
// Debugging point: Check if the method is called
dd("Column updated:", $columnName, $width);

$userId = Auth::id();

// Store in session
$sessionKey = "user.{$userId}.table.{$this->tableName}.column_widths.{$columnName}";
Session::put($sessionKey, $width);

// Update the database
DB::table('column_widths')->updateOrInsert(
[
'user_id' => $userId,
'table_name' => $this->tableName,
'column_name' => $columnName,
],
['width' => $width]
);
}

public function render()
{
return view('livewire.table-column-resizer');
}
}
<?php

namespace App\Livewire;

use Livewire\Component;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Session;
class TableColumnResizer extends Component
{
public $tableName;

protected $listeners = ['updateColumnWidth']; // Listen for the emitted event

public function mount($tableName)
{
$this->tableName = "column_widths";
}

public function updateColumnWidth(string $columnName, int $width)
{
// Debugging point: Check if the method is called
dd("Column updated:", $columnName, $width);

$userId = Auth::id();

// Store in session
$sessionKey = "user.{$userId}.table.{$this->tableName}.column_widths.{$columnName}";
Session::put($sessionKey, $width);

// Update the database
DB::table('column_widths')->updateOrInsert(
[
'user_id' => $userId,
'table_name' => $this->tableName,
'column_name' => $columnName,
],
['width' => $width]
);
}

public function render()
{
return view('livewire.table-column-resizer');
}
}
I see that window.livewire is undefined so the emit never works. The objective is send the resizing info back to the listener to persist it. I am new at Laravel and filament but understand the concepts (developer for 40+ years)
1 replies
FFilament
Created by brownbear1773 on 4/21/2024 in #❓┊help
slideOver not working for me
I am a veteran developer but newbie with Laravel/filament. Working thru Dary's video on duplicating the filament demo. I have a snippet below that you can see in the cations I have added a ->slideOut on the Edit. Thing is it does not work and I have no idea why, Thoughts? ``` public static function form(Form $form): Form { return $form ->schema([ Forms\Components\Group::make() ->schema([ Section::make() ->schema([ TextInput::make('name') ->required()
->unique()
}),
]), ]),
]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('name')->searchable()->sortable(), TextColumn::make('parent_name')->label('Parent')->searchable()->sortable(), IconColumn::make('is_visible')->label('Visibility')->searchable()->sortable(), TextColumn::make('updated_at')->label('Updated at')->date()->sortable(), ]) ->filters([ // ]) ->actions([ //Tables\Actions\ActionGroup::make([ //Tables\Actions\ViewAction::make(), Tables\Actions\EditAction::make()->slideOver(), //Tables\Actions\DeleteAction::make(), //]) ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), ]); }
4 replies