I'm trying to solve this problem: I have a table offers. every time after creating a new offer, 6 default articles are copied to the offerposts table and the offer_id key is added to them. consequently, I need to be able to edit all offer posts that belong to a specific offer in the offer editing. I have the records loaded, but as soon as I draw them through Tabs, the values are not inserted into the text field but are above it and therefore I cannot edit it. The goal is that in a specific price offer, in addition to the offer fields, I can also edit the text of all offerposts that have the same offer_id as the offer. Thanks in advance for your help
<?php
namespace App\Filament\Admin\Resources;
use App\Filament\Admin\Resources\OfferResource\Pages;
use App\Filament\Admin\Resources\OfferResource\RelationManagers;
use Filament\Forms\Components\Fieldset;
use App\Models\Offer;
use App\Models\Customer;
use App\Models\Language;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Filament\Forms\Components\MarkdownEditor;
use Filament\Forms\Components\Section;
use App\Models\Post;
use App\Models\OfferPost;
use Filament\Forms\Components\Tabs;
use Illuminate\Support\Carbon;
use Filament\Forms\Components\Textarea;
use Filament\Tables\Actions\EditAction;
use Filament\Forms\Components\ViewField;
use Illuminate\Http\Request;
class OfferResource extends Resource
{
protected static ?string $model = Offer::class;
protected static ?string $navigationIcon = 'heroicon-o-shopping-bag';
public static function form(Form $form): Form
{
$currentOffer = $form->getRecord();
//$offerPosts = OfferPost::where('offer_id', $currentOffer->id);
$offerPosts = OfferPost::where('offer_id', $currentOffer->id)->get();
$currentId = 5;
return $form
->schema([
Section::make('Basic informations')
->description('Please fill all basic informations about offer')
->schema([
Forms\Components\TextInput::make('name')
->required()
->autofocus()
->suffix('id'),
Forms\Components\TextInput::make('project')
->required(),
Forms\Components\TextInput::make('deal_id'),
Forms\Components\Select::make('partner_id')
->options(Customer::all()->pluck('name', 'id'))
->preload()
->searchable()
->label(__('Partner')),
Forms\Components\Select::make('lang_id')
->options(Language::all()->pluck('name', 'id'))
->preload()
->default(Language::first()->id)
->label(__('Language')),
Forms\Components\DatePicker::make('expiration')
->required()
->firstDayOfWeek(1)
->default(Carbon::now()->addDays(15)->format('Y-m-d')),
Forms\Components\MarkdownEditor::make('description')
->columnSpanFull(),
Fieldset::make('Location')
->schema([
Forms\Components\TextInput::make('address')
->required(),
Forms\Components\TextInput::make('city')
->required(),
Forms\Components\TextInput::make('zipcode')
->required(),
Forms\Components\TextInput::make('state')
->required(),
]),
Fieldset::make('Prices')
->schema([
Forms\Components\TextInput::make('extra_work_price')
->numeric(),
Forms\Components\TextInput::make('total_price')
->default(0)
->readonly(),
Forms\Components\TextInput::make('total_price2')
->default(0)
->readonly(),
])->columns(3),
])->columns(3),
Section::make('General texts')
->schema([
Tabs::make('Tabs')
->tabs(function() use ($offerPosts) {
foreach ($offerPosts as $offerPost) {
$body = $offerPost->body;
$name = $offerPost->name;
$tabs[] = Tabs\Tab::make($name)
->schema([
Forms\Components\MarkdownEditor::make($body)
]);
}
return $tabs;
})
]),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('partner.name')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('lang.name')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('extra_work_price')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('total_price')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('total_price2')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('expiration')
->date()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListOffers::route('/'),
'create' => Pages\CreateOffer::route('/create'),
'edit' => Pages\EditOffer::route('/{record}/edit'),
];
}
}
for me, the text is displayed above the MarkDownEditor, and I can't edit it
