jeudi 1 mars 2018

Laravel : Property [nom] does not exist on this collection instance

i have two tables user and technicien with one to one connection. When i edit a technicien using my form "Modifier Techicien" below i want the form to be autofilled with current information from both tables user and technicien. At this time the form is autofilled with only information from technicien. Could anyone help me with this please ?

enter image description here

controller

public function edit($id)
{
    $technicien=technicien::find($id);
    $users = user::orderBy('id', 'asc')->get();
    return view('technicien.edit',['moyenne_avis'=>$technicien],
['actif'=>$technicien],['user_id'=>$technicien])-
>with('users',$users);
}

public function update(Request $request, $id)
{
    // do some request validation
    $technicien=technicien::find($id);
    $technicien->update($request->all());
    return redirect('technicien');
}

edit.blade.php

@extends('Layouts/app')
@extends('Layouts.master')
@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-10">
            <h1>Modifier Technicien</h1>
        <form action="" method="post">
        
        


            <div class="form-group">
                <label for="">Nom</label>
                <input id="nom" type="text" class="form-control" name="nom" value="" >
            </div>
            <div class="form-group">
                <label for="">Prenom</label>
                <input id="nom" type="text" class="form-control" name="nom" value="" >
            </div>

            <div class="form-group">
                <label for="">moyenne Avis</label>
                <input type="text"  name ="moyenne_avis" class="form-control" value ="" >
            </div>
            <div class="form-group">
                <label for="">Etat Technicien</label>
                <input type="text"  name ="actif" class="form-control" value ="" >
            </div>



            <div class="form-group">

                <input type="submit" value = "enregistrer" class="form-control btn btn-primary">
            </div>
        </form>
    </div>
</div>
@endsection



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire