Commit ae72540e authored by K9260's avatar K9260 🎅🏼

Merge

parents 624ed015 5967cd64
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
docker-compose.yml
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
docker-compose.yml
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Age extends Model
{
protected $fillable = [
'minage',
'maxage',
'gender',
];
}
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
class AuthController extends Controller
{
/**
* Create a new AuthController instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth:api', ['except' => ['login']]);
}
/**
* Get a JWT via given credentials.
*
* @return \Illuminate\Http\JsonResponse
*/
public function login()
{
$credentials = request(['email', 'password']);
if (! $token = auth('api')->attempt($credentials)) {
return response()->json(['error' => 'Unauthorized'], 401);
}
return $this->respondWithToken($token);
}
/**
* Get the authenticated User.
*
* @return \Illuminate\Http\JsonResponse
*/
public function me()
{
return response()->json(auth('api')->user());
}
/**
* Log the user out (Invalidate the token).
*
* @return \Illuminate\Http\JsonResponse
*/
public function logout()
{
auth()->logout();
return response()->json(['message' => 'Successfully logged out']);
}
/**
* Refresh a token.
*
* @return \Illuminate\Http\JsonResponse
*/
public function refresh()
{
return $this->respondWithToken(auth('api')->refresh());
}
/**
* Get the token array structure.
*
* @param string $token
*
* @return \Illuminate\Http\JsonResponse
*/
protected function respondWithToken($token)
{
return response()->json([
'access_token' => $token,
'user' => $this->guard()->user(),
'token_type' => 'bearer',
'expires_in' => auth('api')->factory()->getTTL() * 60
]);
}
public function guard() {
return Auth::Guard('api');
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class DBController extends Controller
{
public function populatevaatetable(){
$path =public_path();
$jsonFile=$path ."/json/vaatecomp.json";
$jsondata = file_get_contents($jsonFile);
$data = json_decode($jsondata, true);
foreach ($data as $row) {
DB::insert('insert into vaatecomp (vaate_id, age_id, temperature_id) values (?, ?, ?)', [$row["vaate"], $row["age"], $row["temperature"]]);
}
}
public function populatevaatetable2(){
$path =public_path();
$jsonFile=$path ."/json/vaate.json";
$jsondata = file_get_contents($jsonFile);
$data = json_decode($jsondata, true);
foreach ($data as $row) {
DB::insert('insert into vaate (vaate, tyyppi_id) values (?, ?)', [$row["vaate"], $row["tyyppi_id"]]);
}
}
public function populatetablet(){
$path =public_path();
$jsonFile=$path ."/json/vaate.json";
$jsondata = file_get_contents($jsonFile);
$data = json_decode($jsondata, true);
foreach ($data as $row) {
DB::insert('insert into vaate (vaate, tyyppi_id) values (?, ?)', [$row["vaate"], $row["tyyppi_id"]]);
}
DB::insert('insert into tyyppi (tyyppi) values (?)', ["hattu"]);
DB::insert('insert into tyyppi (tyyppi) values (?)', ["paita"]);
DB::insert('insert into tyyppi (tyyppi) values (?)', ["housut"]);
DB::insert('insert into tyyppi (tyyppi) values (?)', ["kengät"]);
DB::insert('insert into tyyppi (tyyppi) values (?)', ["hanskat"]);
DB::insert('insert into tyyppi (tyyppi) values (?)', ["kokopuku"]);
DB::insert('insert into tyyppi (tyyppi) values (?)', ["sukat",]);
DB::insert('insert into tyyppi (tyyppi) values (?)', ["kaula"]);
DB::insert('insert into tyyppi (tyyppi) values (?)', ["kokopuku_a"]);
DB::insert('insert into tyyppi (tyyppi) values (?)', ["silmät"]);
DB::insert('insert into tyyppi (tyyppi) values (?)', ["takki"]);
DB::insert('insert into age (minage, maxage, gender) values (?, ?, ?)', [0, 1, "B"]);
DB::insert('insert into age (minage, maxage, gender) values (?, ?, ?)', [2, 10, "B"]);
DB::insert('insert into age (minage, maxage, gender) values (?, ?, ?)', [11, 17, "B"]);
DB::insert('insert into age (minage, maxage, gender) values (?, ?, ?)', [18, 70, "N"]);
DB::insert('insert into age (minage, maxage, gender) values (?, ?, ?)', [18, 70, "M"]);
DB::insert('insert into age (minage, maxage, gender) values (?, ?, ?)', [71, 999, "B"]);
DB::insert('insert into temperature (mintemperature, maxtemperature) values (?, ?)', [20, 30]);
DB::insert('insert into temperature (mintemperature, maxtemperature) values (?, ?)', [10, 19]);
DB::insert('insert into temperature (mintemperature, maxtemperature) values (?, ?)', [0, 9]);
DB::insert('insert into temperature (mintemperature, maxtemperature) values (?, ?)', [-10, 0]);
DB::insert('insert into temperature (mintemperature, maxtemperature) values (?, ?)', [-20, -29]);
DB::insert('insert into temperature (mintemperature, maxtemperature) values (?, ?)', [-100, -30]);
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Location;
use Illuminate\Support\Facades\DB;
class LocationController extends Controller
{
public function push(Request $request){
$input = $request->all();
foreach($input as $inp){
$locations = new Location();
$locations->kunta = $inp['Kunta'];
$locations->lat = $inp['Latitude'];
$locations->lon = $inp['Longitude'];
$locations->save();
}
return response()->json($input);
}
public function pull(Request $request){
$kunta = $request->input('kunta');
$locations = DB::table('locations')->select(array('kunta', 'lat', 'lon'))->where('kunta', 'like', $kunta . '%')->get();
return $locations;
}
public function populatedb(){
$path =public_path();
$jsonFile=$path ."/json/locations.json";
$jsondata = file_get_contents($jsonFile);
$data = json_decode($jsondata, true);
foreach ($data as $row) {
DB::insert('insert into locations (kunta, lat, lon) values (?, ?, ?)', [$row["Kunta"], $row["Latitude"], $row["Longitude"]]);
}
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Location;
use Illuminate\Support\Facades\DB;
class LocationController extends Controller
{
public function push(Request $request){
$input = $request->all();
foreach($input as $inp){
$locations = new Location();
$locations->kunta = $inp['Kunta'];
$locations->lat = $inp['Latitude'];
$locations->lon = $inp['Longitude'];
$locations->save();
}
return response()->json($input);
}
public function pull(Request $request){
$kunta = $request->input('kunta');
$locations = DB::table('locations')->select(array('kunta', 'lat', 'lon'))->where('kunta', 'like', $kunta . '%')->get();
return $locations;
}
public function pullclothes(Request $request){
$age = $request->input('age');
$temperature = $request->input('temperature');
if(!empty($request->input('gender'))){
$gender = $request->input('gender');
}
else {
$gender = "B";
}
$vaatteet = DB::select( DB::raw("select vaate.vaate,tyyppi.tyyppi from vaate inner join tyyppi on tyyppi.id=vaate.tyyppi_id where vaate.id in (select vaatecomp.vaate_id from vaatecomp where vaatecomp.age_id = (select id from age where minage<= :age and maxage >= :age2 and gender = :gender) and vaatecomp.temperature_id = (select id from temperature where mintemperature <= :temperature and maxtemperature >= :temperature2))"),array('age' => $age, 'age2' => $age, 'gender' => $gender, 'temperature' => $temperature, 'temperature2' => $temperature));
return $vaatteet;
}
public function populatedb(){
$path =public_path();
$jsonFile=$path ."/json/locations.json";
$jsondata = file_get_contents($jsonFile);
$data = json_decode($jsondata, true);
foreach ($data as $row) {
DB::insert('insert into locations (kunta, lat, lon) values (?, ?, ?)', [$row["Kunta"], $row["Latitude"], $row["Longitude"]]);
}
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class SpaController extends Controller
{
public function index()
{
return view('spa');
}
}
\ No newline at end of file
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DmitryIvanov\DarkSkyApi\DarkSkyApi;
class WeatherController extends Controller
{
public function push(Request $request){
$lat = $request->input('lat');
$lon = $request->input('lon');
//if(db_age > 1 h)
$forecast = (new DarkSkyApi('78d784f058add542a26b103706a511b2'))
->location($lat, $lon)
->units('si')
->language('fi')
->extend('hourly')
->forecast('hourly');
//kantaan
//else
//hae tiedot kannasta
//$timeMachine = (new DarkSkyApi('78d784f058add542a26b103706a511b2'))
// ->location(46.482, 30.723)
// ->units('si')
// ->language('fi')
// ->timeMachine('2019-03-22', ['daily', 'flags']);
//$b=null;
$a =array();
foreach ($forecast->hourly()->data() as $value){
$b = (array) $value;
$b = reset($b);
array_push($a,$b);
}
return json_encode($a);
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DmitryIvanov\DarkSkyApi\DarkSkyApi;
class WeatherController extends Controller
{
public function push(Request $request){
$lat = $request->input('lat');
$lon = $request->input('lon');
//if(db_age > 1 h)
$forecast = (new DarkSkyApi('78d784f058add542a26b103706a511b2'))
->location($lat, $lon)
->units('si')
->language('fi')
->extend('hourly')
->forecast('hourly');
//kantaan
//else
//hae tiedot kannasta
//$timeMachine = (new DarkSkyApi('78d784f058add542a26b103706a511b2'))
// ->location(46.482, 30.723)
// ->units('si')
// ->language('fi')
// ->timeMachine('2019-03-22', ['daily', 'flags']);
//$b=null;
$a =array();
foreach ($forecast->hourly()->data() as $value){
$b = (array) $value;
$b = reset($b);
array_push($a,$b);
}
return json_encode($a);
}
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Temperature extends Model
{
protected $fillable = [
'mintemperature',
'maxtemperature',
];
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Tyyppi extends Model
{
protected $fillable = [
'tyyppi',
];
}
......@@ -2,11 +2,12 @@
namespace App;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
class User extends Authenticatable implements JWTSubject
{
use Notifiable;
......@@ -36,4 +37,23 @@ class User extends Authenticatable
protected $casts = [
'email_verified_at' => 'datetime',
];
/**
* Get the identifier that will be stored in the subject claim of the JWT.
*
* @return mixed
*/
public function getJWTIdentifier()
{
return $this->getKey();
}
/**
* Return a key value array, containing any custom claims to be added to the JWT.
*
* @return array
*/
public function getJWTCustomClaims()
{
return [];
}
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Vaate extends Model
{
protected $fillable = [
'vaate',
'tyyppi_id',
];
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Vaatecomp extends Model
{
protected $fillable = [
'vaate_id',
'age_id',
'temperature_id',
];
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Weather extends Model
{
//
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Weather extends Model
{
//
}
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.1.3",
"dmitry-ivanov/dark-sky-api": "^1.0",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
}
}
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.1.3",
"dmitry-ivanov/dark-sky-api": "^1.0",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0",
"tymon/jwt-auth": "^1.0.0"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
}
}
This diff is collapsed.
......@@ -42,9 +42,9 @@ return [
],
'api' => [
'driver' => 'token',
'driver' => 'jwt',
'provider' => 'users',
'hash' => false,
/* 'hash' => false,*/
],
],
......
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateWeatherTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('weather', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('json');
$table->timestamps();