Home>
The input contents are not reflected in the database as intended.
Error messageHow the database looks
I want to insert "1" into the proof column when submitting in the form,
It will be NULL.
Because values other than proof are reflected,
Probably, for $request sent in form,
It is assumed that only proof data is not sent.
content.blade.php
@ extends ('layouts.top')
@section ('title', 'Anything Teacher')
@section ('content')
~ Omitted ~
@if ($proof == 1)
<form method = "POST" action = "{{action ('Student \ StudentController @ store2')}}">
@csrf
<input name = "proof" type = "hidden" value = "1">
@Else
<form method = "POST" action = "{{action ('Student \ StudentController @ store')}}">
@csrf
@endif
<input name = "question_id" type = "hidden" value = "{{$question->id}}">
<input name = "name" type = "hidden" value = "{{$teacher->name}}">
<hr>
<label for = "body">Body</label>
<textarea name = "body" rows = "4">{{old ('body')}}</textarea>
@if ($errors->has ('body'))
{{$errors->first ('body')}}
@endif
<button type = "submit">
To comment
</button>
</form>
@endsection
Controller
<? php
namespace App \ Http \ Controllers \ Student;
use App \ Http \ Controllers \ Controller;
use Illuminate \ Http \ Request;
use App \ User;
use App \ Question;
use App \ Comment;
class StudentController extends Controller
{
~ Omitted ~
public function store2 (Request $request)
{
$params = $request->validate ([
'question_id' =>'required | exists: questions, id',
'body' =>'required | max: 2000',
'proof' =>'required',
]);
$question = Question :: findOrFail ($params ['question_id']);
$question->comments ()->create ($params);
$name = $request->name;
$teacher = User :: where ('name', $name)->first ();
return view ('student.content', ['teacher' =>$teacher, 'question' =>$question, 'proof' =>1]);
}
}
If the default value of proof is changed from NULL to none in the database settings,
The following errors are possible:
Error screen
-
Answer # 1
Related articles
- php - about compiling javascript code in laravel development
- php - about the prepare method of the database handler
- php - about laravel route
- php - about the value stored in laravel db
- php - about searching with laravel where clause
- php - about laravel unique validation
- php - i don't know how to display an existing database in vue with laravel + mysql + vuejs
- php - laravel get information about the user who clicked
- php - about laravel 8x components
- php - [laravel] about the return type of the helper function view ()
- php - foreign key constraint on laravel phone number
- php - introduction to laravel (aomoto) eloquent about "creating a model"
- about php zend framework flashmessenger
- mysql - about database structure and how to hold data
- about laravel docker
- php - about javascript document
- php - about the advantages/disadvantages and necessity of saving images in the database
- i want to move to the second page about the pagination function of laravel
- php - [laravel] [eloquent] i don't know how to include the record of the child table to which the relation is made in the respon
- about php functions
Related questions
- [laravel7] is it possible to use database records for the information in filesystemphp?
- php - about the multiple structure of laravel's many-to-many relations
- php : Policy not working in Laravel
- i want to get rid of the no route to host error in php file_get_contents ()
- php - about how to validate the tampering of the value value of checkbox and select element in laravel 6 series
- php - i can't connect to db with laravel
- php - about laravel route
- php - when accessing the web application in lan from a pc in another lan, it cannot be referenced how can i make this visible?
- php - error in laradock docker-composeyml
- php - trying to access array offset on value of type null how to avoid
I just didn't add proof to the Comment whitelist. . .
I apologize to you for a fuss over.