當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Model::update方法代碼示例

本文整理匯總了PHP中Illuminate\Database\Eloquent\Model::update方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model::update方法的具體用法?PHP Model::update怎麽用?PHP Model::update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Database\Eloquent\Model的用法示例。


在下文中一共展示了Model::update方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: update

 /**
  * Update a user.
  *
  * @param Model $item
  * @param array $data
  * @return bool|int
  */
 public function update(Model $item, array $data)
 {
     if (isset($data['password'])) {
         $data['password'] = bcrypt($data['password']);
     }
     return $item->update($data);
 }
開發者ID:artissant,項目名稱:stock,代碼行數:14,代碼來源:UserRepository.php

示例2: update

 /**
  * Update an existing model.
  * @param  array $input
  * @throws Exception
  * @return mixed
  */
 public function update(array $input = [])
 {
     $this->beforeUpdate($input);
     $return = parent::update($input);
     $this->afterUpdate($input, $return);
     return $return;
 }
開發者ID:christiannwamba,項目名稱:laravel-site,代碼行數:13,代碼來源:BaseModel.php

示例3: update

 /**
  * Update the model in the database.
  *
  * @param  array  $attributes
  * @return bool|int
  */
 public function update(array $attributes = [])
 {
     if (isset($attributes['alias']) && empty($attributes['alias'])) {
         $name = $this->name;
         if (isset($attributes['name'])) {
             $name = $attributes['name'];
         }
         $attributes['alias'] = Str::slug($name) . '-' . Uuid::generate(4);
     }
     if (isset($attributes['galleries'])) {
         if (empty($attributes['galleries'])) {
             $attributes['galleries'] = [];
         }
         $attributes['galleries'] = json_encode($attributes['galleries']);
     }
     if (isset($attributes['attributes'])) {
         if (empty($attributes['attributes'])) {
             $attributes['attributes'] = [];
         }
         $attributes['attributes'] = json_encode($attributes['attributes']);
     }
     if (!parent::update($attributes)) {
         throw new Exception('Cannot update product.');
     }
     return $this;
 }
開發者ID:php-soft,項目名稱:laravel-shopping-cart,代碼行數:32,代碼來源:Product.php

示例4: inlineUpdate

 public function inlineUpdate($id)
 {
     $this->instance = $this->find($id);
     if (empty($this->instance)) {
         return false;
     }
     $data = $this->request->all();
     $updated = false;
     if (method_exists($this->instance, 'getRepository')) {
         $repository = $this->instance->getRepository();
         if (method_exists($repository, 'inlineSave')) {
             if ($repository->inlineSave($data)) {
                 $updated = true;
             } else {
                 return false;
             }
         }
     }
     if ($updated == false) {
         $fillableFields = $this->instance->getFillable();
         foreach ($data as $key => $value) {
             if (in_array($key, $fillableFields)) {
                 $this->instance->{$key} = $value;
             }
         }
         if ($this->instance->update()) {
             $updated = true;
         }
     }
     return $updated;
 }
開發者ID:procoders,項目名稱:admin,代碼行數:31,代碼來源:ModelRepository.php

示例5: update

 public function update(array $attributes = array(), array $options = array())
 {
     if (array_key_exists('file', $attributes)) {
         $this->deleteFile();
         $this->uploadFile($attributes['file'], $attributes['file_name']);
     }
     parent::update($attributes, $options);
 }
開發者ID:ixudra,項目名稱:imageable,代碼行數:8,代碼來源:Image.php

示例6: updateModel

 /**
  * @param Model $model
  * @param array $data
  *
  * @throws RepositoryException
  *
  * @return Model
  */
 public function updateModel(Model $model, array $data)
 {
     if (!$model->update($data)) {
         throw new RepositoryException('Could not be saved');
     }
     $this->makeModel();
     return $model;
 }
開發者ID:draperstudio,項目名稱:eloquent-repositories,代碼行數:16,代碼來源:CrudlTrait.php

示例7: update

 /**
  * @param Model $model
  * @param array $input
  * @return bool
  */
 public function update(Model $model, array $input)
 {
     $updated = $model->update($input);
     if ($updated) {
         app('cache')->flush();
     }
     return $updated;
 }
開發者ID:rappasoft,項目名稱:laravel-5-boilerplate,代碼行數:13,代碼來源:BaseRepository.php

示例8: update

 /**
  * Update permissions and roles of a route.
  *
  * @param  array  $attributes
  * @return bool|int
  */
 public function update(array $attributes = [])
 {
     if (!parent::update($attributes)) {
         throw new Exception('Cannot update category.');
         // @codeCoverageIgnore
     }
     return $this->fresh();
 }
開發者ID:wyrover,項目名稱:laravel-users,代碼行數:14,代碼來源:RoutePermission.php

示例9: update

 /**
  * 執行更新操作
  *
  * @param \Illuminate\Database\Eloquent\Model $model
  *
  * @return mixed
  */
 public function update(Model $model)
 {
     $this->validateUpdate();
     $form = $this->request()->all();
     if ($model->update($form)) {
         return $this->success('保存成功', $model);
     }
     return $this->error('修改失敗,請稍後再試');
 }
開發者ID:netxinyi,項目名稱:meigui,代碼行數:16,代碼來源:ResourceTrait.php

示例10: update

 /**
  * If a future month is being set to 0, set the value to null instead of 0
  */
 public function update(array $attributes = [], array $options = [])
 {
     if (array_key_exists('hours_used', $attributes) && $attributes['hours_used'] == 0) {
         if ($this->getStartDate() > \Carbon\Carbon::now()) {
             $attributes['hours_used'] = null;
         }
     }
     parent::update($attributes);
 }
開發者ID:rtmatt,項目名稱:rtclientmanager,代碼行數:12,代碼來源:ServiceMonth.php

示例11: update

 /**
  * Update the model in the database.
  *
  * @param array $attributes
  * @param array $options
  * @return bool|int
  */
 public function update(array $attributes = [], array $options = [])
 {
     if (Guardian::hasClients()) {
         $attributes[Guardian::getClientColumn()] = Guardian::getClientId();
     }
     if ($this->locked) {
         return false;
     }
     return parent::update($attributes, $options);
 }
開發者ID:emilmoe,項目名稱:guardian,代碼行數:17,代碼來源:Role.php

示例12: update

 /**
  * Update the model in the database.
  *
  * @param  array  $attributes
  * @return bool|int
  */
 public function update(array $attributes = [])
 {
     if (!empty($attributes['galleries'])) {
         $attributes['galleries'] = json_encode($attributes['galleries']);
     }
     if (!parent::update($attributes)) {
         throw new Exception('Cannot update product.');
     }
     return $this;
 }
開發者ID:emtudo,項目名稱:laravel-shopping-cart,代碼行數:16,代碼來源:Product.php

示例13: update

 public function update(array $data = [])
 {
     unset($data['_method'], $data['_token']);
     if (parent::update($data)) {
         unset($data['color']);
         if (Element::where('element_data_id', $this->id)->update($data)) {
             return true;
         }
     }
     return false;
 }
開發者ID:emmanuelsf,項目名稱:xdrawerl,代碼行數:11,代碼來源:Container.php

示例14: update

 public function update(array $attributes = [])
 {
     parent::update($attributes);
     $instances = collect();
     foreach ($attributes['instances'] as $instance) {
         $instance['date'] = $attributes['date'];
         $instances->push($this->instances()->updateOrCreate(array_merge(['id' => 0], array_only($instance, ['id'])), $instance));
     }
     $this->instances()->whereNotIn('id', $instances->pluck('id')->all())->delete();
     return $this->setRelation('instances', $instances);
 }
開發者ID:Carlsson87,項目名稱:lumen,代碼行數:11,代碼來源:Workout.php

示例15: update

 /**
  * Update author with new data
  *
  * @param  arrray $data
  * @return null
  */
 public function update(array $data = [])
 {
     $validator = $this->getValidator($data);
     if (!$validator->validate()) {
         $messages = [];
         foreach ($validator->errors() as $fieldName => $errors) {
             $messages[] = current($errors);
         }
         $message = implode("\n", $messages);
         throw new \Exception($message);
     }
     return parent::update($data);
 }
開發者ID:GeeH,項目名稱:slim-bookshelf,代碼行數:19,代碼來源:Author.php


注:本文中的Illuminate\Database\Eloquent\Model::update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。