Device.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace App\Http\Models;
  3. use Eloquent;
  4. use Illuminate\Database\Eloquent\Builder;
  5. use Illuminate\Database\Eloquent\Model;
  6. /**
  7. * 订阅设备列表
  8. * Class Device
  9. *
  10. * @package App\Http\Models
  11. * @mixin Eloquent
  12. * @property int $id
  13. * @property int $type 类型:0-兼容、1-Shadowsocks(R)、2-V2Ray
  14. * @property int $platform 所属平台:0-其他、1-iOS、2-Android、3-Mac、4-Windows、5-Linux
  15. * @property string $name 设备名称
  16. * @property int $status 状态:0-禁止订阅、1-允许订阅
  17. * @property string $header 请求时头部的识别特征码
  18. * @property-read mixed $platform_label
  19. * @property-read mixed $type_label
  20. * @method static Builder|Device newModelQuery()
  21. * @method static Builder|Device newQuery()
  22. * @method static Builder|Device query()
  23. * @method static Builder|Device whereHeader($value)
  24. * @method static Builder|Device whereId($value)
  25. * @method static Builder|Device whereName($value)
  26. * @method static Builder|Device wherePlatform($value)
  27. * @method static Builder|Device whereStatus($value)
  28. * @method static Builder|Device whereType($value)
  29. */
  30. class Device extends Model
  31. {
  32. public $timestamps = FALSE;
  33. protected $table = 'device';
  34. protected $primaryKey = 'id';
  35. function getTypeLabelAttribute()
  36. {
  37. switch($this->attributes['type']){
  38. case 1:
  39. $type_label = '<span class="label label-danger"> Shadowsocks(R) </span>';
  40. break;
  41. case 2:
  42. $type_label = '<span class="label label-danger"> V2Ray </span>';
  43. break;
  44. default:
  45. $type_label = '<span class="label label-default"> 其他 </span>';
  46. }
  47. return $type_label;
  48. }
  49. function getPlatformLabelAttribute()
  50. {
  51. switch($this->attributes['platform']){
  52. case 1:
  53. $platform_label = '<i class="fa fa-apple"></i> iOS';
  54. break;
  55. case 2:
  56. $platform_label = '<i class="fa fa-android"></i> Android';
  57. break;
  58. case 3:
  59. $platform_label = '<i class="fa fa-apple"></i> Mac';
  60. break;
  61. case 4:
  62. $platform_label = '<i class="fa fa-windows"></i> Windows';
  63. break;
  64. case 5:
  65. $platform_label = '<i class="fa fa-linux"></i> Linux';
  66. break;
  67. case 0:
  68. default:
  69. $platform_label = '其他';
  70. }
  71. return $platform_label;
  72. }
  73. }