lundi 15 juillet 2019

ID problem when I change the status of a value

In my form revision, I have 2 motorbikes in revision. There are the number 000001 and 000003.

enter image description here

In my form motorbikes, I see that the ID of the motorbike 000002 has been modified instead of ID number 000003.

enter image description here

There is a problem about ID ?

In my Controller motorbike I have this:

 public function index()
    {
        $motorbikes = Motorbike::oldest()->paginate(5);

        $bikeIdsDown = Revision::where('date_revision_start', "<" , Carbon::now())->where('date_revision_end', ">", Carbon::now())->pluck('id')->toArray();

        return view('admin.motorbikes.index', compact('motorbikes', 'bikeIdsDown'))
          ->with('i', (request()->input('page',1) -1)*5);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
   public function create()
    {       

        $revisions = Revision::all();
        $bikeIdsDown = Revision::where('date_revision_start', "<" , Carbon::now())->where('date_revision_end', ">", Carbon::now())->pluck('id')->toArray();

        return view('admin.motorbikes.create', compact('revisions', 'motorbikes'));
    }

In my index.blade I also have this:

@foreach($motorbikes as $motorbike)
  <tr>
    <td> </td>
    <td></td>
    <td> @if(in_array($motorbike->id, $bikeIdsDown))
           UNAVAILABLE
         @else
           Available
         @endif
     </td>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire