PHP code example of naowas / raindrops
1. Go to this page and download the library: Download naowas/raindrops 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/ */
naowas / raindrops example snippets
$client = new Client();
/* or, $client = Client::find(<id>); if you are editing ane existing record */
$form = FormBuilder::build( $client )
->form([
'action' => 'clients',
'method' => 'POST'
])
->render();
return view('create', compact('form'));
{!! $form !!}
$form = FormBuilder::build( $client )
->form([
'action' => 'clients',
'method' => 'POST'
])
->add('field_name', [
'label' => 'Field Label',
'type' => 'date'
])
->render();
$form = FormBuilder::build( $client )
->form([
'action' => 'clients',
'method' => 'POST'
])
->modify('field_name', [
'label' => 'New changed label',
'
$form = FormBuilder::build( $client )
->form([
'action' => 'clients',
'method' => 'POST'
])
->section('Awesome Section One', [ 'field_one', 'field_two'])
->section('Awesome Section Two', [ 'field_three', 'field_four'])
->render();
$form = FormBuilder::build( $client )
->form([
'action' => 'clients',
'method' => 'POST'
])
->submit([
'text' => 'Save Me',
'class' => 'btn btn-success',
'icon' => 'fa fa-save'
])
->render();
$table = DataTable::of(new Client)
->setUrl(url('datatables.data'))
->setId('data-table')
->render();
return view('index', compact('table'));
public function anyData(Datatables $datatables)
{
$query = Client::select();
return $datatables->eloquent($query)
->setTransformer(new DataTableTransformer())
->make(true);
}
public $fields = [
'field_name' => [
'label' => 'Field Label',
'type' => 'input type'
/* other configurations goes here */
]
]
'type' => 'select',
'options' => [
'option_1' => 'Option One'
]
/**
* Fields
*/
public $fields = [
'public_id' => [
'label' => 'Device ID',
'form' => false,
'index' => true,
'show' => 'exact'
],
'serial_number' => [
'label' => 'Serial Number',
'type' => 'text',
'validations' => 'unique:devices,serial_number{id}',
'index' => true,
'unique' => true,
'filter' => 'string'
],
'model_id' => [
'label' => 'Model',
'type' => 'select_db',
'table' => 'device_models',
'options' => ['id', 'model'],
'index' => true,
'show' => ['model', 'model_name']
],
'notes' => [
'label' => 'Notes',
'type' => 'editor'
],
'category' => [
'label' => 'Category',
'type' => 'select',
'form' => false,
'options' => [
'individual' => 'Individual',
'company' => 'Company'
],
'classes' => [],
'
protected $actions = [
'Sale' => '{url}/{id}/sale'
];
protected $paths = [
'client_photo' => 'uploads/client/client_photo'
];