'required|exists:users,id', 'name' => 'required|between:1,255', 'data' => 'required' ]; /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function user() { return $this->belongsTo('User'); } /** * @param $value */ public function setDataAttribute($value) { $this->attributes['data'] = json_encode($value); } /** * @param $value * * @return mixed */ public function getDataAttribute($value) { return json_decode($value); } }