I am making a post that seems to successfully reach the controller but the browser keeps showing a 302 response. I am logging the request with dd()
and am getting the text to log appropriately. I don't know why I am getting a 302 though. I posted my code below and would love some input on what I'm doing wrong. Thanks!
Blade
<form class="form" role="form" method="POST" action="">
<div class="form-group @hasError('custom_text')">
<textarea name="custom_text" value="">
</textarea>
@error('custom_text')
</div>
<button class="btn btn-success" type="submit">Update Custom Text</button>
</form>
Controller
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Http\Requests\Admin\CustomTextFormRequest;
class CustomTextController extends Controller
{
public function index()
{
return view('admin.store.custom-text');
}
public function update(CustomTextFormRequest $request)
{
$customText = $request->input('custom_text');
dd($customText);
flash('Custom Text Updated!');
return redirect()->back();
}
}
CustomTextForRequest
class CustomTextFormRequest extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
return [
'custom_text' => 'required|string',
];
}
}
** Routes **
Route::post('admin/store/custom-text/update', 'Admin\CustomTextController@update');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire