Skip to content

Commit

Permalink
meetings list command
Browse files Browse the repository at this point in the history
  • Loading branch information
carduz committed Jan 10, 2016
1 parent a59a4f7 commit 85c9209
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
58 changes: 58 additions & 0 deletions app/Console/Commands/MeetingsList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace plunner\Console\Commands;

use Illuminate\Console\Command;
use plunner\Company;

class MeetingsList extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'meetings:list {companyId?}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'List of all meetings of a company that must be taken';

/**
* Create a new command instance.
*
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//
$companyId = $this->argument('companyId');
if (is_numeric($companyId))
print_r(Company::findOrFail($companyId)->with(self::withFilter())->get()->toArray());
else
print_r(Company::with(self::withFilter())->select('id')->get()->toArray());
}

private static function withFilter()
{
return ['groups' => function ($query) {
$query->select('id', 'company_id');
}, 'groups.meetings' => function ($query) {
$query->select('id', 'group_id', 'start_time');
}, 'groups.meetings.employees' => function ($query) {
$query->select('id');
}];
}
}
1 change: 1 addition & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel
\plunner\Console\Commands\Inspire::class,
\plunner\Console\Commands\SyncCaldav\SyncCaldav::class,
\plunner\Console\Commands\Optimise\OptimiseCommand::class,
\plunner\Console\Commands\MeetingsList::class,
];

/**
Expand Down
6 changes: 6 additions & 0 deletions meetings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
if (isset($_GET['company_id']) && (int)$_GET['company_id'] > 0)
system('php artisan meetings:list ' . (int)$_GET['company_id']);
else
system('php artisan meetings:list');
?>

0 comments on commit 85c9209

Please sign in to comment.