本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::delete方法的具体用法?PHP Model::delete怎么用?PHP Model::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Model
的用法示例。
在下文中一共展示了Model::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteThe
/**
* Delete the given model entity.
*
* @param Model $model Model to be deleted.
* @param string $msg Message for a successful delete.
* @param string $title Title for a successful delete.
*
* @return array
*/
protected function deleteThe(Model $model, $msg = 'messages.deleted', $title = 'messages.success')
{
if ($model->delete()) {
return ['title' => trans("admin::{$title}"), 'msg' => trans("admin::{$msg}")];
}
return reportError();
}
示例2: delete
/**
* Delete the model.
*
* @param \Illuminate\Database\Eloquent\Model $user
*
* @return bool
*
* @throws \Exception
*/
public function delete(Model $user)
{
if (auth()->user() && auth()->user()->id === $user->id) {
abort(406);
}
return $user->delete();
}
示例3: delete
public function delete()
{
foreach (VendorItemPivot::byVendor($this->id)->get() as $object) {
$object->delete();
}
return parent::delete();
}
示例4: delete
public function delete()
{
foreach ($this->projects as $project) {
$project->delete();
}
parent::delete();
}
示例5: remove
/**
* Removes a model from this relationship type.
*/
public function remove(Model $model, $sessionKey = null)
{
if ($sessionKey === null) {
$options = $this->parent->getRelationDefinition($this->relationName);
if (array_get($options, 'delete', false)) {
$model->delete();
} else {
/*
* Make this model an orphan ;~(
*/
$model->setAttribute($this->getPlainForeignKey(), null);
$model->setAttribute($this->getPlainMorphType(), null);
$model->save();
}
/*
* Use the opportunity to set the relation in memory
*/
if ($this instanceof MorphOne) {
$this->parent->setRelation($this->relationName, null);
} else {
$this->parent->reloadRelations($this->relationName);
}
} else {
$this->parent->unbindDeferred($this->relationName, $model, $sessionKey);
}
}
示例6: delete
public function delete()
{
// Remove all relationships
$this->memberships()->detach();
$this->medias()->detach();
$this->pricelists()->delete();
// Delete all media links
foreach (ModuleMediaMembership::where('module_id', $this->id)->get() as $mmm) {
$mmm->delete();
}
// Remove all relationships
$this->tags()->detach();
// Delete all images
foreach ($this->images as $image) {
$image->delete();
}
// Delete all translations
$this->translations()->delete();
// Delete asset images folder
$upload_dir = \Config::get('redminportal::image.upload_dir');
$deleteFolder = new Image();
$url_path = RHelper::joinPaths($upload_dir, $this->table, $this->id);
$deleteFolder->deleteFiles($url_path);
return parent::delete();
}
示例7: delete
/**
* {@inheritdoc}
*/
public function delete()
{
if ($this->exists) {
$this->tagged()->delete();
}
return parent::delete();
}
示例8: delete
/**
* Delete Questions before deleting Group itself.
*
* @return bool|null
* @throws \Exception
*/
public function delete()
{
$this->questions->each(function ($question) {
$question->delete();
});
return parent::delete();
}
示例9: delete
public function delete()
{
foreach ($this->photos as $photo) {
File::delete($photo->path);
}
parent::delete();
}
示例10: delete
/**
* Delete Groups before deleting Section itself.
*
* @return bool|null
* @throws \Exception
*/
public function delete()
{
$this->groups->each(function ($group) {
$group->delete();
});
return parent::delete();
}
示例11: delete
public function delete()
{
$this->is()->delete();
$this->photos()->delete();
// δεν είμαι σίγουρος αν διαγράφει ΟΛΕΣ τις φωτογραφίες
parent::delete();
}
示例12: delete
/**
* Delete table data rate_cat and releted child rates
*/
public function delete()
{
// delete all related rates
$this->rates()->delete();
// delete the rates_cat
return parent::delete();
}
示例13: destroy
/**
* 删除资源
*
* @param \Illuminate\Database\Eloquent\Model $model
*
* @return mixed
* @throws \Exception
*/
public function destroy(Model $model)
{
if ($model->delete()) {
return $this->success('删除成功');
}
return $this->error('删除失败');
}
示例14: delete
/**
* Deletes a blog post and all
* the associated comments.
*
* @return bool
*/
public function delete()
{
// Delete the comments
$this->comments()->delete();
// Delete the blog post
return parent::delete();
}
示例15: delete
/**
* Delete an existing model.
*
* @throws Exception
* @return mixed
*/
public function delete()
{
$this->beforeDelete();
$return = parent::delete();
$this->afterDelete($return);
return $return;
}