There are so many inconsistancies in your code so I don't even know where to begin.
- You have two columns in you migration file with the name title
$table->text('title');
$table->LONGTEXT('title');
Remove the second one.
- You have all capitals in your migration
$table->LONGTEXT('slug');
PHP is case sensitive so change to
$table->longText('slug');
- In your view you have missed quoting property values in several places among other
<input type="text" name=link class="form-control" placeholder="" id="mdate">
Change to
<input type="text" name="link" class="form-control" placeholder="" id="mdate">
So now if you want to validate the fields in your store method you need to do something like this
$request->validate([
'title' => 'required',
'date_time' => 'required|date'
'category_id' => 'required|exits:categories',
]);
You will need to validate the other fields too except slug since you probably generates that from the title.
Those fields should not have required rule.
The file you can use the 'mimes`validation for images it could look like this
'mimes:jpeg,bmp,png'
This is stuff you will learn by watching the free videos on this site.
All the conditions after you validation looks like gibberish to me and I have no clue of what you are trying to do.
Remove them and start over is my suggestion. Get a bare minimum to pass the validation and store it in the database.
Something like
public function store(Request $request)
{
$request->validate([
'title' => 'required',
'date_time' => 'required|date'
'category_id' => 'required|exits:categories',
]);
$post = new Post();
$post->title = $request->title;
$post->date_time = $request->date_time;
$post->category_id = $request->category_id;
$post->slug = Str::slug($request->title);
$post->save();
return redirect('/posts')->with('status', 'Post saved!');
}
Then add field for field until you have everything in place.