|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Coyote\Http\Controllers\Job; |
|
4
|
|
|
|
|
5
|
|
|
use Coyote\Http\Controllers\Controller; |
|
6
|
|
|
use Coyote\Repositories\Contracts\JobRepositoryInterface as JobRepository; |
|
7
|
|
|
use Coyote\Repositories\Contracts\TagRepositoryInterface as TagRepository; |
|
8
|
|
|
use Coyote\Services\Elasticsearch\Builders\Job\FbBuilder; |
|
9
|
|
|
use Coyote\Tag; |
|
10
|
|
|
|
|
11
|
|
|
class FbController extends Controller |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var JobRepository |
|
15
|
|
|
*/ |
|
16
|
|
|
private $job; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var TagRepository |
|
20
|
|
|
*/ |
|
21
|
|
|
private $tag; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @param TagRepository $tag |
|
25
|
|
|
* @param JobRepository $job |
|
26
|
|
|
*/ |
|
27
|
|
|
public function __construct(TagRepository $tag, JobRepository $job) |
|
28
|
|
|
{ |
|
29
|
|
|
parent::__construct(); |
|
30
|
|
|
|
|
31
|
|
|
$this->tag = $tag; |
|
32
|
|
|
$this->job = $job; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
|
37
|
|
|
*/ |
|
38
|
|
|
public function showByCategory() |
|
39
|
|
|
{ |
|
40
|
|
|
$tags = $this->tag->findAllBy('category_id', Tag\Category::LANGUAGE); |
|
41
|
|
|
$result = $hashTags = $count = []; |
|
42
|
|
|
|
|
43
|
|
|
foreach ($tags as $tag) { |
|
44
|
|
|
$builder = new FbBuilder(); |
|
45
|
|
|
$builder->setLanguage($tag->name); |
|
46
|
|
|
$builder->onlyFromLastWeek(); |
|
47
|
|
|
|
|
48
|
|
|
$source = $this->job->search($builder)->getSource(); |
|
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
if ($source) { |
|
51
|
|
|
$hashTags[] = '#' . $tag->name; |
|
52
|
|
|
|
|
53
|
|
|
$result[$tag->real_name] = $source; |
|
54
|
|
|
$count[$tag->real_name] = count($result[$tag->real_name]); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
array_multisort($count, SORT_DESC, $result); |
|
59
|
|
|
|
|
60
|
|
|
return view('job.fb_category', ['hash_tags' => $hashTags, 'result' => $result]); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
|
65
|
|
|
*/ |
|
66
|
|
|
public function showByKeyword() |
|
67
|
|
|
{ |
|
68
|
|
|
$builder = new FbBuilder(); |
|
69
|
|
|
$builder->setLanguage($this->request->input('q')); |
|
|
|
|
|
|
70
|
|
|
|
|
71
|
|
|
$source = $this->job->search($builder)->getSource(); |
|
72
|
|
|
$result = []; |
|
73
|
|
|
|
|
74
|
|
|
foreach ($source as $job) { |
|
75
|
|
|
foreach ($job->get('locations') as $location) { |
|
76
|
|
|
$result[$location->get('city')][] = $job; |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
return view('job.fb_keyword', ['result' => $result]); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|