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. hadoop-2.6.0.tar.gz + hive-1.0.0.tar.gz + pig-0.15.0.tar.gz的安装

    这里,为什么选择用hadoop-2.6.0.tar.gz  +   hive-1.0.0.tar.gz是为了搭配兼容. hadoop-2.6.0.tar.gz  +   hive-1.0.0.tar. ...

  2. 今日题解------uvalive 2689

    今天学到了代码以外的东西,就是你在vj上挂了content ,然后你想更新它,你就要刷新一下,不然你提交的那题可能提交到别的地方. 好了回到重点,本题的题意是: #include<bits/st ...

  3. HDU——T 3336 Count the string

    http://acm.hdu.edu.cn/showproblem.php?pid=3336 Time Limit: 2000/1000 MS (Java/Others)    Memory Limi ...

  4. js03 数组

    变量的自动转换=== 等同符:不会发生类型的自动转化! == 等值符:会发生类型自动转化.自动匹配!判断相等没有equals()方法,只有2个等号3个等号. <!DOCTYPE HTML PUB ...

  5. spring的BeanWrapper类的原理和使用方法

    转自:http://blog.sina.com.cn/s/blog_79ae79b30100t4hh.html 如果动态设置一个对象属性,可以借助Java的Reflection机制完成: Class ...

  6. element-UI实现el-table-column百分比自定义分配

    1.把el-table-column的属性width换位min-width就支持百分比显示了.

  7. itchat转发指定的微信群里某个用户的发言到指定的群

    复读机功能, 如果有比较多的用户,超出500人,那就得分开至少两个群,如何把一些消息自动复制到另一个群呢. 自动转发指定用户的发言,转发到别的群 # !/usr/bin/env python # -* ...

  8. [JWT] JWT Signature With RS256 - Learn The Advantages Compared to HS256

    The advantage of RS256 over HS256 is RS256 no longer need to share the secret key between client and ...

  9. Apple Watch 集成环信SDK

    本文简单的讲述下怎样用Apple Watch Kit集成环信SDK. 升级xcode到version 6.2,和 IOS SDK8.2 下载环信SDK从官网 打开XCode->new proje ...

  10. eclipse中导入zico Maven项目

    zico源代码地址:https://github.com/jitlogic/zico 简单的说,git上同步的源代码需要先进行maven编译,然后导入eclipse. 如果没有配置好maven,请参考 ...