1. Go to this page and download the library: Download ivanmercedes/flex-fields library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ivanmercedes / flex-fields example snippets
use IvanMercedes\FlexFields\FlexFieldsPlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugins([
FlexFieldsPlugin::make()
->showDashboardPage(true)
->showOverviewWidget(true)
->showEntitiesInMenu(true), // Globally toggle entities in the sidebar
]);
}
use IvanMercedes\FlexFields\Facades\FlexFields;
// Fluent entity access
$entity = FlexFields::entity('product');
$fields = $entity->fields(); // Cached active fields
$records = $entity->records()->where('status', 'published')->get();
// Create record with field values
$record = $entity->createRecord([
'title' => 'Sample Product',
], [
'price' => 99.99,
'color' => '#00ff00',
]);
use Illuminate\Database\Eloquent\Model;
use IvanMercedes\FlexFields\Models\Traits\HasFlexFields;
class Product extends Model
{
use HasFlexFields;
}
$product = Product::find(1);
$product->setFlexValue('price', 199.99);
$price = $product->getFlexValue('price');
use IvanMercedes\FlexFields\Ai\Agents\FlexFieldsAssistant;
$agent = new FlexFieldsAssistant;
$response = $agent->prompt('Show schema for products');
use IvanMercedes\FlexFields\Ai\FlexFieldsAi;
use Laravel\Ai\Agent;
class ContentAgent extends Agent
{
public function tools(): array
{
return [
// All tools or filtered by categories: read, structure, content, publishing, destructive
...FlexFieldsAi::tools(['read', 'content', 'publishing']),
];
}
}