vendredi 12 juillet 2019

Retrieve the availability of motorbikes which are not in revision or in training

I am looking a way to retrieve the availability of motos which are not in revision or training.

I have a form named motorbike with 3 fields (matriculation, number_motorbike, status).

Here, I have 3 motorbikes and 1 unavailable number motorbike -> 000001.

enter image description here

My second form is revision with 4 fields (date_revision_start, date_revision_end, garage, fk_motorbike).

I only have 1 motorbike in revision.

enter image description here

In my form trainings I have 2 fields (date_sitting, fk_motorbike).

enter image description here

Here, when I add for example 1 motorbike which is in revision, there is no blocking, it's my problem.

In the form create.blade.php, Is it possible, to see only the motorbikes availables every day for example?

enter image description here

I really stuck on this problem... I thank in advance for your help and your time.

Controller -> Training

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Motorbike;
use App\Training;

class TrainingController extends Controller
{

    public function index()
    {
        $trainings = Training::oldest()->paginate(5);
        return view('admin.trainings.index', compact('trainings'))
             ->with('i', (request()->input('page',1) -1)*5);
    }


    public function create()
    {   

        $motorbikes = Motorbike::all();
        return view('admin.trainings.create', compact('motorbikes', 'trainings'));

    }

    public function store(Request $request)
    {   

        $request->validate([
                'date_sitting' => 'required',
                'fk_motorbike' => 'required'
        ]);

        Training::create($request->all());

        return redirect()->route('trainings.index')
                ->with('success', 'new data created successfully');
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire