MongoDB
 sql >> Database >  >> NoSQL >> MongoDB

Come inserire oggetti nidificati in MongoDB con Laravel 5?

Crea un array con le chiavi.

public function store(Request $request)
{
    $player->name = $request->input('name');
    $player->lastname = $request->input('lastname');
    $player->stats = [
      'position' => $request->input('stats.position'),
      'profile' => $request->input('stats.profile'),
    ];
    $player->save();
    return response()->json($player);
}