Answer the question
In order to leave comments, you need to log in
Why Laravel submit doesn't work?
I don't understand why the form is not working. Here are the routes:
Route::get('fill-profile', '[email protected]')->middleware('auth')->name('fill-profile');
Route::post('store-profile', '[email protected]')->middleware('auth')->name('store-profile');
class ProfileController extends Controller
{
public function store(CreateProfileRequest $request)
{
dd(\Auth::user());
$name = \Auth::user()->name;
$profile = new Profile();
$profile->location = \Auth::user()->location->place . ', ' . \Auth::user()->location->country;
$profile->name = $name;
$profile->surname = $request->surname;
$profile->age = $request->age;
$profile->gender = $request->gender;
$profile->skype = $request->skype;
$profile->discord = $request->discord;
$profile->about = $request->about;
$profile->user_id = \Auth::user()->id;
$profile->save();
return redirect()->route('profile')->with('slug', $name);
}
public function fill()
{
// Check if logged in
if (!(\Auth::check())) {
return Redirect::to('/login');
}
// check if user account is active
if (! \Auth::user()->isActive()) {
\Auth::logout();
return redirect('login')->with('error', trans('auth.deactivated'));
}
$user = \Auth::user();
return view('frontend.user.fill', ['user' => $user]);
}
}
<form name="account-fill" action="{{ route('store-profile') }}" method="POST">
{!! csrf_field() !!}
<input type="text" name="surname" placeholder="Enter your surname">
<input type="number" name="age" placeholder="How old are you?">
<h4>Select your gender:</h4>
<select name="gender" form="account-fill">
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
<h4>Add some contact information:</h4>
<input type="text" placeholder="Enter your Skype login here">
<input type="text" placeholder="Enter your Discord login here">
<h4>Tell us something about you:</h4>
<textarea name="about" cols="60" rows="10" placeholder="Hey, type here something about yourself"></textarea>
<input type="submit" class="btn" value="Send">
</form>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question