Привет, я работаю над методом обновления для обновления профиля, сейчас я обновляю профиль, передавая модель в качестве параметра, но я хочу передать идентификатор профиля, чтобы маршрут был patch('/profiles/podcast/{id}''
iя довольно новичок в laravel, поэтому мне интересно, как мне изменить контроллер и тест phpunit, чтобы обновлять его таким образом при захвате объектов в laravel?
Функция обновления в контроллере:
public function update(PodcastProfile $podcastProfile)
{
$this->user = Auth::user();
$this->podcastProfile = $podcastProfile;
if (!$this->hasPodcastProfile()) {
abort(400, "You don't have a podcast profile configured");
}
$this->validation();
$this->transaction();
return $this->podcastProfile->toJson();
}
Этотекущий маршрут для метода обновления
Route::patch('/profiles/podcast/{podcastProfile}', 'PodcastProfileController@update');
Это тестовый пример phpunit для функции
/**
* @test
*/
public function it_should_update_podcast_profile()
{
$podcastDetails = $this->handlePostRequestToController();
$this->json('patch', '/profiles/podcast/' . $podcastDetails['id'], $this->updateData)
->assertSuccessful();
$this->checkPodcastProfile($this->updateData, $podcastDetails['id']);
$this->checkGuestFormats($this->updateData['guest_format']);
$this->checkAvailability($this->updateData['availability']);
$this->checkEquipment($this->updateData['equipment']);
$this->checkCategories($this->updateData['categories']);
$this->checkLocation($this->updateData['country'], $this->updateData['city']);
}