just use a different name for the form inputs for each section, and have your controller differentiate the input name and insert/update it accordingly.
How to submit 3 individual post from single From for single designed page?
Is it possible through database? I have a from(section.blade.php) in which I have 3 section one for man scheduled 2nd for women scheduled and 3rd for child scheduled and only one submit button, but I want on 3 submit button on form for each section, so I could post data like for men(1), women(1+) and child(1+) on single design page. Please tell or give any relevant link or example please, thanks.
@siangboon , thanks once again, so is it possible without loading page
what do you mean by without loading page?
You can do it with ajax using vanilla javascript or any of the frameworks out there.
I made 3 submit button and when submit my first button then , it's refreshing the page actually,
Here is my code
<div class="card">
<!-- Model -->
<div class="card-body">
<h4 class="card-title">Past Event </h4>
<div class="button-box">
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#exampleModal" data-whatever="@fat">Add New <i class="fas fa-plus"></i></button>
</div>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel1">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<form action="{{route('past_event.store1')}}" method="post" enctype="multipart/form-data" class="form-bg1">
{{csrf_field()}}
<div class="form-body">
<div class="row p-t-20">
<div class="form-group">
<input type="hidden" name="category_id" id="category" value="16">
</div>
<!--/span-->
<div class="col-md-6">
<div class="form-group">
<label class="control-label">Event Title </label>
<input type="text" name="title" class="form-control" placeholder="">
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="control-label">Event Date</label>
<input type="text" name="event_date" class="form-control" placeholder="Select a date" id="mdate">
<small class="form-control-feedback"></small> </div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="control-label">Video link(Youtube)</label>
<input type="text" name="event_video_link" class="form-control" placeholder="" >
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="control-label">Place Name</label>
<input type="text" name="event_place_name" class="form-control" placeholder="" id="mdate">
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="card">
<div class="card-body">
<h4 class="card-title">Event Image</h4>
<label for="input-file-now">Max file size 2 mb</label>
<input type="file" name="Image" id="input-file-now" class="dropify" />
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-success"><i class="fa fa-check"></i> Save</button>
</div>
</div>
</div>
</form>
*****************************************************************************************************************************************************************
<!--/span-->
</div>
</div>
<div class="row p-t-20">
<form action="{{route('past_event.store2')}}" method="post" enctype="multipart/form-data" class="form-bg1">
{{csrf_field()}}
<div class="row">
<div class="col-lg-4 col-md-4">
<div class="form-group">
<label class="control-label">Speaker Person Name</label>
<input type="text" name="speaker_name" class="form-control" placeholder="" >
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="form-group">
<label class="control-label">Speaker Person Position</label>
<input type="text" name="speaker_position" class="form-control" placeholder="" >
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="card">
<div class="card-body">
<h4 class="card-title">Speaker Image</h4>
<label for="input-file-now">Max file size 2 mb</label>
<input type="file" name="Featured" id="input-file-now" class="dropify" />
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-success"><i class="fa fa-check"></i> Save</button>
</div>
</form>
</div>
*****************************************************************************************************************************************************************
<div class="row p-t-20">
<form action="{{route('past_event.store3')}}" method="post" enctype="multipart/form-data" class="form-bg1">
{{csrf_field()}}
<div class="row">
<div class="col-lg-4 col-md-4">
<div class="form-group">
<label class="control-label">Event_session_Name</label>
<input type="text" name="event_session_name" class="form-control" placeholder="" >
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="form-group">
<label class="control-label">session_time</label>
<input type="text" name="session_time" class="form-control" placeholder="" >
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="form-group">
<label class="control-label">session_person_name</label>
<input type="text" name="session_person_name" class="form-control" placeholder="" >
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="form-group">
<label class="control-label">session_person_topic</label>
<input type="text" name="session_person_topic" class="form-control" placeholder="" >
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="card">
<div class="card-body">
<h4 class="card-title">Session person Image</h4>
<label for="input-file-now">Max file size 2 mb</label>
<input type="file" name="Featured1" id="input-file-now" class="dropify" />
</div>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="card">
<div class="card-body">
<h4 class="card-title">session_person_pdf</h4>
<label for="input-file-now">Max file size 2 mb</label>
<input type="file" name="File" id="input-file-now" class="dropify" />
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-success"><i class="fa fa-check"></i> Save</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- /.modal End -->
sure it will refresh as this is 3 form in a single page, each button clicked will submit the particular form details and after process it will redirect back..
you can try to use the axios or ajax as proposed by tray2, but i personally prefer using tabs to seperate each form in this case... to create a tabs component can refer to this... https://laracasts.com/series/practical-vue-components/episodes/7
Thank you @, And when I am submitting the button individually, it creating another id and on webpage not showing all data in one link. so due to that when I am opening the post for single.blade.php to view it's not showing all in one.. It's asking to pay, please help with this, if there is another link with example..,
@tray2 thank you, Is there any example link so I can go through with it and find the way to do that?
Here is my code for create.blade.php
@extends ('layouts.app')
@section('content')
<div class="page-wrapper">
<!-- ============================================================== -->
<!-- Container fluid -->
<!-- ============================================================== -->
<div class="container-fluid">
<!-- ============================================================== -->
<!-- Bread crumb and right sidebar toggle -->
<!-- ============================================================== -->
<div class="row page-titles">
<div class="col-md-5 align-self-center">
<a href="{{route('home')}}"><h4 class="text-themecolor"><i class="icon-home"></i> Go to Home</h4></a>
</div>
</div>
@if(count($errors)>0)
<ul class="list-group">
@foreach($errors->all() as $error)
<li class="list-group-item text-danger">
{{$error}}
</li>
@endforeach
</ul>
@endif
<!-- ============================================================== -->
<!-- End Bread crumb and right sidebar toggle -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- Start Page Content -->
<!-- ============================================================== -->
<!-- Row -->
<div class="row">
<div class="col-lg-12">
<div class="card">
<!-- Model -->
<!-- Model -->
<div class="card-body">
<h4 class="card-title">Past </h4>
<div class="button-box">
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#exampleModal" data-whatever="@fat">Add New <i class="fas fa-plus"></i></button>
</div>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel1">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<form action="{{route('past_event.store')}}" method="post" enctype="multipart/form-data" class="form-bg1">
{{csrf_field()}}
<div class="form-body">
<div class="row p-t-20">
<div class="form-group">
<input type="hidden" name="category_id" id="category" value="16">
</div>
<!--/span-->
<div class="col-md-6">
<div class="form-group">
<label class="control-label">Event Title </label>
<input type="text" name="title" class="form-control" placeholder="">
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="control-label">Event Date</label>
<input type="text" name="event_date" class="form-control" placeholder="Select a date" id="mdate">
<small class="form-control-feedback"></small> </div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="control-label">Video link(Youtube)</label>
<input type="text" name="event_video_link" class="form-control" placeholder="" >
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="control-label">Place Name</label>
<input type="text" name="event_place_name" class="form-control" placeholder="" id="mdate">
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="card">
<div class="card-body">
<h4 class="card-title">Event Image</h4>
<label for="input-file-now">Max file size 2 mb</label>
<input type="file" name="Image" id="input-file-now" class="dropify" />
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-success"><i class="fa fa-check"></i> Save</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<form action="{{route('past_event.store2')}}" method="post" enctype="multipart/form-data" class="form-bg1">
{{csrf_field()}}
<div class="row">
<div class="form-group">
<input type="hidden" name="category_id" id="category" value="16">
</div>
<div class="col-lg-4 col-md-4">
<div class="form-group">
<label class="control-label">Speaker Person Name</label>
<input type="text" name="speaker_name" class="form-control" placeholder="" >
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="form-group">
<label class="control-label">Speaker Person Position</label>
<input type="text" name="speaker_position" class="form-control" placeholder="" >
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="card">
<div class="card-body">
<h4 class="card-title">Speaker Image</h4>
<label for="input-file-now">Max file size 2 mb</label>
<input type="file" name="Featured" id="input-file-now" class="dropify" />
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-success"><i class="fa fa-check"></i> Save</button>
</div>
</form>
</div>
</div>
</div>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<form action="{{route('past_event.store3')}}" method="post" enctype="multipart/form-data" class="form-bg1">
{{csrf_field()}}
<div class="row">
<div class="form-group">
<input type="hidden" name="category_id" id="category" value="16">
</div>
<div class="col-lg-4 col-md-4">
<div class="form-group">
<label class="control-label">Event_session_Name</label>
<input type="text" name="event_session_name" class="form-control" placeholder="" >
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="form-group">
<label class="control-label">session_time</label>
<input type="text" name="session_time" class="form-control" placeholder="" >
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="form-group">
<label class="control-label">session_person_name</label>
<input type="text" name="session_person_name" class="form-control" placeholder="" >
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="form-group">
<label class="control-label">session_person_topic</label>
<input type="text" name="session_person_topic" class="form-control" placeholder="" >
<small class="form-control-feedback"> </small>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="card">
<div class="card-body">
<h4 class="card-title">Session person Image</h4>
<label for="input-file-now">Max file size 2 mb</label>
<input type="file" name="Featured1" id="input-file-now" class="dropify" />
</div>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="card">
<div class="card-body">
<h4 class="card-title">session_person_pdf</h4>
<label for="input-file-now">Max file size 2 mb</label>
<input type="file" name="File" id="input-file-now" class="dropify" />
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-success"><i class="fa fa-check"></i> Save</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- /.modal End -->
<div class="card-body">
<div class="table-responsive">
<table id="example23" class="display nowrap table table-hover table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>S.no</th>
<th>Date</th>
<th>Title</th>
<th>Form Link</th>
<th>Notice link</th>
<th>Descr</th>
<th>image</th>
<th>Form PDF</th>
<th>Notice PDF</th>
<th>Descr PDF</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@if($past_events->count()>0)
@foreach($past_events as $post)
<tr>
<td>{{$post->id}}</td>
<td>{{$post->date_time}}</td>
<td>{{$post->title}}</td>
<td>{{$post->f_link}}</td>
<td>{{$post->n_link}}</td>
<td>{{$post->content}}</td>
<td> @if ($post->Image) <img src="{{$post->Image}}" alt="" width="110px" height="110px"> @endif</td>
<td>{{$post->file}}</td>
<td>{{$post->featured1}}</td>
<td>{{$post->image}}</td>
<td style="width: 200px;">
<a href="{{route('past_event.edit', ['id'=>$post->id])}}" class="btn btn-info btn-xs" type="button" class="btn waves-effect waves-light btn-info"><i class="fas fa-edit"></i> Edit</a></button>
<a href="{{route('past_event.delete', ['id'=>$post->id])}}" type="button" class="btn waves-effect waves-light btn-danger"><i class="fas fa-trash-alt"></i> Delete</a></button>
</td>
</tr>
@endforeach
@else
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- Row -->
<!-- ============================================================== -->
<!-- End PAge Content -->
<!-- ============================================================== -->
<!-- ============================================================== -->
</div>
<!-- ============================================================== -->
<!-- End Container fluid -->
<!-- ============================================================== -->
</div>
@section('styles')
<link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote.css" rel="stylesheet">
@section('scripts')
<script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote.js"></script>
<script>
$(document).ready(function() {
$('#content').summernote();
});
</script>
<!-- Row -->
<script src="/app/cerca-admin/assets/node_modules/bootstrap-material-datetimepicker/js/bootstrap-material-datetimepicker.js"></script>
<script src="/app/cerca-admin/assets/node_modules/dropify/dist/js/dropify.min.js"></script>
<script src="/app/cerca-admin/assets/node_modules/datatables/datatables.min.js"></script>
<script>
// MAterial Date picker
$('#timepicker').bootstrapMaterialDatePicker({ format: 'HH:mm', time: true, date: false });
$('#mdate').bootstrapMaterialDatePicker({ format :'MM/DD/YYYY', weekStart: 0, time: false, currentDate:new Date() });
$('#date-format').bootstrapMaterialDatePicker({ format: 'dddd DD MMMM YYYY - HH:mm' });
$('#min-date').bootstrapMaterialDatePicker({ format: 'MM/DD/YYYY HH:mm', minDate: new Date() });
// Dropify
$(document).ready(function() {
// Basic
$('.dropify').dropify();
// Translated
$('.dropify-fr').dropify({
messages: {
default: 'Glissez-déposez un fichier ici ou cliquez',
replace: 'Glissez-déposez un fichier ou cliquez pour remplacer',
remove: 'Supprimer',
error: 'Désolé, le fichier trop volumineux'
}
});
// Used events
var drEvent = $('#input-file-events').dropify();
drEvent.on('dropify.beforeClear', function(event, element) {
return confirm("Do you really want to delete \"" + element.file.name + "\" ?");
});
drEvent.on('dropify.afterClear', function(event, element) {
alert('File deleted');
});
drEvent.on('dropify.errors', function(event, element) {
console.log('Has Errors');
});
var drDestroy = $('#input-file-to-destroy').dropify();
drDestroy = drDestroy.data('dropify')
$('#toggleDropify').on('click', function(e) {
e.preventDefault();
if (drDestroy.isDropified()) {
drDestroy.destroy();
} else {
drDestroy.init();
}
})
});
</script>
and after that template.blade.php
@extends('layouts.frontend')
@section('content')
<section id="page-title" class="page-title">
<div class="container-fluid bg-overlay bg-overlay-dark">
<div class="bg-section">
<img src="/app/assets/images/page-titles/2.jpg" alt="Background"/>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="title title-1 text--center">
<div class="title--content">
<div class="title--heading">
<h1>Past Events</h1>
</div>
</div>
</div><!-- .page-title end -->
</div><!-- .col-md-12 end -->
</div><!-- .row end -->
</div><!-- .container end -->
</section><!-- #page-title end -->
<!-- Blog Grid
============================================= -->
<section id="blog" class="blog blog-grid video-button video-button-1 ar-event">
<div class="container">
<div class="row">
@foreach($past_event->sortBydesc('id') as $post)
<div class="col-xs-12 col-sm-12 col-md-4">
<div class="video--content1">
<div class="bg-section">
@if ($post->Image)
<img src="{{ $post->Image }}" alt="Background" />@endif
</div>
</div>
</div>
<!-- .col-md-6 end -->
<div class="col-xs-12 col-sm-12 col-md-8">
<div class="heading heading-2 mb-10">
<h2 class="ar-heading--title">{{$post->title}}</h2>
</div>
<p class="ar-date"><i class="fa fa-calendar" aria-hidden="true"></i> {{ \Carbon\Carbon::parse($post->event_date)->format('F j, Y') }} <i class="fa fa-map-marker" aria-hidden="true"></i> IIT Delhi</p>
<div class="divider--line"></div>
<p>{{$post->title}} </p>
<a class="btn btn--primary btn--bordered btn--rounded ar-btn1" href="{{ route('post.single', ['slug' => $post->slug ]) }}">read more</a>
</div>
<!-- .col-md-6 end -->
</div>
@endforeach
</div>
<!-- .container end -->
</section>
and then single.blade.php
<div class="col-xs-12 col-sm-6 col-md-4 portfolio-item filter-web">
<div class="portfolio--img">
<img src="{{$past_event->Featured}}" alt="Portfolio Item">
<div class="portfolio--hover">
<div class="portfolio--action">
<div class="pos-vertical-center">
<div class="portfolio-zoom">
<a class="img-popup" href="{{$past_event->Featured}}" title="Portfolio Item">
<i class="icon--zoom"></i>
</a>
</div>
</div>
</div>
<!-- .Portfolio-action end -->
</div>
<!-- .Portfolio-hover end -->
</div>
<!-- .Portfolio-img end -->
<div class="portfolio--content">
<div class="portfolio--title">
<h4><a href="#">{{$past_event->speaker_name}}</a></h4>
</div>
<div class="portfolio--cat">
<a href="#">{{$past_event->speaker_position}}</a>
</div>
</div>
</div>
<!-- . portfolio-item end -->
<!-- Portfolio #2 -->
<div class="col-xs-12 col-sm-6 col-md-4 portfolio-item filter-print">
<div class="portfolio--img">
<img src="/app/assets/images/portfolio/standard/2col/2.jpg" alt="Portfolio Item">
<div class="portfolio--hover">
<div class="portfolio--action">
<div class="pos-vertical-center">
<div class="portfolio-zoom">
<a class="img-popup" href="/app/assets/images/portfolio/full/2.jpg" title="Portfolio Item">
<i class="icon--zoom"></i>
</a>
</div>
</div>
</div>
<!-- .Portfolio-action end -->
</div>
<!-- .Portfolio-hover end -->
</div>
<!-- .Portfolio-
And in this single.blade.php i needed slug filed so can open with page, but differernt form has different slug filed like title for form1 , poistion for form2 and session for form3. Is any possibility to show all data in one link with slug with different submit button
Why not just use google and search for "submit from ajax"
here is one using jQuery
https://code.tutsplus.com/tutorials/submit-a-form-without-page-refresh-using-jquery--net-59
thanks @tray2 once again, I tried with google, here is problem is that i needed slug filed so can open with page, but differernt form has different slug filed like title for form1 , poistion for form2 and session for form3. Is any possibility to show all data in one link with slug with different submit button.
Probably but I think you are making it more complex that it needs to be.
Since I don't know what your table looks like it's hard do give the correct advice
Yes but what does the table look like where you store the information submitted?
What information is it that you submit?
@tray2 , this is my table,
Schema::create('past_events', function (Blueprint $table) {
$table->bigIncrements('id');
$table->LONGTEXT('title')->nullable();
$table->date('event_date')->nullable();
$table->string('event_video_link')->nullable();
$table->string('event_place_name')->nullable();
$table->string('speaker_name')->nullable();
$table->string('speaker_position')->nullable();
$table->string('event_session_name')->nullable();
$table->string('session_time')->nullable();
$table->string('session_person_name')->nullable();
$table->string('session_person_topic')->nullable();
//necessary
$table->string('slug');
$table->unsignedInteger('category_id');
// Optional Content
$table->string('Featured')->nullable();
$table->string('Featured1')->nullable();
$table->string('File')->nullable();
$table->string('Image')->nullable();
//model components
$table->softDeletes();
$table->timestamps();
});
@tray2 , As I have 3 button so it's creating individual id for each submit and I want to post in single way
Then use the same on click function for them all.
I agree, if form is too large, use session to temporarily hold some of the data.
If ajax the variables will hold the data, and you could show, hide div's as needed.
You could also search for laravel multi part form, a lot of answers should come up.
you may try to make the thing as simple as possible first.
if the another 2 form sections are not mandatory, can just show it only on edit form, ket the create form to serve only the mandatory information.
@tray2 , I used and it's submitting data, however, I want to submit the data from different button but want to view in one post, but in my case it's creating ID each time ,How could do that? thanks
@siangboon , All field are mandatory in each section for submit the individual button, I want to just view in one post, Please give an example
@jlrdw , I searched as @siangboon and @tray2 has suggested, however, I have large data for each section everytime so , not getting idea, to how do that, thanks
It should be understood that CREATE method is creataing a new record hence we should expect that new id will be generated.
Since all the fields are mandatory then just one "CREATE" form to include all sections but only one submit button to submit all data at once, and once submitted redirect back to "EDIT" form with each update button on each section to allow them update each section accordingly (you can either have differetn method to handle each section update or do some checking in single method) .
@siangboon , thanks, I am trying to like you said, I am redirected to new store method, but when doing that, my jquery not responding
here is code I did in redirect---> return redirect()->route('past_event.store2','id');
public function store1(Request $request) {
// dd($request->all());
$this->validate($request, [
'title' =>'required',
'event_video_link'=>'required',
'event_place_name'=>'required',
'event_date'=>'required',
'Image'=>'mimes:jpeg,pdf,docx,png:5000',
'category_id'=>'required',
]);
// Create Initial Required Data Array
$data = [
'title'=>$request->title,
'event_video_link'=>$request->event_video_link,
'event_place_name'=>$request->event_place_name,
'category_id'=>$request->category_id,
'slug'=>str_slug($request->title),
// $date = date('Y-m-d H:i:s'),
// $date_time = Carbon::createFromFormat('Y-m-d H:i:s', $date)
// ->format('d-m-Y'),
'event_date'=>Carbon::parse(strtotime($request->event_date))->format('Y-m-d'),
];
if($request->has('title'))
{
$data['title']=$request->title;
}
if($request->has('event_video_link'))
{
$data['event_video_link']=$request->event_video_link;
}
if($request->has('event_place_name'))
{
$data['event_place_name']=$request->event_place_name;
}
if (request('Image')) {
$Image = request('Image');
$file_name = time() . $Image->getClientOriginalName();
$Image->move('uploads/past', $file_name);
$data['Image'] = 'uploads/past/'.$file_name;
}
// Create the Post with the $data Array
past_events::create($data);
//$post=Post::whereBetween('created_at',[$date_time, $to])->get();
Session::flash('success', 'New Blog has been Published on Website for Particular Menu');
return redirect()->route('past_event.store2','id');
}
Can you help to correct, why it's not happening?
sorry, i'm lost on what you are doing, and not sure what exactly you mean jquery not responding (and i'm not good in jquery also)..
Perhaps tray2 can help or you may create another thread for the jquery error and paste your error message also...
but personally, i would try to disable or ignore any javascript issue before i solve the main store issue first...
btw, your return does not seem so right, it should have value i think, for example:
return redirect()->route('past_event.store2', ['id' => 1324]);
@siangboon Thanks, I have solved the jQuery issue, however in return redirect()->route('past_event.store2', ['id' => 1324]); , the 1324, is unique or I have to enter manually, and what is next to do...:)
First I'd strongly suggest you watch the Laravel 5.7 from scratch series here on laracasts since most of the stuff you need is covered there.
The value that @siangboon are refering to as 1234 is the id of the record you just created.
$pastEventId = past_events::create($data);
Session::flash('success', 'New Blog has been Published on Website for Particular Menu');
return redirect()->route('past_event.store2',['id' => $pastEventId]);
What is this part?
if($request->has('title'))
{
$data['title']=$request->title;
}
if($request->has('event_video_link'))
{
$data['event_video_link']=$request->event_video_link;
}
if($request->has('event_place_name'))
{
$data['event_place_name']=$request->event_place_name;
}
You have already validated the request and this code wouldn't be executed unless the validation succeds. And you have already assigned the $data array before this code.
OP. take some free jQuery tutorials somewhere then come back to the problem.
You are trying to make one post a lengthy tutorial, just my opin
Or at least start a new post for jQuery issues.
thanks @tray2 yes, i am using jquery to store the id of first form then tried to validate the id, but it's not working..since i used all methid
@jlrdw thanks, i goes through tutorial , but still on same issue, i think i have to used multiarray for it
Since you are now having jQuery issues, you may want to create a new post.
Please or to participate in this conversation.