1. Go to this page and download the library: Download aquanode/formation 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/ */
if (Form::isValid('user')) // validates array fields with names like "user[name]" and "user[email]"
{
return true;
}
if (Form::isValid('user.')) // ending with a "." allows us to validate fields like "user[0][name]" and "user[1][name]"
{
return true;
}
/**
* The attribute sets for the model.
*
* @var array
*/
protected static $attributeSets = [
'standard' => [
'id',
'content',
'url', // this could even be a key listed in $arrayIncludedMethods for a getUrl() method
],
'update' => [
'set:standard', // t:author', // this will use an attribute set from the model used for the "author" relationship
'section' => 'class:'.Section::class, // this will look for an attribute set called "standard"
'tags' => 'class:'.Tag::class.';set', // this will look for an attribute set called "set"
],
];
/**
* The methods to automatically atic $attributeSets = [
'author' => [
'id',
'username',
'select:first_name', // this data is only being selected, and will be combined using the "getName" method defined above
'select:last_name', // this data is only being selected, and will be combined using the "getName" method defined above
'name',
],
];
/**
* The attribute sets for the model.
*
* @var array
*/
protected static $arrayIncludedMethods = [
'name' => 'getName',
];
$post = Post::selectAttributeSet('standard')
->limitRelatedData()
->first();
// selectSet is short-hand alias for selectAttributeSet
$users = User::selectSet('author', true), passing true as the second parameter automatically calls limitRelatedData() scope
->get()
->toArray();
return $post->toArray('standard');
return $post->toLimitedArray(); // same as above, assumes "standard" by default
return Post::orderBy('id')->get()->toArray('standard'); // filter models in a collection with attribute set
return Post::orderBy('id')->paginate(25)->toArray('standard'); // return a paginator converted to an array
return Post::orderBy('id')->setPage(3)->paginate(25)->collectionToArray('standard'); // return just the collection
/**
* The special formatted fields for the model for saving to the database.
*
* @var array
*/
protected static $formatsForDb = [
'media_type' => 'null-if-false:media',
'published_at' => 'null-if-false:published',
];
// new record
Form::setValidationRulesForNew($input);
// existing record
$record->setValidationRules($input);
// new or existing record ($record can be null)
Form::setValidationRulesForModel($record, $input);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.