1. Go to this page and download the library: Download czim/laravel-dataobject 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/ */
czim / laravel-dataobject example snippets
class TestDataObject extends \Czim\DataObject\AbstractDataObject
{
public function getName($value)
{
$this->getAttribute('name');
}
public function setName($value)
{
$this->setAttribute('name', $value);
}
}
class TestDataObject extends \Czim\DataObject\AbstractDataObject
{
protected $magicAssignment = false;
...
$dataObject = new YourDataObject();
// validate() returns a boolean, false if it does not follow the rules
if ( ! $dataObject->validate()) {
$messages = $dataObject->messages();
// messages() returns a standard Laravel MessageBag
dd( $messages->first() );
}