Kaan
Kaan
FFilament
Created by Kaan on 4/29/2024 in #❓┊help
Call to undefined method App\Models\Category::category_image()
Hi. I'm using this package for the media library: https://filamentphp.com/plugins/awcodes-curator In my CategoryResource, i'm trying to insert a form data with image. Here's my CategoryResource > Form Method:
public static function form(Form $form): Form
{
return $form
->schema([
Wizard::make([
Wizard\Step::make('Language')
->description('Select the language for this category')
->schema([
Forms\Components\Select::make('language_id')
->label('Language')
->options(Language::all()->where('is_active', true)->pluck('name', 'id'))
->required(),
]),
Wizard\Step::make('About Category')
->description('Enter the details of the category')
->schema([
Forms\Components\Select::make('parent_id')
->label('Parent Category')
->helperText('If there is no parent category, leave this field empty')
->options(function (callable $get) {
$language = Language::find($get('language_id'));
if (!$language) {
return Category::where('id', null)->pluck('name', 'id');
}
return Category::where('language_id', $language->id)->pluck('name', 'id');
})
->searchable()
->placeholder('Select parent category')
->default(null),
CuratorPicker::make('category_image_id')
->relationship('category_image', 'id'),
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\Textarea::make('description')
->maxLength(65535),
Forms\Components\Toggle::make('is_active')
->required()
->default(true),
]),
]),
])->columns(1);
}
public static function form(Form $form): Form
{
return $form
->schema([
Wizard::make([
Wizard\Step::make('Language')
->description('Select the language for this category')
->schema([
Forms\Components\Select::make('language_id')
->label('Language')
->options(Language::all()->where('is_active', true)->pluck('name', 'id'))
->required(),
]),
Wizard\Step::make('About Category')
->description('Enter the details of the category')
->schema([
Forms\Components\Select::make('parent_id')
->label('Parent Category')
->helperText('If there is no parent category, leave this field empty')
->options(function (callable $get) {
$language = Language::find($get('language_id'));
if (!$language) {
return Category::where('id', null)->pluck('name', 'id');
}
return Category::where('language_id', $language->id)->pluck('name', 'id');
})
->searchable()
->placeholder('Select parent category')
->default(null),
CuratorPicker::make('category_image_id')
->relationship('category_image', 'id'),
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\Textarea::make('description')
->maxLength(65535),
Forms\Components\Toggle::make('is_active')
->required()
->default(true),
]),
]),
])->columns(1);
}
And here's my Category Model:
class Category extends Model
{
use HasFactory, Sluggable;

protected $fillable = [
'language_id',
'name',
'slug',
'description',
'parent_id',
'order',
'is_active',
'category_image_id',
];

public function sluggable(): array
{
return [
'slug' => [
'source' => 'name'
]
];
}


public function language(): BelongsTo
{
return $this->belongsTo(Language::class);
}

public function parent(): BelongsTo
{
return $this->belongsTo(Category::class, 'parent_id');
}

public function children(): HasMany
{
return $this->hasMany(Category::class, 'parent_id');
}

public function products(): HasMany
{
return $this->hasMany(Product::class);
}

public function scopeActive($query)
{
return $query->where('is_active', true);
}

public function scopeOrdered($query)
{
return $query->orderBy('order', 'asc');
}

public function categoryImage(): BelongsTo
{
return $this->belongsTo(Media::class, 'category_image_id', 'id');
}
}
class Category extends Model
{
use HasFactory, Sluggable;

protected $fillable = [
'language_id',
'name',
'slug',
'description',
'parent_id',
'order',
'is_active',
'category_image_id',
];

public function sluggable(): array
{
return [
'slug' => [
'source' => 'name'
]
];
}


public function language(): BelongsTo
{
return $this->belongsTo(Language::class);
}

public function parent(): BelongsTo
{
return $this->belongsTo(Category::class, 'parent_id');
}

public function children(): HasMany
{
return $this->hasMany(Category::class, 'parent_id');
}

public function products(): HasMany
{
return $this->hasMany(Product::class);
}

public function scopeActive($query)
{
return $query->where('is_active', true);
}

public function scopeOrdered($query)
{
return $query->orderBy('order', 'asc');
}

public function categoryImage(): BelongsTo
{
return $this->belongsTo(Media::class, 'category_image_id', 'id');
}
}
When i try to insert data in my CategoryResource i'm getting this error:
Call to undefined method App\Models\Category::category_image()
Call to undefined method App\Models\Category::category_image()
How can i solve the problem?
4 replies
FFilament
Created by Kaan on 4/28/2024 in #❓┊help
Awcodes | Curator Image Upload Error
Hello. Whenever I try to upload and save an image on the create page, I get the following error:
SQLSTATE[HY000]: General error: 1 table media has no column named alt
INSERT INTO
"media" (
"alt",
"title",
"caption",
"description",
"disk",
"directory",
"visibility",
"name",
"path",
"exif",
"width",
"height",
"size",
"type",
"ext",
"updated_at",
"created_at"
)
VALUES
(
?,
ScreenShot,
?,
?,
public,
media,
public,
efb27e74 - b093 -4285 - 88c2 - 1876e2a2086a,
media / efb27e74 - b093 -4285 - 88c2 - 1876e2a2086a.jpg,
{ "FileName": ":-",
"FileDateTime": 1714334960,
"FileSize": 73685,
"FileType": 2,
"MimeType": "image\/jpeg",
"SectionsFound": "IFD0",
"COMPUTED": { "html": "width=\"813\" height=\"958\"",
"Height": 958,
"Width": 813,
"IsColor": 1,
"ByteOrderMotorola": 1 } },
813,
958,
73685,
image / jpeg,
jpg,
2024 -04 -28 20: 09: 22,
2024 -04 -28 20: 09: 22
)
SQLSTATE[HY000]: General error: 1 table media has no column named alt
INSERT INTO
"media" (
"alt",
"title",
"caption",
"description",
"disk",
"directory",
"visibility",
"name",
"path",
"exif",
"width",
"height",
"size",
"type",
"ext",
"updated_at",
"created_at"
)
VALUES
(
?,
ScreenShot,
?,
?,
public,
media,
public,
efb27e74 - b093 -4285 - 88c2 - 1876e2a2086a,
media / efb27e74 - b093 -4285 - 88c2 - 1876e2a2086a.jpg,
{ "FileName": ":-",
"FileDateTime": 1714334960,
"FileSize": 73685,
"FileType": 2,
"MimeType": "image\/jpeg",
"SectionsFound": "IFD0",
"COMPUTED": { "html": "width=\"813\" height=\"958\"",
"Height": 958,
"Width": 813,
"IsColor": 1,
"ByteOrderMotorola": 1 } },
813,
958,
73685,
image / jpeg,
jpg,
2024 -04 -28 20: 09: 22,
2024 -04 -28 20: 09: 22
)
15 replies
FFilament
Created by Kaan on 11/7/2023 in #❓┊help
Add Custom Button to Repeater
No description
1 replies
FFilament
Created by Kaan on 10/27/2023 in #❓┊help
Preventing Automatic Record Creation in Associated Table with BelongsToMany Relationship
Hello, I am working with a BelongsToMany relationship and using Filament's Relation Managers. When I select multiple options and submit the form, records are automatically added to the pivot table, which is the desired behavior. However, I do not want these records to be created in the other table that's associated via the relationship. Is there a way to prevent this automatic record creation in the associated table while still allowing the data to be stored in the pivot table? Thank you for your assistance!
1 replies
FFilament
Created by Kaan on 10/21/2023 in #❓┊help
Catch data from fill
Hello. I am trying to trigger the fill state by triggering the visible property and capturing the type of the current data while filling the data in Filament, but I could not succeed. Here is my code: All Code: https://gist.github.com/kaanxweb/b7aace76adec07d1dbd7c1d052af6676 Form Method:
public function form(Form $form): Form
{
return $form
->schema([
Repeater::make('categorySteps')
->label($this->categoryApplicationName . ' Adımı')
->schema([
TextInput::make('step_title')
->label('Adım Başlığı')
->disabled()
->required(),

FileUpload::make('file_name')
->label('Dosya Yükleyin')
->disk('public')
->directory('category-application-steps')
->acceptedFileTypes(['application/pdf'])
->visible(fn(mixed $value): bool => dd($value))
->required(),

TextInput::make('file_description')
->label('Dosya Açıklaması')
->required(),

Checkbox::make('is_approved')
->label('Dikkatlice Okudum ve Onaylıyorum')
->accepted()
])
->deletable(false)
->addable(false)
->reorderable()
->columns(1),
])
->statePath('data')
->columns(1);
}
public function form(Form $form): Form
{
return $form
->schema([
Repeater::make('categorySteps')
->label($this->categoryApplicationName . ' Adımı')
->schema([
TextInput::make('step_title')
->label('Adım Başlığı')
->disabled()
->required(),

FileUpload::make('file_name')
->label('Dosya Yükleyin')
->disk('public')
->directory('category-application-steps')
->acceptedFileTypes(['application/pdf'])
->visible(fn(mixed $value): bool => dd($value))
->required(),

TextInput::make('file_description')
->label('Dosya Açıklaması')
->required(),

Checkbox::make('is_approved')
->label('Dikkatlice Okudum ve Onaylıyorum')
->accepted()
])
->deletable(false)
->addable(false)
->reorderable()
->columns(1),
])
->statePath('data')
->columns(1);
}
3 replies
FFilament
Created by Kaan on 10/16/2023 in #❓┊help
Custom Page Repeater Delete Item
I am working on a project using Filament V3 and facing an issue while trying to implement a custom delete method within a Repeater component. My aim is to allow the user to delete individual records within the Repeater component. I have created a delete method in my page class, and I am trying to link this method to the deleteAction property of the Repeater component, but it seems like the delete method is not being triggered. Below is the relevant code: https://gist.github.com/kaanxweb/8cdba1bf2c8b67f2a1706cdc4900509f
2 replies
FFilament
Created by Kaan on 10/13/2023 in #❓┊help
Wizard Running in the Same Column
Hello everyone. I want the wizard to save the data in the same column on the same sheet just like Repeater. Is that possible?
1 replies
FFilament
Created by Kaan on 10/10/2023 in #❓┊help
Catch Mount on the index page
Hello. I want to capture the id from the url in an index page and I want the index page to always show data based on a specific id. However, I cannot capture mount in my index page.
4 replies
FFilament
Created by Kaan on 10/9/2023 in #❓┊help
Dynamic Wizard
I'm currently working on a project where I'm using the Wizard component in Filament. I have a table named category_steps and I want to dynamically generate wizard steps based on the number of records in this table. Essentially, for each record in category_steps, I want to present the user with a corresponding step in the wizard. Could anyone guide me on how to achieve this dynamic generation of wizard steps using Filament in Laravel? Any help or pointers would be greatly appreciated. Thank you!
29 replies
FFilament
Created by Kaan on 10/7/2023 in #❓┊help
Update Repeater
I've been working with the Repeater component and I've encountered an issue where changes made on the front-end are not being persisted to the database. Here's the code I'm using:
72 replies
FFilament
Created by Kaan on 10/5/2023 in #❓┊help
Unable to retrieve the file_size for file at location
Greetings! I get the error you see below when saving an image on the filament: Unable to retrieve the file_size for file at location: livewire-tmp/6D8QLsQas3ajrb0518YlLmJfytitii-metaZG5wLXg0MDAtanBnLmpwZw==-.jpg.
3 replies
FFilament
Created by Kaan on 10/3/2023 in #❓┊help
Fill Method
Hi guys. Is fill method (for forms) available for Multi data? For Example:

$this->form->fill([
'categorySteps' => $category->categorySteps->toArray(),
]);

$this->form->fill([
'categorySteps' => $category->categorySteps->toArray(),
]);
2 replies
FFilament
Created by Kaan on 10/3/2023 in #❓┊help
Fill Form Data
Greetings! I want to perform an edit operation on my custom page I created in Filament. However, since this edit operation will be with data from a relational table, I have some difficulty in bringing the data. If I need to talk about logic briefly: There is "category_id" in categorySteps. Every data that has this "category_id" comes from the category_steps table. What I want to do here is to call the step_title of the data in the category_steps table associated with this category_id https://hastebin.skyra.pw/ezupekilon.php
12 replies
FFilament
Created by Kaan on 9/30/2023 in #❓┊help
Get record in custom page
Hi I want to get the record data in a custom page, I tried with $this->record but is not working, I'm using v3 My code:
<?php

namespace App\Filament\Resources\CategoryResource\Pages;

use App\Filament\Resources\CategoryResource;
use App\Models\Category;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Pages\Page;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Select;

use Filament\Tables;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

use Illuminate\Database\Eloquent\Model;



class ManageCategorySteps extends Page

{
protected static ?string $model = Category::class;

protected static string $resource = CategoryResource::class;

protected static string $view = 'filament.resources.category-resource.pages.manage-category-steps';

protected static ?string $title = 'Edit your Steps';

protected static ?string $recordTitleAttribute = 'record';





public function form(Form $form): Form
{
return $form
->schema([
Repeater::make('categorySteps')
->label('Category Steps')
->schema([
TextInput::make('categorySteps.name')->required(),
])
->columns(2)
])->columns(1);
}
}
<?php

namespace App\Filament\Resources\CategoryResource\Pages;

use App\Filament\Resources\CategoryResource;
use App\Models\Category;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Pages\Page;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Select;

use Filament\Tables;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

use Illuminate\Database\Eloquent\Model;



class ManageCategorySteps extends Page

{
protected static ?string $model = Category::class;

protected static string $resource = CategoryResource::class;

protected static string $view = 'filament.resources.category-resource.pages.manage-category-steps';

protected static ?string $title = 'Edit your Steps';

protected static ?string $recordTitleAttribute = 'record';





public function form(Form $form): Form
{
return $form
->schema([
Repeater::make('categorySteps')
->label('Category Steps')
->schema([
TextInput::make('categorySteps.name')->required(),
])
->columns(2)
])->columns(1);
}
}
4 replies
FFilament
Created by Kaan on 9/29/2023 in #❓┊help
Custom Page Forms Function Didn't Work
No description
3 replies