AdEmployerController.php
1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace App\Http\Controllers;
use App\Models\Ad_employer;
use App\Models\Employer;
use App\Models\Static_ad;
use App\Models\Static_worker;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
class AdEmployerController extends Controller
{
public function Ad_employer(Ad_employer $ad_employer) {
$get_date = date('Y.m');
$c = Static_ad::query()->where('year_month', '=', $get_date)
->where('ad_employer_id', '=', $ad_employer->id)
->get();
if ($c->count() > 0) {
$upd = Static_ad::find($c[0]->id);
$upd->lookin = $upd->lookin + 1;
$upd->save();
} else {
$crt = new Static_ad();
$crt->lookin = 1;
$crt->year_month = $get_date;
$crt->ad_employer_id = $ad_employer->id;
$crt->save();
}
$stat = Static_ad::query()->
where('year_month', '=', $get_date)->
where('ad_employer_id', '=', $ad_employer->id)
->get();
return view('public.ad.profile', compact('ad_employer', 'stat'));
}
}