thinkphp5项目--企业单车网站(九)(加强复习啊)(花了那么多时间写的博客,不复习太浪费了)
thinkphp5项目--企业单车网站(九)(加强复习啊)(花了那么多时间写的博客,不复习太浪费了)
项目地址
fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Website
https://github.com/fry404006308/BicycleEnterpriseWebsite
一、总结
二、js警告框warning事件
<a href="#" onClick="warning('确实要删除吗', '{:url('article/delete',array('id'=>$vo['aid']))}')" class="btn btn-danger btn-sm shiny">
1、这里onclick调用
2、warning的使用:warning('参数1','url')
三、文章删除逻辑
删除数据库字段,同时也要删除资源,比如图片
这里用了钩子函数,模型事件,before_delete
控制器代码:
public function delete(){
$id = input('id');
if(ModelArticle::destroy($id)){ //1、模型的静态方法destroy删除
$this->success('删除文章成功!','article/lst');
}else{
$this->error('删除文章失败!');
}
}
模型代码:
<?php
namespace app\admin\model;
use think\Model; class Article extends Model
{
protected static function init() //2、注册模型事件
{
Article::event('before_delete', function ($datain) { //3、删除图片操作
//1、删除原来的图片
$dataArticle = Article::find($datain->aid);
/*$_SERVER['DOCUMENT_ROOT'] string(129) "E:/2017-02-21--SoftWare/PHP/SOFTWARE/phpStudy_New/PHPTutorial/WWW/github/BicycleEnterpriseWebsite/BicycleEnterpriseWebsite/public"*/
$thumbpath=$_SERVER['DOCUMENT_ROOT'].$dataArticle->athumb;
if(file_exists($thumbpath)){
@unlink($thumbpath);
}
});
}
}
thinkphp5项目--企业单车网站(九)(加强复习啊)(花了那么多时间写的博客,不复习太浪费了)的更多相关文章
- thinkphp5项目--企业单车网站(五)
thinkphp5项目--企业单车网站(五) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...
- thinkphp5项目--企业单车网站(四)
thinkphp5项目--企业单车网站(四) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...
- thinkphp5项目--企业单车网站(三)
thinkphp5项目--企业单车网站(三) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...
- thinkphp5项目--企业单车网站(二)
thinkphp5项目--企业单车网站(二) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...
- thinkphp5项目--企业单车网站(一)
thinkphp5项目--企业单车网站(一) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...
- thinkphp5项目--企业单车网站(七)
thinkphp5项目--企业单车网站(七) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...
- thinkphp5项目--企业单车网站(六)
thinkphp5项目--企业单车网站(六) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...
- thinkphp5项目--企业单车网站(八)(文章板块要点)(删除图片)
thinkphp5项目--企业单车网站(八)(文章板块要点)(删除图片) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise ...
- thinkphp5项目--练手--企业单车网站(九)(友情链接)
thinkphp5项目--练手--企业单车网站(九)(友情链接) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Webs ...
随机推荐
- vue 中表单 [v-bind:true-value="a" v-bind:false-value="b"] 的用法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- LuoguP2764 最小路径覆盖问题(最大流)
题目描述 «问题描述: 给定有向图G=(V,E).设P 是G 的一个简单路(顶点不相交)的集合.如果V 中每个顶点恰好在P 的一条路上,则称P是G 的一个路径覆盖.P 中路径可以从V 的任何一个顶点开 ...
- linux/unix 基本概念的认识(sha-bang 、PPA)
PPA:Personal Package Archives : Ubuntu: 比如为安装 emacs,需要首先添加某个PPA: sudo add-apt-repository ppa:cassou/ ...
- django 简单会议室预约(3)
URL配置: 今天配置一下URL,打开urls.py配置如下: from django.conf.urls import patterns, include, url from djapp impor ...
- RFID的基本组织构成
RFID技术由3大组件构成, 包括: 阅读器.天线.标签三大组件. 阅读器 为RFID系统最重要也是最复杂的一个组件.因其工作模式一般是主动向标签询问标识信息, 所以有时又被称为询问器(Interro ...
- OrmLite使用小结(一)
在使用OrmLite过程中,遇到了不少问题.鉴于中文文档比較少,看英文文档又不知道怎样看起.仅仅能遇到问题查找解决方法并整理出来,如有错误,希望能指正! ** 1.模糊条件查询 ** 使用条件查询时. ...
- 关于C++中的内存泄露
1.c++内存泄漏的定义: 内存泄漏(memory leak)是指由于疏忽或错误造成了程序未能释放掉不再使用的内存的情况.内存泄漏并非指内存在物理上的消失,而是应用程序分配某段内存后,由于设计错误,失 ...
- Java exception handling best practices--转载
原文地址:http://howtodoinjava.com/2013/04/04/java-exception-handling-best-practices/ This post is anothe ...
- 不同jquery对象触发相同的函数 “.js-story-title,.js-mt-index-cont2”
$(document).on("click",".js-story-title,.js-mt-index-cont2",function () {}
- vue 自定义分页组件
vue2.5自定义分页组件,可设置每页显示条数,带跳转框直接跳转到相应页面 Pagination.vue 效果如下图: all: small(只显示数字和上一页和下一页): html <temp ...