123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- use Encore\Admin\Traits\ModelTree;
- use Illuminate\Database\Eloquent\SoftDeletes;
- class Recruit extends Model
- {
- use SoftDeletes;
- protected $table = 'recruit';
- protected $guarded = [];
- //当前步骤
- public static $currentText = ['已结束','报名','审核','笔试','上机','面试','复试','体检','政审','公示'];
- //步骤和流程的处理
- public static function parse_index(Recruit $value)
- {
- //步骤处理
- $current = $value->current;
- $value->current_text = self::$currentText[$current];
- switch ($current){
- case '0':
- $value->current_time = "时间:" . date('m.d',strtotime($value->updated_at));
- break;
- case '1':
- if(empty($value->apply_start)){
- $value->current_time = '待定';
- }else if(empty($value->apply_end)){
- $value->current_time = date('m.d',strtotime($value->apply_start)) . '-' . '待定';
- }else{
- $value->current_time = date('m.d',strtotime($value->apply_start)) . '-' . date('m.d',strtotime($value->apply_end));
- }
- break;
- case '2':
- if(empty($value->audit_start)){
- $value->current_time = '待定';
- }else if(empty($value->audit_end)){
- $value->current_time = date('m.d',strtotime($value->audit_start)) . '-' . '待定';
- }else{
- $value->current_time = date('m.d',strtotime($value->audit_start)) . '-' . date('m.d',strtotime($value->audit_end));
- }
- break;
- case '3':
- if(empty($value->preliminary_start)){
- $value->current_time = '待定';
- }else if(empty($value->preliminary_end)){
- $value->current_time = date('m.d',strtotime($value->preliminary_start)) . '-' . '待定';
- }else{
- $value->current_time = date('m.d',strtotime($value->preliminary_start)) . '-' . date('m.d',strtotime($value->preliminary_end));
- }
- break;
- case '4':
- if(empty($value->computer_start)){
- $value->current_time = '待定';
- }else if(empty($value->computer_end)){
- $value->current_time = date('m.d',strtotime($value->computer_start)) . '-' . '待定';
- }else{
- $value->current_time = date('m.d',strtotime($value->computer_start)) . '-' . date('m.d',strtotime($value->computer_end));
- }
- break;
- case '5':
- if(empty($value->interview_start)){
- $value->current_time = '待定';
- }else if(empty($value->interview_end)){
- $value->current_time = date('m.d',strtotime($value->interview_start)) . '-' . '待定';
- }else{
- $value->current_time = date('m.d',strtotime($value->interview_start)) . '-' . date('m.d',strtotime($value->interview_end));
- }
- break;
- case '6':
- if(empty($value->reexamine_start)){
- $value->current_time = '待定';
- }else if(empty($value->reexamine_end)){
- $value->current_time = date('m.d',strtotime($value->reexamine_start)) . '-' . '待定';
- }else{
- $value->current_time = date('m.d',strtotime($value->reexamine_start)) . '-' . date('m.d',strtotime($value->reexamine_end));
- }
- break;
- case '7':
- if(empty($value->health_start)){
- $value->current_time = '待定';
- }else if(empty($value->health_end)){
- $value->current_time = date('m.d',strtotime($value->health_start)) . '-' . '待定';
- }else{
- $value->current_time = date('m.d',strtotime($value->health_start)) . '-' . date('m.d',strtotime($value->health_end));
- }
- break;
- case '8':
- if(empty($value->political_start)){
- $value->current_time = '待定';
- }else if(empty($value->political_end)){
- $value->current_time = date('m.d',strtotime($value->political_start)) . '-' . '待定';
- }else{
- $value->current_time = date('m.d',strtotime($value->political_start)) . '-' . date('m.d',strtotime($value->political_end));
- }
- break;
- case '9':
- if(empty($value->publicity_start)){
- $value->current_time = '待定';
- }else if(empty($value->publicity_end)){
- $value->current_time = date('m.d',strtotime($value->publicity_start)) . '-' . '待定';
- }else{
- $value->current_time = date('m.d',strtotime($value->publicity_start)) . '-' . date('m.d',strtotime($value->publicity_end));
- }
- break;
- }
- //流程处理
- $step_arr = explode(',',$value->step);
- $step_text = '';
- foreach ($step_arr as $k => $v) {
- if ((count($step_arr) - 1 ) == $k) {
- $step_text .= self::$currentText[$v];
- } else {
- $step_text .= self::$currentText[$v] . '->';
- }
- }
- $value->step_text = $step_text;
- return $value;
- }
- public static function parse_info(Recruit $value)
- {
- $step = explode(',',$value->step);
- $steps = [];
- foreach ($step as $v){
- switch ($v){
- case '0':
- $item['step_id'] = 10;
- $item['name'] = '已结束';
- $item['time'] = "时间:" . date('m.d',strtotime($value->updated_at));
- break;
- case '1':
- $item['step_id'] = 1;
- $item['name'] = '报名';
- if(empty($value->apply_start)){
- $time = '待定';
- }else if(empty($value->apply_end)){
- $time = date('m.d',strtotime($value->apply_start)) . '-' . '待定';
- }else{
- if ($value->apply_start == $value->apply_end) {
- $time = date('m.d',strtotime($value->apply_start));
- } else {
- $time = date('m.d',strtotime($value->apply_start)) . '-' . date('m.d',strtotime($value->apply_end));
- }
- }
- $item['time'] = $time;
- break;
- case '2':
- $item['step_id'] = 2;
- $item['name'] = '审核';
- if(empty($value->audit_start)){
- $time = '待定';
- }else if(empty($value->audit_end)){
- $time = date('m.d',strtotime($value->audit_start)) . '-' . '待定';
- }else{
- if ($value->audit_start == $value->audit_end) {
- $time = date('m.d',strtotime($value->audit_start));
- } else {
- $time = date('m.d',strtotime($value->audit_start)) . '-' . date('m.d',strtotime($value->audit_end));
- }
- }
- $item['time'] = $time;
- break;
- case '3':
- $item['step_id'] = 3;
- $item['name'] = '笔试';
- if(empty($value->preliminary_start)){
- $time = '待定';
- }else if(empty($value->preliminary_end)){
- $time = date('m.d',strtotime($value->preliminary_start)) . '-' . '待定';
- }else{
- $value->preliminary_start = date('m.d',strtotime($value->preliminary_start));
- $value->preliminary_end = date('m.d',strtotime($value->preliminary_end));
- if ($value->preliminary_start == $value->preliminary_end) {
- $time = $value->preliminary_start;
- } else {
- $time = $value->preliminary_start . '-' . $value->preliminary_end;
- }
- }
- $item['time'] = $time;
- break;
- case '4':
- $item['step_id'] = 4;
- $item['name'] = '上机';
- if(empty($value->computer_start)){
- $time = '待定';
- }else if(empty($value->computer_end)){
- $time = date('m.d',strtotime($value->computer_start)) . '-' . '待定';
- }else{
- if ($value->computer_start == $value->computer_end) {
- $time = date('m.d',strtotime($value->computer_start));
- } else {
- $time = date('m.d',strtotime($value->computer_start)) . '-' . date('m.d',strtotime($value->computer_end));
- }
- }
- $item['time'] = $time;
- break;
- case '5':
- $item['step_id'] = 5;
- $item['name'] = '面试';
- if(empty($value->interview_start)){
- $time = '待定';
- }else if(empty($value->interview_end)){
- $time = date('m.d',strtotime($value->interview_start)) . '-' . '待定';
- }else{
- if ($value->interview_start == $value->interview_end) {
- $time = date('m.d',strtotime($value->interview_start));
- } else {
- $time = date('m.d',strtotime($value->interview_start)) . '-' . date('m.d',strtotime($value->interview_end));
- }
- }
- $item['time'] = $time;
- break;
- case '6':
- $item['step_id'] = 6;
- $item['name'] = '复试';
- if(empty($value->reexamine_start)){
- $time = '待定';
- }else if(empty($value->reexamine_end)){
- $time = date('m.d',strtotime($value->reexamine_start)) . '-' . '待定';
- }else{
- if ($value->reexamine_start == $value->reexamine_end) {
- $time = date('m.d',strtotime($value->reexamine_start));
- } else {
- $time = date('m.d',strtotime($value->reexamine_start)) . '-' . date('m.d',strtotime($value->reexamine_end));
- }
- }
- $item['time'] = $time;
- break;
- case '7':
- $item['step_id'] = 7;
- $item['name'] = '体检';
- if(empty($value->health_start)){
- $time = '待定';
- }else if(empty($value->health_end)){
- $time = date('m.d',strtotime($value->health_start)) . '-' . '待定';
- }else{
- if ($value->health_start == $value->health_end) {
- $time = date('m.d',strtotime($value->health_start));
- } else {
- $time = date('m.d',strtotime($value->health_start)) . '-' . date('m.d',strtotime($value->health_end));
- }
- }
- $item['time'] = $time;
- break;
- case '8':
- $item['step_id'] = 8;
- $item['name'] = '政审';
- if(empty($value->political_start)){
- $time = '待定';
- }else if(empty($value->political_end)){
- $time = date('m.d',strtotime($value->political_start)) . '-' . '待定';
- }else{
- if ($value->political_start == $value->political_end) {
- $time = date('m.d',strtotime($value->political_start));
- } else {
- $time = date('m.d',strtotime($value->political_start)) . '-' . date('m.d',strtotime($value->political_end));
- }
- }
- $item['time'] = $time;
- break;
- case '9':
- $item['step_id'] = 9;
- $item['name'] = '公示';
- if(empty($value->publicity_start)){
- $time = '待定';
- }else if(empty($value->publicity_end)){
- $time = date('m.d',strtotime($value->publicity_start)) . '-' . '待定';
- }else{
- if ($value->publicity_start == $value->publicity_end) {
- $time = date('m.d',strtotime($value->publicity_start));
- } else {
- $time = date('m.d',strtotime($value->publicity_start)) . '-' . date('m.d',strtotime($value->publicity_end));
- }
- }
- $item['time'] = $time;
- break;
- }
- array_push($steps,$item);
- }
- $value->steps = $steps;
- if($value->current == '0'){
- $value->current = '10';
- }
- $value->introduction = htmlspecialchars_decode($value->introduction, ENT_QUOTES);
- $time = time();
- // 报名中
- if (strtotime($value->audit_start) < $time && strtotime($value->audit_end) > $time) {
- $value->isApply = 1;
- } else {
- $value->isApply = 0;
- }
- return $value;
- }
- }
|