Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

davy_yg's avatar
Level 27

add profile button

Hello,

I wonder why the add profile button does not work?

index.blade.php

<button class="btn btn-primary" onclick="{{ url('profile/create') }}">Add Profile</button><br><br>

web.php

Route::get('profile/create', 'ProfileController@create')->name('profile.create');

ProfileController.php

class ProfileController extends Controller
{
	//

public function create() { return view('admin.add_profile'); } }

0 likes
2 replies
rodrigo.pedra's avatar
Level 56

If you want to use a <button> you need to use a valid JavaScript expression on the onclick attribute:

<button class="btn btn-primary" onclick="window.location.href = '{{ url('profile/create') }}'">Add Profile</button><br><br>

But as it seems you are using bootstrap, you can style a regular link as a button:

<a class="btn btn-primary" href="{{ url('profile/create') }}">Add Profile</a><br><br>
sauravs012's avatar

you did not use window.location in onclick attr. Try this

<button class="btn btn-primary" onclick="window.location='{{ url(profile/create") }}'">Add Profile</button>

Please or to participate in this conversation.