I created a Laravel project which first shows you a combobox with months, it then sends you to the page with the selected month, on this page it shows the weather statistics for this month, my task is to add 2 radio buttons , one that when pressed shows the statistics in degrees celcius and the other one when clicked shows the degrees in fahrenheit,
to be honest i don't really know how to approach this matter.
I've looked online how you would change from celcius to fahrenheit but i didn't really find anything propper to help me.
this is the page that it starts with
<!DOCTYPE html> <!-- selecteer.php -->
<html lang="nl">
<head> <!-- VIEW -->
<meta charset="UTF-8">
<title>Temperaturen</title>
</head>
<body>
<form action="overzicht" method="post">
Maand: <select name="maand">
<option value="1">Januari</option>
<option value="2">Februari</option>
<option value="3">Maart</option>
<option value="4">April</option>
</select>
<button type="submit">Overzicht</button>
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
</form>
</body>
</html>
you select a month (the months are in dutch) and then when you click on the button you go to "Temperatuur.php"
<?php # app\Temperatuur.php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class Temperatuur extends Model
{
static public function getData($maand = 0)
{
$dagtemperaturen = DB::table('dagmeting')->where('maandnr','=',$maand)->get();
return $dagtemperaturen;
}
}
on this page it shows a table filled with the temperature stats of the selected month, and it shows the month at the top.
<?php # app\Http\Controllers\TemperatuurController.php
// CONTROLLER
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Temperatuur;
use Illuminate\Http\Request;
class TemperatuurController extends Controller
{
public function getIndex()
{
return view('selecteer');
}
public function overzicht(Request $request)
{
$maand = $request->input('maand');
$metingen= Temperatuur::getData($maand);
return view('overzicht', array('maand'=>$maand, 'metingen'=>$metingen));
}
}
^^ this is the controller for temperatuur.php
i really dont know how to approach this matter , i know you need to do something with javascript, but i really dont have a clue what..
Aucun commentaire:
Enregistrer un commentaire