PHP code example of vonsogt / template-operation
1. Go to this page and download the library: Download vonsogt/template-operation 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/ */
vonsogt / template-operation example snippets
namespace App\Http\Controllers\Admin;
use Backpack\CRUD\app\Http\Controllers\CrudController;
class InvoiceCrudController extends CrudController
{
use \SoufieneSlimi\TemplateOperation\TemplateOperation;
protected function setupTemplateOperation()
{
$this->crud->setValidation(InvoiceTemplateRequest::class);
$this->crud->setOperationSetting('excludedInputs', ['paid']);
CRUD::field('title')->type('custom_html')->value('<h1>FXXXX-XXXXXX</h1>')->size(8);
CRUD::field('type')->default(3)->size(4);
CRUD::field('hr')->type('custom_html')->value('<hr>');
CRUD::field('client')->size(6);
CRUD::field('items')->type('repeatable')->fields([
[
'name' => 'product',
'label' => 'Product',
'type' => 'select2_from_array',
'options' => Product::get(['id', 'name'])->pluck('name', 'id')->toArray(),
'wrapperAttributes' => ['class' => 'form-group col-md-6'],
],
[
'name' => 'quantity',
'label' => 'Quantity',
'type' => 'number',
'wrapperAttributes' => ['class' => 'form-group col-md-3'],
'attributes' => ['step' => 'any'],
],
[
'name' => 'price',
'label' => 'Price',
'type' => 'number',
'wrapperAttributes' => ['class' => 'form-group col-md-3'],
'attributes' => ['step' => 'any'],
],
]);
CRUD::field('total')
->label('Total ('.config('settings.currency').')')
->type('number')
->size(5)
->attributes(['readonly' => 'true']);
CRUD::field('paid')->type('number')->attributes(['step' => 'any'])->size(5);
CRUD::field('wallet')->default(config('settings.default_wallet'))->size(2);
}
'operations' => [
/*
* Template Operation
*/
'template' => [
// The cards color
// Available colors: bg-blue, bg-green, bg-purple, bg-orange, bg-red
'cardsClass' => 'bg-orange',
// How many cards per row
'cardsPerRow' => 3,
// The card icon
'cardIcon' => '<i class="las la-pen-alt"></i>',
// Excluded columns
'excludedInputs' => ['status_id']
],
]
bash
php artisan migrate
config\backpack\crud.php
$this->crud->setOperationSetting('key', value);