MuhamDaily πŸ…₯
MuhamDaily πŸ…₯
FFilament
Created by MuhamDaily πŸ…₯ on 5/4/2024 in #β“β”Šhelp
Select Condition
In Laravel Filament version 3, I want to make if the user chooses the first option then the nominal input will appear, if the user chooses the second option then the item name input will appear. Can I apply it to filament? so input will appear if the option has been selected
4 replies
FFilament
Created by MuhamDaily πŸ…₯ on 12/14/2023 in #β“β”Šhelp
Custom Column Filament
#Model: OrderItem.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class OrderItem extends Model
{
use HasFactory;

protected $fillable = [
'order_id', 'package_id', 'weight', 'unit_price'
];
}
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class OrderItem extends Model
{
use HasFactory;

protected $fillable = [
'order_id', 'package_id', 'weight', 'unit_price'
];
}
#Model: Order.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Order extends Model
{
use HasFactory;

protected $fillable = [
'customer_id', 'code', 'status', 'payment', 'notes'
];

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

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

public function items(): HasMany
{
return $this->hasMany(OrderItem::class);
}
}
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Order extends Model
{
use HasFactory;

protected $fillable = [
'customer_id', 'code', 'status', 'payment', 'notes'
];

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

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

public function items(): HasMany
{
return $this->hasMany(OrderItem::class);
}
}
#File: OrderResource.php
use Filament\Tables\Table;
use App\Models\OrderItem;

public function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('total_price')
->getStateUsing(fn (OrderItem $record) => $record->weight . $record->unit_price),
]);
}
use Filament\Tables\Table;
use App\Models\OrderItem;

public function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('total_price')
->getStateUsing(fn (OrderItem $record) => $record->weight . $record->unit_price),
]);
}
How to display total price from order_item table? so weight * unit_price
16 replies
FFilament
Created by MuhamDaily πŸ…₯ on 12/10/2023 in #β“β”Šhelp
How can the FileUpload field in Laravel Filament directory be changed dynamically?
I have a form with a file upload. When i upload the file, it saves into my desired public/uploads/documents location. However, i want every user should save it's files public/uploads/documents/userfolder based on user foldername on my client's details table. I am using Relation manager to save client's details and uploaded files. How do i achieve this?
FileUpload::make('documents')->disk('public')->directory('uploads/documents/'.$foldername)
FileUpload::make('documents')->disk('public')->directory('uploads/documents/'.$foldername)
I want to get the $foldername from the related Parent model in the table.
3 replies