ChannelSellPlatforms.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: hp
  5. * Date: 2017/11/21
  6. * Time: 8:59
  7. */
  8. namespace App\Modules\Channel\Models;
  9. use DB;
  10. use Illuminate\Database\Eloquent\Model;
  11. class ChannelSellPlatforms extends Model
  12. {
  13. protected $table = 'channel_sell_platforms';
  14. protected $fillable = ['id', 'name', 'code', 'desc', 'bill_type', 'created_at', 'updated_at'];
  15. /**
  16. * 根据id查找
  17. * @param $id
  18. * @return mixed
  19. */
  20. static function getById($id)
  21. {
  22. return self::where('id', $id)->first();
  23. }
  24. /**
  25. * 根据名称查找
  26. * @param $name
  27. * @return mixed
  28. */
  29. static function getByName($name)
  30. {
  31. return self::where('name', $name)->first();
  32. }
  33. /**
  34. * 根据code查找
  35. * @param $code
  36. * @return mixed
  37. */
  38. static function getByCode($code)
  39. {
  40. return self::where('code', $code)->first();
  41. }
  42. /**
  43. * 添加记录
  44. * @param $data
  45. * @return mixed
  46. */
  47. static function addInfo($data)
  48. {
  49. return self::create($data);
  50. }
  51. /**
  52. * 获取列表
  53. * @return mixed
  54. */
  55. static function getList()
  56. {
  57. return self::paginate();
  58. }
  59. /**
  60. * 根据id更新
  61. * @param $id id
  62. * @param array $params
  63. * @return mixed
  64. */
  65. static function updateById($id, $params = [])
  66. {
  67. if ($params) {
  68. return self::where('id', $id)->update($params);
  69. }
  70. }
  71. }