Multi attach Laravel from ReactJS

  arrays, eloquent, laravel, laravel-sanctum, reactjs

I have a litte problem inputting data from client to server, where the value does not match and has an error.
I want to add data using a pivot table with attach but the value I get does not match I tried several ways but failed.
What I want after creating the document data then attach the user according to what has been inputted in the client.

The problem

Just want to take id from client for pivot maybe like that:


here’s the code I’ve made:


    try {
        $document = Document::create([
            'udin' => $request['udin'],
            'slug' => $uuid,
            'status' => self::$active,

        return ResponseFormatter::success(
    } catch (Exception $e) {
        return ResponseFormatter::error([
            'message' => self::$wrong,
            'error' => $e->errors(),
        ], self::$failed, 500);



Source: Laravel

Leave a Reply