Skip to content

Commit

Permalink
Merge pull request #26 from t29mato/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
t29mato authored Aug 21, 2020
2 parents af8dab1 + 529ba8a commit a4cbe06
Show file tree
Hide file tree
Showing 12 changed files with 1,985 additions and 706 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
```
$ docker-compose up --build
$ docker-compose exec app composer install
$ docker-compose exec app php artisan migrate
$ touch database/database.sqlite
$ docker-compose exec app php artisan migrate
```

## cron設定
Expand Down
21 changes: 21 additions & 0 deletions app/Http/Controllers/OceanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

use Illuminate\Http\Request;
use App\Ocean;
use App\OceanHistory;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Config;

class OceanController extends Controller
{
Expand All @@ -16,6 +18,7 @@ public function index()
$dtNow = new Carbon();
foreach ($oceans as $index => $ocean) {
array_push($oceanFormated, [
'id' => $ocean->id,
'name' => $ocean->nickname ? $ocean->nickname : $ocean->name,
'transparency' => $ocean->transparency,
'transparencyLevel' => $this->calculateTransparencyLevel(
Expand All @@ -34,6 +37,24 @@ public function index()
]);
}

public function ocean($ocean_id)
{
$now = new Carbon();
$oceans = OceanHistory::where('ocean_histories.ocean_id', '=', $ocean_id)
->where('ocean_histories.created_at', '>', $now->subYear()->format('Y-m-d'))
->join('oceans', 'ocean_id', '=', 'oceans.id')
->select('oceans.name', 'ocean_histories.transparency', 'oceans.id', 'ocean_histories.created_at')
->orderBy('ocean_histories.created_at', 'desc')
->get();
foreach ($oceans as $index => $ocean) {
// var_dump($ocean->name, $ocean->transparency, $ocean->created_at->format('Y-m-d'));
// var_dump($ocean->created_at->format('Y-m-d') . ': ' . $ocean->transparency . '<br>');
}
return view('ocean', [
'oceans' => $oceans
]);
}

private function calculateTransparencyInt(string $transparency): int
{
$result = 0;
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"predis/predis": "^1.1"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.4",
"facade/ignition": "^1.4",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
Expand Down
Loading

0 comments on commit a4cbe06

Please sign in to comment.