1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace plunner\Http\Controllers\Employees\Meetings; |
4
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
6
|
|
|
use plunner\Http\Controllers\Controller; |
7
|
|
|
use plunner\Http\Requests; |
8
|
|
|
use plunner\Meeting; |
9
|
|
|
|
10
|
|
|
class MeetingsController extends Controller |
11
|
|
|
{ |
12
|
15 |
|
public function __construct() |
13
|
|
|
{ |
14
|
15 |
|
config(['auth.model' => \plunner\Employee::class]); |
15
|
15 |
|
config(['jwt.user' => \plunner\Employee::class]); |
16
|
15 |
|
$this->middleware('jwt.authandrefresh:mode-en'); |
17
|
15 |
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Display a listing of the resource. |
21
|
|
|
* |
22
|
|
|
* @param Request $request needed for get query to get only current planed meetings |
23
|
|
|
* @return \Illuminate\Http\Response |
24
|
|
|
*/ |
25
|
6 |
|
public function index(Request $request) |
26
|
|
|
{ |
27
|
6 |
|
$employee = \Auth::user(); |
28
|
6 |
|
$meetings = $employee->meetings(); |
29
|
6 |
|
if ($request->query('current')) |
30
|
3 |
|
$meetings->where(function ($query) { //parenthesis for conditions ...(C1 OR C2)... |
31
|
3 |
|
$query->where('start_time', '=', NULL);//to be planned |
32
|
|
|
//datetime to consider timezone, don't use mysql NOW() |
33
|
3 |
|
$query->orWhere('start_time', '>=', new \DateTime());//planned |
34
|
3 |
|
}); |
35
|
6 |
|
return $meetings->get(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Display the specified resource. |
40
|
|
|
* |
41
|
|
|
* @param int $id |
42
|
|
|
* @return \Illuminate\Http\Response |
43
|
|
|
*/ |
44
|
6 |
|
public function show($id) |
45
|
|
|
{ |
46
|
6 |
|
$meeting = Meeting::findOrFail($id); |
47
|
6 |
|
$this->authorize($meeting); |
48
|
3 |
|
return $meeting; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Store a newly created resource in storage. |
53
|
|
|
* |
54
|
|
|
* @param int $meetingId |
55
|
|
|
* @return static |
56
|
|
|
*/ |
57
|
|
|
public function showImage($meetingId) |
58
|
|
|
{ |
59
|
|
|
$meeting = Group::findOrFail($meetingId); |
60
|
|
|
$this->authorize($meeting); |
61
|
|
|
$ret = self::getImg($meeting); |
62
|
|
|
$blank = storage_path('img/meetings.jpg'); |
63
|
|
|
if ($ret === false) |
64
|
|
|
return (new Response(file_get_contents($blank), 200)) |
65
|
|
|
->header('Content-Type', 'image/jpeg'); |
66
|
|
|
return (new Response($ret, 200)) |
67
|
|
|
->header('Content-Type', 'image/jpeg'); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
private static function getImg(Meeting $meeting) |
71
|
|
|
{ |
72
|
|
|
$name = 'meetings/' . $meeting->id; |
73
|
|
|
if (!\Storage::exists($name)) |
|
|
|
|
74
|
|
|
return false; |
75
|
|
|
return \Storage::get($name); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.