ActivityWorkStation.php 885 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class ActivityWorkStation extends Model
  5. {
  6. // 获取站点token
  7. public static function getToekn($wsId, $wsType, $wsName ='')
  8. {
  9. $res = self::where('work_station_id', $wsId)
  10. ->where('work_station_type', $wsType)
  11. ->first();
  12. if($res) {
  13. if($wsName){
  14. $res->name = $wsName;
  15. $res->token = md5($wsId.'.'.$wsType.'.'.$wsName);
  16. $res->save();
  17. }
  18. }else {
  19. $model = new self();
  20. $model->name = $wsName;
  21. $model->work_station_type = $wsType;
  22. $model->work_station_id = $wsId;
  23. $model->token = md5($wsId.'.'.$wsType.'.'.$wsName);
  24. if($model->save()){
  25. $res= $model;
  26. }
  27. }
  28. return $res;
  29. }
  30. }