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项目--企业单车网站(九)(加强复习啊)(花了那么多时间写的博客,不复习太浪费了)的更多相关文章

  1. thinkphp5项目--企业单车网站(五)

    thinkphp5项目--企业单车网站(五) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...

  2. thinkphp5项目--企业单车网站(四)

    thinkphp5项目--企业单车网站(四) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...

  3. thinkphp5项目--企业单车网站(三)

    thinkphp5项目--企业单车网站(三) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...

  4. thinkphp5项目--企业单车网站(二)

    thinkphp5项目--企业单车网站(二) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...

  5. thinkphp5项目--企业单车网站(一)

    thinkphp5项目--企业单车网站(一) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...

  6. thinkphp5项目--企业单车网站(七)

    thinkphp5项目--企业单车网站(七) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...

  7. thinkphp5项目--企业单车网站(六)

    thinkphp5项目--企业单车网站(六) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...

  8. thinkphp5项目--企业单车网站(八)(文章板块要点)(删除图片)

    thinkphp5项目--企业单车网站(八)(文章板块要点)(删除图片) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise ...

  9. thinkphp5项目--练手--企业单车网站(九)(友情链接)

    thinkphp5项目--练手--企业单车网站(九)(友情链接) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Webs ...

随机推荐

  1. POJ 2430 状压DP

    题意: 思路: 先预处理出所有格子的statement statement=1–>只有上边的格子被覆盖 statement=2–>只有下边的格子被覆盖 statement=3–>上下 ...

  2. 海康威视抓拍一体机--- C#源码

    https://pan.baidu.com/s/1kV4AjRp 需要的联系qq:694666781

  3. Vue 学习记录<2>

    一.Vue https://vue-loader.vuejs.org/zh-cn/ https://vuejs-templates.github.io/webpack/structure.html

  4. [ES6] Extends class in ES6 vs ES5 subclass

    ES6 class with extends and super: class Tree { constructor(size = ', leaves = {spring: 'green', summ ...

  5. Cookie应用--显示看过的商品

    package cn.itcast; import java.io.IOException; import java.io.PrintWriter; import java.util.LinkedHa ...

  6. 1.java soap api操作和发送soap消息

    转自:https://blog.csdn.net/lbinzhang/article/details/84721359 1. /** * soap请求 * * @return * @throws Ex ...

  7. MyEclipse 2016 安装/破解

    MyEclipse2016 C1 已经出现了!感觉好像不错的样子! 不多说了,开整... 好熟悉的界面,点击Next! 如上图标注1所示,请修改安装目录! 根据自己的喜好可以选择不同的版本,也可以安装 ...

  8. java 位操作 bitwise(按位) operation bit

    java 位操作 bitwise(按位) operation bit //一篇对于 原码 反码 补码 的介绍 http://www.cnblogs.com/zhangziqiu/archive/201 ...

  9. BZOJ4025: 二分图(LCT)

    Description 神犇有一个n个节点的图.因为神犇是神犇,所以在T时间内一些边会出现后消失.神犇要求出每一时间段内这个图是否是二分图.这么简单的问题神犇当然会做了,于是他想考考你. Input ...

  10. STM32之CAN通讯接收过滤器过滤分析

    一.前言 学习了CAN通讯,底层的东东CAN控制器已经帮你处理完成,也就是CAN通讯协议已经做好,你按协议格式往对应的位扔数据发送就好,所以使用CAN通讯,我们只需要去关心制定发送的数据间的协议,也就 ...