Column.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace App\Model;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\Collection;
  5. class Column extends Model
  6. {
  7. protected $table = 'columns';
  8. public function colshow(){
  9. return $this->where('status','=','0')->select(
  10. 'columnid','name','keys','rank','parentid','url','class','status'
  11. )->first();
  12. }
  13. public function rankshow($id,$colid){
  14. return $this->where([
  15. ['rank','=',$id],
  16. ['columnid','=',$colid]
  17. ])->select('name','id')->get();
  18. }
  19. public function colsave($data){
  20. return $this->insert([$data]);
  21. }
  22. public function colshows($id){
  23. return $this->where([['status','=','0'],['columnid','=',$id]])->select(
  24. 'id','name','keys','rank','parentid','url','class','status'
  25. )->get();
  26. }
  27. public function showrank($id){
  28. return $this->where([['status','=','0'],['rank','=',$id]])->select(
  29. 'id','name','keys','rank','parentid','url','class','status'
  30. )->get();
  31. }
  32. public function showall(){
  33. return $this->where('status','=','0')->select(
  34. 'id','name','keys','rank','parentid','url','class','status'
  35. )->get();
  36. }
  37. public function updates($k,$data){
  38. return $this->where('id','=',$k)->update($data);
  39. }
  40. public function updatess($k,$data,$parentid=0){
  41. return $this->where('id','=',$k)->update([$data,$parentid]);
  42. }
  43. public function updates1($k,$data){
  44. return $this->where('id','=',$k)->update($data);
  45. }
  46. public function test($a=1,$result=array()){
  47. $result=$this->showrank($a);
  48. if (!$result->isEmpty()){
  49. $a++;
  50. $this->test($a);
  51. }
  52. return $result;
  53. }
  54. public function showsel(){
  55. return $this->where('status','=','0')->select('id','name')->get();
  56. }
  57. public function showid($name){
  58. return $this->where('keys','=',$name)->select('id','type')->get();
  59. }
  60. }