Skip to content

Commit

Permalink
feat: first
Browse files Browse the repository at this point in the history
  • Loading branch information
xiCO2k committed Jan 27, 2022
0 parents commit 5045dd9
Show file tree
Hide file tree
Showing 30 changed files with 6,991 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_style = space
indent_size = 2
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* text=auto
/.github export-ignore
.styleci.yml export-ignore
.scrutinizer.yml export-ignore
BACKERS.md export-ignore
CONTRIBUTING.md export-ignore
CHANGELOG.md export-ignore
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/vendor
/.idea
/.vscode
/.vagrant
.phpunit.result.cache
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<p align="center">
<img title="Laravel Zero" height="100" src="https://raw.githubusercontent.com/laravel-zero/docs/master/images/logo/laravel-zero-readme.png" />
</p>

<p align="center">
<a href="https://github.com/laravel-zero/framework/actions"><img src="https://img.shields.io/github/workflow/status/laravel-zero/framework/Tests.svg" alt="Build Status"></img></a>
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://img.shields.io/packagist/dt/laravel-zero/framework.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://img.shields.io/packagist/v/laravel-zero/framework.svg?label=stable" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://img.shields.io/packagist/l/laravel-zero/framework.svg" alt="License"></a>
</p>

<h4> <center>This is a <bold>community project</bold> and not an official Laravel one </center></h4>

Laravel Zero was created by, and is maintained by [Nuno Maduro](https://github.com/nunomaduro), and is a micro-framework that provides an elegant starting point for your console application. It is an **unofficial** and customized version of Laravel optimized for building command-line applications.

- Built on top of the [Laravel](https://laravel.com) components.
- Optional installation of Laravel [Eloquent](https://laravel-zero.com/docs/database/), Laravel [Logging](https://laravel-zero.com/docs/logging/) and many others.
- Supports interactive [menus](https://laravel-zero.com/docs/build-interactive-menus/) and [desktop notifications](https://laravel-zero.com/docs/send-desktop-notifications/) on Linux, Windows & MacOS.
- Ships with a [Scheduler](https://laravel-zero.com/docs/task-scheduling/) and a [Standalone Compiler](https://laravel-zero.com/docs/build-a-standalone-application/).
- Integration with [Collision](https://github.com/nunomaduro/collision) - Beautiful error reporting

------

## Documentation

For full documentation, visit [laravel-zero.com](https://laravel-zero.com/).

## Support the development
**Do you like this project? Support it by donating**

- PayPal: [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L)
- Patreon: [Donate](https://www.patreon.com/nunomaduro)

## License

Laravel Zero is an open-source software licensed under the MIT license.
Empty file added app/Commands/.gitkeep
Empty file.
164 changes: 164 additions & 0 deletions app/Commands/GamesCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<?php

namespace App\Commands;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Support\Facades\Http;
use LaravelZero\Framework\Commands\Command;
use function Termwind\{render, live, select, terminal};

class GamesCommand extends Command
{
protected $signature = 'games';

public function handle()
{
$select = select(fn ($options, $active) => view('games', [
'leagues' => $this->getAvailableGames(),
'active' => $active,
]), collect($this->getAvailableGames())->pluck('games')->flatten(1)->toArray());

$select->refreshEvery(seconds: 1);
$select->render();

$active = $select->getActive();

terminal()->clear();

live(fn () => view('game', [
'timeLabel' => '1st half',
'time' => date('i:s'),
'score' => $this->getScores(),
'events' => $this->getEvents(),
]))->refreshEvery(seconds: 1);
}

private function getAvailableGames()
{
return [[
'country' => 'Italy',
'name' => 'Serie A',
'games' => [[
'value' => 1,
'time' => now()->subMinutes(87)->subSeconds(12)->format('i:s'),
'home' => [
'team' => 'Juventus',
'total' => 0,
],
'away' => [
'team' => 'Cagliari',
'total' => 0,
],
]]
], [

'country' => 'Netherlands',
'name' => 'Eredivisie',
'games' => [[
'value' => 3,
'time' => now()->subMinutes(42)->subSeconds(21)->format('i:s'),
'home' => [
'team' => 'AZ Alkmaar',
'total' => 0,
],
'away' => [
'team' => 'Groningen',
'total' => 0,
],
]]
], [
'country' => 'Germany',
'name' => 'Bundesliga',
'games' => [[
'value' => 2,
'time' => now()->format('i:s'),
'home' => [
'team' => 'B. Monchengladbach',
'total' => 2,
],
'away' => [
'team' => 'Eintracht Frankfurt',
'total' => 1,
],
]]
]];
}

private function getScores(): array
{
return [
'home' => [
'team' => 'B. Monchengladbach',
'total' => 2,
],
'away' => [
'team' => 'Eintracht Frankfurt',
'total' => 1,
],
];
}

private function getEvents(): array
{
return [[
'team' => 'home',
'type' => 'goal',
'minute' => 6,
'player' => 'Neuhaus F.',
'extra' => 'Scally J.',
], [
'team' => 'away',
'type' => 'sub',
'minute' => 28,
'out' => 'Jakic K.',
'in' => 'Rode S.',
], [
'team' => 'away',
'type' => 'card',
'card' => 'yellow',
'minute' => 39,
'player' => 'Tuta',
], [
'team' => 'away',
'type' => 'card',
'card' => 'yellow',
'minute' => 42,
'player' => 'Borre R.',
], [
'team' => 'home',
'type' => 'card',
'card' => 'yellow',
'minute' => 43,
'player' => 'Embolo B.',
], [
'team' => 'away',
'type' => 'goal',
'minute' => 45,
'player' => 'Borre R.',
], [
'type' => 'halftime',
], [
'team' => 'home',
'type' => 'goal',
'minute' => 50,
'player' => 'Lindstrom J.',
], [
'team' => 'home',
'type' => 'goal',
'minute' => 54,
'player' => 'Bensebaini R.',
'extra' => '(Penalti)',
], [
'team' => 'away',
'type' => 'goal',
'minute' => 55,
'player' => 'Kamada D.',
], [
'team' => 'away',
'type' => 'card',
'card' => 'red',
'minute' => 76,
'player' => 'Borre R.',
]];
}
}
52 changes: 52 additions & 0 deletions app/Commands/InspireCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace App\Commands;

use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;
use function Termwind\{render};

class InspireCommand extends Command
{
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'inspire {name=Artisan}';

/**
* The description of the command.
*
* @var string
*/
protected $description = 'Display an inspiring quote';

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
render(<<<'HTML'
<div class="py-1 ml-2">
<div class="px-1 bg-blue-300 text-black">Laravel Zero</div>
<em class="ml-1">
Simplicity is the ultimate sophistication.
</em>
</div>
HTML);
}

/**
* Define the command's schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
public function schedule(Schedule $schedule)
{
// $schedule->command(static::class)->everyMinute();
}
}
28 changes: 28 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}

/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
53 changes: 53 additions & 0 deletions application
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env php
<?php

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/

$autoloader = require file_exists(__DIR__.'/vendor/autoload.php') ? __DIR__.'/vendor/autoload.php' : __DIR__.'/../../autoload.php';

$app = require_once __DIR__.'/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/

$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);

$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);

/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/

$kernel->terminate($input, $status);

exit($status);
Loading

0 comments on commit 5045dd9

Please sign in to comment.