Forum Laravel SQLSTATE
i want to create new suggestion, but it show the error below https://imgur.com/a/MoBXpgX
database for suggestion shown below https://imgur.com/a/B31h2U8
this is my create.blade
@extends('layouts.app') @section('content') <div class="col-sm-9"> <h1>Create Suggestion</h1> {!! Form::open(['method' => 'POST', 'action' => ['[email protected]']]) !!} <div class="container-fluid" id="dynamic_field"> {{--store data form in array for multiple suggestion--}} <table class="table table-bordered" id="dynamic_field"> <tr> <td> {!! Form::textarea('suggestion', null , ['class' => 'form-control', 'placeholder' => 'Suggestion']) !!} </td> <td> {!! Form::text('category', null , ['class' => 'form-control', 'placeholder' => 'Category']) !!} </td> </tr> </table> </div> <br/> {{--{!! Form::submit('Create Suggestion', ['class'=>'btn btn-primary btn-lg col-sm-12']) !!}--}} <button type="submit" class="btn btn-danger" onclick="return confirm('Successful creating !')">Create Suggestion</button> {!! Form::close() !!} </div> @endsection
this is my controller
<?php namespace App\Http\Controllers; use App\Suggestion; use Illuminate\Http\Request; class SuggestionController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $suggestions = Suggestion::all(); return view('admin.suggestion.index',compact('suggestions')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('admin.suggestion.create'); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // return $request->all(); // $suggestions = $request->input('suggestion'); $suggestion = [ 'suggestion', 'category' => $request->input('suggestion','category') ]; Suggestion::create($suggestion); return redirect()->back(); } /** * Display the specified resource. * * @param \App\Suggestion $suggestion * @return \Illuminate\Http\Response */ public function show(Suggestion $suggestion) { // } /** * Show the form for editing the specified resource. * * @param \App\Suggestion $suggestion * @return \Illuminate\Http\Response */ public function edit(Suggestion $suggestion) { $id=$suggestion->id; $suggestion=Suggestion::findOrFail($id); return view('admin.suggestion.edit', compact('suggestion')); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Suggestion $suggestion * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $suggestion= Suggestion::findOrFail($id); $suggestions=$request->input('suggestion'); $suggestion->update(['suggestion'=>$suggestions]); return redirect()->back(); } /** * Remove the specified resource from storage. * * @param \App\Suggestion $suggestion * @return \Illuminate\Http\Response */ public function destroy(Suggestion $suggestion) { $id=$suggestion->id; Suggestion::findOrFail($id)->delete(); return redirect('/suggestion'); } }
Please sign in or create an account to participate in this conversation.
There's no shortage of content at Laracasts. In fact, you could watch nonstop for days upon days, and still not see everything!
Get Started
SQLSTATE
i want to create new suggestion, but it show the error below https://imgur.com/a/MoBXpgX
database for suggestion shown below https://imgur.com/a/B31h2U8
this is my create.blade
this is my controller