json

Posted 1 year ago by chagouani

I have 2 table technicien(id, user_id,actif) and user (nom , prenom , adresse )

I would like to perform a web service function to display the technician list with their name and firstname of the user table

i have this function but it displays all techiciens i like to shown information of selected id

public function GetTables() {
    $techniciens = Technicien::with('user')->get();

    return $techniciens->map(function ($technicien) {
    return [
        'id' => $technicien->id,
        'actif' => $technicien->actif,
        'moyenne_avis' => $technicien->moyenne_avis,
        'nom' => $technicien->user->nom,
        'prenom' => $technicien->user->prenom,
        'adresse' => $technicien->user->adresse,
    ];
  });
  }

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.