I use Orchid 13 and Laravel 9, here is my code:
<?php
namespace App\Orchid\Screens;
use App\Models\Order;
use App\Models\Product;
use App\Models\ProductVariant;
use App\Models\TeamMember;
use Illuminate\Http\Request;
use Orchid\Screen\Actions\Button;
use Orchid\Screen\Fields\Group;
use Orchid\Screen\Fields\Input;
use Orchid\Screen\Fields\Picture;
use Orchid\Screen\Fields\Select;
use Orchid\Screen\Fields\TextArea;
use Orchid\Screen\Screen;
use Orchid\Screen\TD;
use Orchid\Support\Color;
use Orchid\Support\Facades\Alert;
use Orchid\Support\Facades\Layout;
class ProductEditScreen extends Screen
{
public $product;
public function query(Product $product): iterable
{
return [
'product' => $product,
'product.variants' => ProductVariant::where('mainProductId',$product->id)->filters()->defaultSort('id')->paginate()
];
}
public function layout(): iterable
{
return [
Layout::rows([
Group::make([
Input::make('product.productName')
->title('Name')
->placeholder('Attractive but mysterious title')
->help('Specify a short descriptive title for this post.'),
Input::make('product.3dmodel')
->title('3d Model URL')
->placeholder('URL to Sketchfab...')
->help('Specify URL for model uploaded in SketchFab.com.'),
]),
]),
Layout::rows([
Group::make([
Button::make('Add Product Variant')->icon('puzzle')->method('buttonClickProcessing')->type(Color::PRIMARY()),
])->fullWidth(),
Layout::table('product.variants', [
TD::make('id')->sort(),
TD::make('created_at')->sort(),
])
])->title('Product Variants'),
];
}
This portion of code gives me this error:
Orchid\Screen\Builder::Orchid\Screen\{closure}(): Argument #1 ($field) must be of type Orchid\Screen\Contracts\Fieldable, Orchid\Screen\Layouts\Table@anonymous given, called in /Users/venelin/Projects/BeastBurst-Website/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php on line 262
If I remove this:
Layout::table('product.variants', [
TD::make('id')->sort(),
TD::make('created_at')->sort(),
])
It is getting resolved. So I am sure trying to add this table causes my issue. Any idea why and how can I fix it?