public function store(CreateRoleRequest $request) { $data = $request->only(['name', 'description']); $this->roleModel->create($data); $this->setStatusMessage(trans('aliukevicius/laravelRbac::lang.role.messageCreated', ['name' => $data['name']])); return \Redirect::to($this->getRoleUrl('index')); }
/** * {@inheritdoc} */ public function create(array $data) { $instance = $this->model->create($data); if (!$instance->getKey()) { throw new EntityCreateException('Failed to create entity'); } return $instance; }
/** * Create a new model * * @param array Data to create a new object * @return boolean */ public function create(array $data) { $model = $this->model->create($data); if (!$model) { return false; } return $model; }
/** * Performs INSERT. * * @param $row */ protected function insert($row) { if ($this->dryRun) { return; } $record = $this->model->create($row); }
public static function create(array $attributes = []) { if (array_key_exists('attachment', $attributes)) { $attributes['attachment'] = static::processAttachment($attributes['attachment']); } return parent::create($attributes); }
/** * Create a new model instance and store it in the database * * @param array $data * @return static */ public function store(array $data) { // Remove non-fillable items from our data array foreach ($data as $key => $value) { if (!in_array($key, $this->model->getFillable())) { unset($data[$key]); } } // Do we need to create a reference id? $referenceColumn = $this->referenceIdColumnName(); if ($this->model->isFillable($referenceColumn) && !isset($data[$referenceColumn])) { $data[$referenceColumn] = $this->generateReferenceId(); } // Return the new model object return $this->model->create($data); }
/** * Create the model in the database. * * @param array $attributes * @return category */ public static function create(array $attributes = []) { if (empty($attributes['alias'])) { $attributes['alias'] = Str::slug($attributes['name']) . '-' . Uuid::generate(4); } return parent::create($attributes)->fresh(); }
/** * Create a new model. * * @param array $input * @throws Exception * @return mixed */ public static function create(array $input) { static::beforeCreate($input); $return = parent::create($input); static::afterCreate($input, $return); return $return; }
/** * Save a new model and return the instance. * * @param array $attributes * @return static */ public static function create(array $attributes = []) { if (Guardian::hasClients()) { $attributes[Guardian::getClientColumn()] = Guardian::getClientId(); } return parent::create($attributes); }
public static function create(array $attributes = []) { if (!array_key_exists('start_date', $attributes)) { throw new \RTMatt\MonthlyService\Exceptions\ServiceMonthNoDateException(); } return parent::create($attributes); }
/** * @param array $data * * @return mixed */ public function create(array $data) { $this->validate($data, ValidatorInterface::RULE_CREATE); $results = $this->model->create($data); $this->resetModel(); return $this->parseResult($results); }
/** * Create a new model instance and store it in the database * * @param array $data * @return static */ public function store(array $data) { // Do we need to create a reference id? if ($this->model->isFillable('ref') && !isset($data['ref'])) { $data['ref'] = $this->generateReferenceId(); } // Create the new model object $model = $this->model->create($data); // Do we need to set a hash? if ($this->model->isFillable('hash')) { $model->hash = \Hashids::encode($model->id); $model->save(); } // Return the new model object return $model; }
public static function create(array $attributes = []) { if (config('global.managers.current.id')) { $data = array_merge($attributes, ['manager_id' => config('global.managers.current.id'), 'ip' => config('global.ip.current'), 'origin' => config('global.origin.current')]); parent::create($data); } }
/** * Create the model in the database. * * @param array $attributes * @return category */ public static function create(array $attributes = []) { if (empty($attributes['alias'])) { $attributes['alias'] = Str::slug($attributes['title']); } $attributes['user_id'] = Auth::user()->id; return parent::create($attributes)->fresh(); }
/** * Override of the create function, to incorporate a salt for password generation * * @param array attributes[]; */ public static function create(array $attributes = []) { if (self::isUnguarded()) { $attributes['password'] = password_hash($attributes['password'], PASSWORD_BCRYPT); $model = parent::create($attributes); return $model; } }
/** * Create a new entity * * @param array $data * * @return \Symfony\Component\HttpFoundation\Response */ public function create(array $data) { $q = $this->model->create($data); if (!$q) { return $this->createError(); } return $this->createSuccess(); }
/** * Creates an item * * @param \Illuminate\Http\Request $data * @return \Illuminate\Http\JsonResponse */ public function create(Request $data = null) { $data = $data ?: \Input::json(); $json = $data->all(); $json = $this->addAttribution($json); try { $this->model->validate($json); $item = $this->model->create($json); return $this->showByObject($item); } catch (ValidationException $e) { return $this->response->setStatusCode(422)->withError($e->errors()->all(), 'GEN-UNPROCESSABLE-ENTITY'); } catch (MassAssignmentException $e) { return $this->response->setStatusCode(422)->withError("Cannot mass assign " . $e->getMessage(), 'GEN-UNPROCESSABLE-ENTITY'); } catch (\Exception $e) { return $this->response->setStatusCode(422)->withError($e->getMessage(), 'GEN-UNPROCESSABLE-ENTITY'); } }
public static function create(array $data = []) { if (is_module_enabled('Site')) { $siteId = Site::id(); $data['site_id'] = $siteId; } return parent::create($data); }
public static function create(array $data) { if (User::where('student_id', '=', $data['student_id'])->count() > 0) { return $data['student_id'] . " already exists"; } parent::create($data); return $data['student_id'] . " added successfully"; }
public static function create(array $options = []) { $res = Location::geocode($options['address'] . ' Tulsa, OK'); $geo = $res->results[0]->geometry->location; $options['lat'] = $geo->lat; $options['lng'] = $geo->lng; return parent::create($options); }
public static function create(array $attributes = []) { $country = parent::create($attributes); /** @var $country Country */ $army = Army::create(['size' => 2]); $country->army()->save($army); return $country; }
public static function create(array $attributes = array(), $confirmation = true) { $attributes["confirmation_code"] = \Uuid::generate()->string; $user = parent::create($attributes); if ($confirmation) { self::sendComfirmationMail($user); } return $user; }
public static function create(array $attributes = []) { $model = parent::create(array_except($attributes, 'instances')); if (array_key_exists('instances', $attributes) && !empty($attributes['instances'])) { $instances = collect($model->instances()->createMany($attributes['instances'])); $model->setRelation('instances', $instances); } return $model; }
/** * Record a notification for the user but make sure there are no duplicates first * * @param int $userId * @param string $message * @param string $type * @param string $hash * @return Notification */ public static function logNew($userId, $message, $type, $hash) { $existingNotifications = Notification::where('user_id', $userId)->where('hash', $hash)->first(); if ($existingNotifications) { return $existingNotifications; } $newNotification = parent::create(['user_id' => $userId, 'message' => $message, 'type' => $type, 'hash' => $hash]); event(new NewMemberNotification($newNotification)); return $newNotification; }
public static function create(array $attributes) { $length = 6; do { $attributes['slug'] = str_random($length); $exists = static::where('slug', '=', $attributes['slug'])->first(); $length++; } while (!empty($exists)); return parent::create($attributes); }
/** * Create Product * * @param array $attributes Attributes * @return PhpSoft\Illuminate\ShoppingCart\Model\Product */ public static function create(array $attributes = []) { if (empty($attributes['alias'])) { $attributes['alias'] = Str::slug($attributes['title']) . '-' . Uuid::generate(4); } if (empty($attributes['galleries'])) { $attributes['galleries'] = []; } $attributes['galleries'] = json_encode($attributes['galleries']); return parent::create($attributes)->fresh(); }
public static function create(array $attributes = []) { if (!array_key_exists('start_date', $attributes)) { throw new \RTMatt\MonthlyService\Exceptions\ServicePlanNoDateException(); } $plan = parent::create($attributes); static::generateServiceMonths($plan); if (!(array_key_exists('skip_default_benefits', $attributes) && $attributes['skip_default_benefits'] === true)) { static::applyDefaultBenefits($plan); } return $plan; }
/** * @param Entity $entity * @param array $data * @return Entity */ public function saveEntity(Entity $entity, $data = array()) { if ($record = $this->model->find($entity->id())) { if (isset($data['updated_at'])) { $data['updated_at'] = date("Y-m-d H:i:s"); } $record->update($data); } else { $record = $this->model->create($data); $entity->setId($record->id); } return $entity; }
public static function create(array $attributes) { $purchase_id = array_get($attributes, 'purchase_id'); $product_id = array_get($attributes, 'product_id'); if (!$purchase_id or !$product_id) { return null; } $first = \App\Models\ProductInPurchaseModel::where('purchase_id', '=', $purchase_id)->where('product_id', '=', $product_id)->first(); if ($first) { return null; } return parent::create($attributes); }
/** * @param array $attributes * @return void|static */ public static function create(array $attributes = []) { // Add salt if (!array_key_exists('secret', $attributes) || $attributes['secret'] == '') { $secret = StringHelper::generateRandomString(20); $attributes['secret'] = $secret; } // Account status $attributes['account_status'] = self::ACCOUNT_ACTIVE; $model = parent::create($attributes); // Generate passkey UserPasskey::create(['user_id' => $model->id, 'passkey' => md5(StringHelper::generateRandomString() . time() . $model->secret)]); return $model; }