PluginsSliderModel.class.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Admin\Model;
  15. class PluginsSliderModel{
  16. public function show_slider_page(){
  17. $count=M('plugins_slider')->count();
  18. $Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
  19. $show = $Page->show();// 分页显示输出
  20. $list = M('plugins_slider')->where(array('status'=>1))->order('slider_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
  21. foreach ($list as $key => $value) {
  22. $list[$key]['image']=resize($value['image'], 100, 100);
  23. }
  24. return array(
  25. 'empty'=>'<tr><td colspan="20">~~暂无数据</td></tr>',
  26. 'list'=>$list,
  27. 'page'=>$show
  28. );
  29. }
  30. public function validate($data){
  31. $error=array();
  32. if(empty($data['image'])){
  33. $error='图片必须';
  34. }
  35. if($error){
  36. return array(
  37. 'status'=>'back',
  38. 'message'=>$error
  39. );
  40. }
  41. }
  42. public function add_slider($data){
  43. $error=$this->validate($data);
  44. if($error){
  45. return $error;
  46. }
  47. $r=M('PluginsSlider')->add($data);
  48. if($r){
  49. return array(
  50. 'status'=>'success',
  51. 'message'=>'新增成功',
  52. 'jump'=>U('PluginsSlider/index')
  53. );
  54. }else{
  55. return array(
  56. 'status'=>'fail',
  57. 'message'=>'新增失败',
  58. 'jump'=>U('PluginsSlider/index')
  59. );
  60. }
  61. }
  62. public function edit_slider($data){
  63. $error=$this->validate($data);
  64. if($error){
  65. return $error;
  66. }
  67. $r=M('PluginsSlider')->save($data);
  68. if($r){
  69. return array(
  70. 'status'=>'success',
  71. 'message'=>'修改成功',
  72. 'jump'=>U('PluginsSlider/index')
  73. );
  74. }else{
  75. return array(
  76. 'status'=>'fail',
  77. 'message'=>'修改失败',
  78. 'jump'=>U('PluginsSlider/index')
  79. );
  80. }
  81. }
  82. }
  83. ?>