-1

new to PHP so I'm struggling to see why this is a syntax error, a correction and some advice would be great, thanks! Code below:

<?php
namespace App\Http\Controllers;

use App\User;
use App\Chatkit;
use Illuminate\Http\Request;

class UserController extends Controller
{
    public function create(Request $request, Chatkit $chatkit)
    {
        $data = $request->validate([
                                   'name' => 'required|string|max:255',
                                   'password' => 'required|string|min:6',
                                   'email' => 'required|string|email|max:255|unique:users',
                                   ]);

        $data['chatkit_id'] = str_slug($data['email'], '_');

        $response = $chatkit->createUser([
                                         'id' => $data['chatkit_id'],
                                         'name' => $data['name']
                                         );

        if ($response['status'] !== 201) {
            return response()->json(['status' => 'error'], 400);
        }

        return response()->json(User::create($data));
    }
}
Danny Dainton
  • 23,069
  • 6
  • 67
  • 80
Chakeeel
  • 165
  • 1
  • 4
  • 12

1 Answers1

3

It's here:

    $response = $chatkit->createUser([
                                     'id' => $data['chatkit_id'],
                                     'name' => $data['name']
                                     );
  //--------------------------------^

You need a ] making it:

    $response = $chatkit->createUser([
                                     'id' => $data['chatkit_id'],
                                     'name' => $data['name']
                                    ]);
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252