protected $_plural;
protected $_fields = [];
+ protected $_storeRequest;
+ protected $_updateRequest;
+
public function setup()
{
if (!$this->_routeURL) {
foreach ($this->_fields as $field) {
$this->addField($field);
}
-
-
- // add asterisk for fields that are required in ModelRequest
- $this->crud->setRequiredFields(CubistMagicStoreRequest::class, 'create');
- $this->crud->setRequiredFields(CubistMagicUpdateRequest::class, 'edit');
}
+
public function store(CubistMagicStoreRequest $request)
{
// your additional operations before save here
{
use CubistMagicAttribute;
protected $_attributes;
+ protected $_rules = [];
/**
* @param $attributes
public function getDefaultAttributes()
{
- return ['type' => 'text', 'column' => false, 'form' => 'both'];
+ return ['type' => 'text', 'column' => false, 'form' => 'both', 'rules' => ''];
}
public function __construct($attributes)
$this->init();
}
+ public function getRules()
+ {
+ return $this->getAttribute('rules', '');
+ }
+
public function getDefinition()
{
return $this->_attributes;
namespace Cubist\Backpack\app\Magic\Models;
+use Backpack\CRUD\CrudTrait;
use Cubist\Backpack\app\Magic\Fields\CubistMagicField;
use Cubist\Backpack\app\Magic\Util;
use Illuminate\Database\Eloquent\Model;
{
use CubistMagicAttribute;
+ use CrudTrait;
/**
* @var CubistMagicField[]
{
/** @var CubistMagicField $field */
$field = CubistMagicField::getInstance($attributes);
- $this->_fields[$field->getAttribute('name')] = $field;
+ $name = $field->getAttribute('name');
+ $this->_fields[$name] = $field;
+ $this->fillable[] = $name;
}
public function generateCode()
class CubistMagicRequest extends FormRequest
{
+ /**
+ * CubistMagicRequest constructor.
+ */
+ public function __construct($controller, $operation)
+ {
+ $this->__construct();
+ }
+
+
/**
* Determine if the user is authorized to make this request.
*
*/
public function rules()
{
+
return [
// 'name' => 'required|min:5|max:255'
];