Skip to content

Commit 85c9209

Browse files
committed
meetings list command
1 parent a59a4f7 commit 85c9209

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
}

app/Console/Kernel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
/**

meetings.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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+
?>

0 commit comments

Comments
 (0)