File tree Expand file tree Collapse file tree 3 files changed +65
-0
lines changed
Expand file tree Collapse file tree 3 files changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace plunner \Console \Commands ;
4+
5+ use Illuminate \Console \Command ;
6+ use plunner \Company ;
7+
8+ class MeetingsList extends Command
9+ {
10+ /**
11+ * The name and signature of the console command.
12+ *
13+ * @var string
14+ */
15+ protected $ signature = 'meetings:list {companyId?} ' ;
16+
17+ /**
18+ * The console command description.
19+ *
20+ * @var string
21+ */
22+ protected $ description = 'List of all meetings of a company that must be taken ' ;
23+
24+ /**
25+ * Create a new command instance.
26+ *
27+ */
28+ public function __construct ()
29+ {
30+ parent ::__construct ();
31+ }
32+
33+ /**
34+ * Execute the console command.
35+ *
36+ * @return mixed
37+ */
38+ public function handle ()
39+ {
40+ //
41+ $ companyId = $ this ->argument ('companyId ' );
42+ if (is_numeric ($ companyId ))
43+ print_r (Company::findOrFail ($ companyId )->with (self ::withFilter ())->get ()->toArray ());
44+ else
45+ print_r (Company::with (self ::withFilter ())->select ('id ' )->get ()->toArray ());
46+ }
47+
48+ private static function withFilter ()
49+ {
50+ return ['groups ' => function ($ query ) {
51+ $ query ->select ('id ' , 'company_id ' );
52+ }, 'groups.meetings ' => function ($ query ) {
53+ $ query ->select ('id ' , 'group_id ' , 'start_time ' );
54+ }, 'groups.meetings.employees ' => function ($ query ) {
55+ $ query ->select ('id ' );
56+ }];
57+ }
58+ }
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel
1616 \plunner \Console \Commands \Inspire::class,
1717 \plunner \Console \Commands \SyncCaldav \SyncCaldav::class,
1818 \plunner \Console \Commands \Optimise \OptimiseCommand::class,
19+ \plunner \Console \Commands \MeetingsList::class,
1920 ];
2021
2122 /**
Original file line number Diff line number Diff line change 1+ <?php
2+ if (isset ($ _GET ['company_id ' ]) && (int )$ _GET ['company_id ' ] > 0 )
3+ system ('php artisan meetings:list ' . (int )$ _GET ['company_id ' ]);
4+ else
5+ system ('php artisan meetings:list ' );
6+ ?>
You can’t perform that action at this time.
0 commit comments