BUB-7 Automobili: Creato modello Operazione e Rifornimento, su controller gestione del rifornimento e creazione delle migrations per Manutenzione Revisione e Accessori
This commit is contained in:
parent
2be78bfcde
commit
9fa9b6681c
@ -4,6 +4,8 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
|
|
||||||
use App\Models\Auto;
|
use App\Models\Auto;
|
||||||
|
use App\Models\Operazione;
|
||||||
|
use App\Models\Rifornimento;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
|
||||||
@ -63,4 +65,11 @@ class AutoController extends Controller
|
|||||||
{
|
{
|
||||||
return view('auto.rifornimento',['id'=>$id['id'],'dettagli'=>Auto::getAutoById($id['id'])]);
|
return view('auto.rifornimento',['id'=>$id['id'],'dettagli'=>Auto::getAutoById($id['id'])]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function saveRifornimento(Request $request)
|
||||||
|
{
|
||||||
|
$id=Operazione::saveOperazione($request);
|
||||||
|
Rifornimento::saveRifornimento($id,$request);
|
||||||
|
return redirect(route('auto_list'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
11
app/Models/Accessori.php
Normal file
11
app/Models/Accessori.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Accessori extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
@ -11,17 +11,17 @@ class Auto extends Model
|
|||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
public function getAutoById($id)
|
public static function getAutoById($id)
|
||||||
{
|
{
|
||||||
return $dettagli=DB::table('autos')->find($id);
|
return $dettagli=DB::table('autos')->find($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAutoList()
|
public static function getAutoList()
|
||||||
{
|
{
|
||||||
return $lista=DB::table('autos')->select(['targa','marca','modello','id'])->get();
|
return $lista=DB::table('autos')->select(['targa','marca','modello','id'])->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveAuto($request)
|
public static function saveAuto($request)
|
||||||
{
|
{
|
||||||
DB::table('autos')->insert([
|
DB::table('autos')->insert([
|
||||||
'targa'=>$request['targa'],
|
'targa'=>$request['targa'],
|
||||||
@ -37,7 +37,7 @@ class Auto extends Model
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delAuto($id)
|
public static function delAuto($id)
|
||||||
{
|
{
|
||||||
DB::table('autos')->delete($id['id']);
|
DB::table('autos')->delete($id['id']);
|
||||||
}
|
}
|
||||||
|
11
app/Models/Manutenzione.php
Normal file
11
app/Models/Manutenzione.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Manutenzione extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
29
app/Models/Operazione.php
Normal file
29
app/Models/Operazione.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class Operazione extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
// Operazione effettuata sull'auto
|
||||||
|
|
||||||
|
public static function saveOperazione($data)
|
||||||
|
{
|
||||||
|
// inserisce nel database e ritorna l'id
|
||||||
|
$id=DB::table('operaziones')->insertGetId(
|
||||||
|
[
|
||||||
|
'fk_auto_id'=>$data['auto'],
|
||||||
|
'data'=>$data['data'],
|
||||||
|
'km'=>$data['km'],
|
||||||
|
'importo'=>$data['importo'],
|
||||||
|
'type'=>$data['type']
|
||||||
|
]
|
||||||
|
);
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
|
}
|
11
app/Models/Revisione.php
Normal file
11
app/Models/Revisione.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Revisione extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
23
app/Models/Rifornimento.php
Normal file
23
app/Models/Rifornimento.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class Rifornimento extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
// Inserisce i dati di un rifornimento
|
||||||
|
public static function saveRifornimento($id,$data)
|
||||||
|
{
|
||||||
|
DB::table('rifornimentos')->insert([
|
||||||
|
'eurolitro'=>$data['eurolitro'],
|
||||||
|
'litri'=>$data['litri'],
|
||||||
|
'distributore'=>$data['distributore'],
|
||||||
|
'operazione_id'=>$id
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateRifornimentosTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('rifornimentos', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->double('eurolitro',10,2);
|
||||||
|
$table->double('litri',10,2);
|
||||||
|
$table->string('distributore',255);
|
||||||
|
$table->unsignedBigInteger('fk_operazione');
|
||||||
|
$table->foreign('fk_operazione')->references('id')->on('operaziones');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('rifornimentos');
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateOperazionesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('operaziones', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->unsignedBigInteger('fk_auto_id');
|
||||||
|
$table->foreign('fk_auto_id')->references('id')->on('autos');
|
||||||
|
$table->date('data');
|
||||||
|
$table->bigInteger('km');
|
||||||
|
$table->double('importo',10,2);
|
||||||
|
$table->string('type',100);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('operaziones');
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateManutenzionesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('manutenziones', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('manutenziones');
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateRevisionesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('revisiones', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('revisiones');
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateAccessorisTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('accessoris', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('accessoris');
|
||||||
|
}
|
||||||
|
}
|
@ -48,6 +48,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
|
<input type="hidden" name="type" value="rifornimento">
|
||||||
|
<input type="hidden" name="auto" value="{{ $dettagli->id; }}">
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -71,6 +71,8 @@ Route::get('/', [MovimentiController::class,'dashboard']);
|
|||||||
Route::get('auto/delete', [AutoController::class, 'delAuto']);
|
Route::get('auto/delete', [AutoController::class, 'delAuto']);
|
||||||
Route::get('auto/detail', [AutoController::class, 'getAutoDetails']);
|
Route::get('auto/detail', [AutoController::class, 'getAutoDetails']);
|
||||||
Route::get('auto/rifornimento', [AutoController::class, 'rifornimentoAuto'])->name('auto_rifornimento');
|
Route::get('auto/rifornimento', [AutoController::class, 'rifornimentoAuto'])->name('auto_rifornimento');
|
||||||
|
Route::post('auto/rifornimento', [AutoController::class, 'saveRifornimento']);
|
||||||
|
|
||||||
|
|
||||||
/// TEST routes
|
/// TEST routes
|
||||||
Route::get('fullcalender', [FullCalenderController::class, 'index']);
|
Route::get('fullcalender', [FullCalenderController::class, 'index']);
|
||||||
|
Loading…
Reference in New Issue
Block a user