Я с успело пытается вставить данные с помощью Laravel 5.1Ошибка при вставке данных с Laravel 5,1
вот мой код:
$event = Event::whereId($request->input('event'))->first();
$participant = new Participant([
'email' => $request->input('mail'),
'lastname' => $request->input('lastname'),
'firstname' => $request->input('firstname'),
'phonenumber' => $request->input('phone'),
'address' => $request->input('address'),
'department' => $request->input('department')
]);
$gender = Gender::whereId($request->input('gender'));
$expertise = Expertise::whereId($request->input('expertise'));
$country = Country::whereId($request->input('country'));
$participant->gender()->associate($gender);
$participant->expertise()->associate($expertise);
$participant->country()->associate($country);
$event->participant()->save($participant);
ее моя ошибка:
"Object of class Illuminate\Database\Eloquent\Builder could not be converted to string"
[...]
at BelongsToMany->save(object(Participant)) in EventController.php line 122
Строка 122 соответствует: «$ event-> участник() -> save ($ участник);"
Я не думаю, что вам нужна дополнительная информация, но вы всегда можете спросить меня.
вот мой «участник» отношения в моей модели «Событие»: участник публичных функций() { return $ this-> принадлежит ToMany ('App \ Partant'); } – Hayanno