I have a view where I pull the data with an "onclick" of the "Asisgnar" button and when I click on the "Enviar formulario" button, an email is sent directly with the loaded data... this works perfectly, but I would like it to be sent the mail without redirecting me to another page.
My form code
<form action="{{route('contactanos.store')}}" method="POST">
{{ csrf_field() }}
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<label for="inspector">Inspector</label>
<select class="form-select col-xs-12 col-sm-12 col-md-12" aria-label="Default select example" id="inspector" for="inspector" name="inspector" >
<option selected></option>
#foreach($users as $user)
<option value="{{ $user->name }}">{{ $user->name }}</option>
#endforeach
</select>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<label for="estado">Estado</label>
<select class="form-select col-xs-12 col-sm-12 col-md-12" aria-label="Default select example" id="estado" for="estado" name="estado">
<option selected></option>
<option value="Pendiente">Pendiente</option>
<option value="Coordinado">Coordinado</option>
<option value="Peritando">Derivado a inspector</option>
<option value="Baja">Baja</option>
</select>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<label for="localidad">Localidad</label>
<input type="text" name="localidad" id="localidad" class="form-control" >
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<label for="fechaip">Fecha IP</label>
<input type="date" name="fechaip" id="fechaip" class="form-control" >
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<label for="siniestro">Siniestro</label>
<input type="text" name="siniestro" id="siniestro" class="form-control" >
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<label for="inspector">Inspector</label>
<select class="form-select col-xs-12 col-sm-12 col-md-12" aria-label="Default select example" id="emailperito" for="emailperito" name="emailperito" >
<option selected></option>
#foreach($users as $user)
<option value="{{ $user->email }}">{{ $user->name }}</option>
#endforeach
</select>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<label for="email">Email taller</label>
<input type="text" name="email" id="email" class="form-control" >
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<label for="patente">Patente</label>
<input type="text" name="patente" id="patente" class="form-control" >
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<label for="modalidad">Tipo de inspección</label>
<input type="text" name="modalidad" id="modalidad" class="form-control" >
</div>
</div>
<input type="hidden" id="id">
<button type="submit" id="updateButton" class="btn btn-success" onclick="updateData(event)">Guardar</button>
<button type="submit" class="btn btn-primary float-right">Enviar formulario</button>
</form>
Controller Code to send mail
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
//mail
use App\Mail\ContactanosMailable;
use Illuminate\Support\Facades\Mail;
use App\Models\Siniestro;
class CoordinacionesController extends Controller
{
public function index(){
return view('contactanos.index');
}
public function store(Request $request){
$siniestro = Siniestro::paginate(1000);
$this->siniestro = $siniestro;
$email = $this->siniestro['emailperito'];
$cc = $this->siniestro['email'];
$correo = new ContactanosMailable($request->all());
Mail::to($email)->cc($cc)->send($correo);
return redirect()->route('siniestros.index');
}
}
View.blade
My view
I have tried removing the post method and removing the "return redirect()->route('sinisters.index');" of the controller, but it doesn't work.
you can do it with an ajax like this
$.ajax({
url: '{{route("your-route")}}',
method: "POST",
data: {
_token: '<?php echo csrf_token() ?>',
... // the rest of your form
}
})
Try this solution
add jquery in your blade file
jquery cdn
<script src="https://code.jquery.com/jquery-3.6.0.min.js" crossorigin="anonymous"></script>
Give class to your form
<form action="{{route('contactanos.store')}}" method="POST" class="my_form">
Change your javascript code as per below
$(document).on('submit', '.my_form', function (event) {
event.preventDefault();
var form = $(this);
$.ajax({
type: form.attr('method'),
url: form.attr('action'),
data: form.serialize(),
success: function (response) {
if(response.success){
//handle success message
} else {
//handle error message
}
},
error: function (xhr, textStatus, errorThrown) {
console.log("ERROR");
}
});
});
change your controller->store function
public function store(Request $request){
try {
$siniestro = Siniestro::paginate(1000);
$this->siniestro = $siniestro;
$email = $this->siniestro['emailperito'];
$cc = $this->siniestro['email'];
$correo = new ContactanosMailable($request->all());
Mail::to($email)->cc($cc)->send($correo);
return response()->json([
'success' => true,
'message' => 'Your success message'
]);
} catch (\Throwable $th) {
return response()->json([
'success' => false,
'message' => 'Your error message'
]);
}
}
Data insert & Delete works fine. However, the edit doesn't update the data. Instead it inserts a new one..
I have INSERT & UPDATE in a single file, made with if conditions:
<?php
include ("./backend/config/connection.php");
include ("./backend/config/function.php");
if (isset($_POST["traffic_operation"])) {
if (isset($_POST["traffic_operation"]) == "Add") {
$traffic_doc = "";
if ($_FILES["traffic_doc"]["name"] != "") {
$traffic_doc = upload_image();
}
$statement = $connection->prepare('INSERT INTO traffic_violations (
plateNumber,
carModel,
carColor,
violationType,
ownerGender,
violationDateTime,
violationLocation,
workingShift,
violationAction,
violationStatement,
cccEmployee
) VALUES (
:plate_number,
:car_model,
:car_color,
:violation_type,
:owner_gender,
:violation_date,
:violation_location,
:working_shift,
:violation_action,
:traffic_doc,
:ccc_employee
)
');
$result = $statement->execute([
":plate_number" => $_POST["plate_number"],
":car_model" => $_POST["car_model"],
":car_color" => $_POST["car_color"],
":violation_type" => $_POST["violation_type"],
":owner_gender" => $_POST["owner_gender"],
":violation_date" => $_POST["violation_date"],
":violation_location" => $_POST["violation_location"],
":working_shift" => $_POST["working_shift"],
":violation_action" => $_POST["violation_action"],
":traffic_doc" => $traffic_doc,
":ccc_employee" => $_POST["ccc_employee"],
]);
if (!empty($result)) {
echo 'Traffic Violation Added';
}
}
if ($_POST["traffic_operation"] == "Edit") {
$traffic_doc = "";
if ($_FILES["traffic_doc"]["name"] != "") {
$traffic_doc = upload_image();
}
$statement = $connection->prepare('UPDATE traffic_violations SET
plateNumber = :plate_number,
carModel = car_model,
carColor = car_color,
violationType = violation_type,
ownerGender = owner_gender,
violationDateTime = violation_date,
violationLocation = violation_location,
workingShift = working_shift,
violationAction = violation_action,
violationStatement = traffic_doc,
cccEmployee = ccc_employee,
WHERE id = :id');
$result = $statement->execute([
":id" => $_POST["violation_id"],
":plate_number" => $_POST["plate_number"],
":car_model" => $_POST["car_model"],
":car_color" => $_POST["car_color"],
":violation_type" => $_POST["violation_type"],
":owner_gender" => $_POST["owner_gender"],
":violation_date" => $_POST["violation_date"],
":violation_location" => $_POST["violation_location"],
":working_shift" => $_POST["working_shift"],
":violation_action" => $_POST["violation_action"],
":traffic_doc" => $traffic_doc,
":ccc_employee" => $_POST["ccc_employee"],
]);
if (!empty($result)) {
echo "Traffic Violation Updated";
}
}
}
?>
I also use Ajax:
$(document).ready(function() {
$("#add_btn").on('click', function() {
$("#traffic_violation_form")[0].reset();
$(".violation-title").text("Add New Violation");
$("#traffic_action").val("Add");
$("#traffic_operation").val("Add");
$("#traffic_doc").html('');
});
var dataTable = $('.violation_data').DataTable({
"processing": true,
"serverSide": true,
"order": [],
"ajax": {
url: "/traffic-fetch",
type: "POST"
},
"columnDefs": [
{
"target": [0, 3, 4],
"orderable": false
}
]
});
// For Inserting New Violation
$(document).on('submit', '#traffic_violation_form', function(e){
e.preventDefault();
var plateNumber = $("#plate_number").val();
var carModel = $("#car_model").val();
var carColor = $("#car_color").val();
var ownerGender = $("#owner_gender").val();
var violationType = $("#violation_type").val();
var violationLocation = $("#violation_location").val();
var workingShift = $("#working_shift").val();
var violationAction = $("#violation_action").val();
var violationStatement = $("#traffic_doc").val().split('.').pop().toLowerCase();
var cccEmployee = $("#ccc_employee").val();
if(violationStatement != '') {
if( $.inArray(violationStatement, ['jpg', 'jpeg', 'JPG', 'JPEG', 'png', 'PNG', 'webp', 'WEBP']) == -1 ) {
alert('Invalid file type.');
$("#traffic_doc").val();
return false;
}
}
if( plateNumber !='' && carModel !='' && carColor !='' && ownerGender !='' && violationType !='' && violationLocation !='' && workingShift !='' && violationAction !='' && cccEmployee !='') {
$.ajax({
url: "/traffic-insert",
method: "POST",
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
success: function(data) {
$("#traffic_violation_form")[0].reset();
$("#trafficModal").modal('hide');
dataTable.ajax.reload();
}
});
}
else {
alert('Nothing should left empty!');
}
});
// For Updating Violation
$(document).on('click', '.update', function(){
var violation_id = $(this).attr("id");
$.ajax({
url:"/traffic-edit",
method:"POST",
data:{violation_id:violation_id},
dataType:"json",
success:function(data)
{
$("#trafficModal").modal('show');
$(".violation-title").text("Edit Violation");
$("#violation_id").val(violation_id);
$("#plate_number").val(data.plate_number);
$("#car_model").val(data.car_model);
$("#car_color").val(data.car_color);
$("#owner_gender").val(data.owner_gender);
$("#violation_type").val(data.violation_type);
$("#violation_location").val(data.violation_location);
$("#working_shift").val(data.working_shift);
$("#violation_action").val(data.violation_action);
$("#ccc_employee").val(data.ccc_employee);
$("#user_uploaded_image").html(data.violationStatement);
$("#traffic_action").val("Edit");
$("#traffic_operation").val("Edit");
}
})
});
$(document).on('click', '.delete', function(){
var violation_id = $(this).attr("id");
if(confirm("Are you sure you want to delete this?"))
{
$.ajax({
url:"/traffic-delete",
method:"POST",
data:{violation_id:violation_id},
success:function(data)
{
alert(data);
dataTable.ajax.reload();
}
});
}
else
{
return false;
}
});
});
And here is the HTML form:
<form name="traffic_violation_form" id="traffic_violation_form" action="/traffic-process" method="POST" enctype="multipart/form-data">
<div class="modal-body" id="violation-data">
<div class="form-row">
<div class="col-md-6 mb-3">
<div class="form-group">
<label class="form-control-label" for="plate_number">Plate Number</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Plate #</span>
</div>
<input type="text" class="form-control" id="plate_number" name="plate_number" >
</div>
</div>
</div>
<div class="col-md-6 mb-3">
<div class="form-group">
<label class="form-control-label" for="car_model">Vehicle Model</label>
<div class="input-group">
<input type="text" class="form-control" id="car_model" name="car_model" >
</div>
</div>
</div>
<div class="col-md-6 mb-3">
<div class="form-group">
<label class="form-control-label" for="car_color">Vehicle Color</label>
<div class="input-group">
<input type="text" class="form-control" id="car_color" name="car_color" >
</div>
</div>
</div>
<div class="col-md-6 mb-3">
<div class="form-group">
<label class="form-control-label" for="owner_gender">Owner Gender</label>
<div class="input-group">
<select class="form-control" name="owner_gender" id="owner_gender" data-toggle="select" >
<option value="" disabled selected>Select Gender</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="No driver">No Driver</option>
</select>
</div>
</div>
</div>
<div class="col-md-6 mb-3">
<div class="form-group">
<label class="form-control-label" for="violation_type">Violation Type</label>
<select data-toggle="select" class="form-control" name="violation_type" id="violation_type" >
<option value="" disabled selected>Select violation type</option>
<option value="Speeding">Speeding</option>
<option value="Drifting">Drifting</option>
<option value="Pass traffic light">Pass traffic light</option>
</select>
</div>
</div>
<div class="col-md-6 mb-3">
<div class="form-group">
<label class="form-control-label" for="violation_location">Violation Location</label>
<select class="form-control" name="violation_location" id="violation_location" data-toggle="select" >
<option value="" disabled selected>Select Location</option>
<option value="Baylasun">Baylasun</option>
<option value="Baylasun Hotel">Baylasun Hotel</option>
<option value="AL-Waha">AL-Waha</option>
<option value="Al-Morooj">Al-Morooj</option>
<option value="Royal Green">Royal Green</option>
<option value="Beach Towers">Beach Towers</option>
<option value="Emmar Building">Emmar Building</option>
<option value="Industrial Area (East)">Industrial Area (East)</option>
<option value="Industrial Area (West)">Industrial Area (West)</option>
<option value="Hejaz Gate">Hejaz Gate</option>
<option value="Gate 3">Gate 3</option>
<option value="Marina 1">Marina 1</option>
<option value="Marina 2">Marina 2</option>
<option value="Marina 3">Marina 3</option>
<option value="Tala Garden">Tala Garden</option>
<option value="AL-Shorooq">AL-Shorooq</option>
<option value="Yam Beach">Yam Beach</option>
<option value="Sales Center">Sales Center</option>
</select>
</div>
</div>
<div class="col-md-6 mb-3">
<div class="form-group">
<label class="form-control-label" for="violation_date">Violation Created At</label>
<input class="form-control" type="datetime-local" name="violation_date" id="violation_date" >
</div>
</div>
<div class="col-md-6 mb-3">
<div class="form-group">
<label class="form-control-label" for="working_shift">Working Shift</label>
<select class="form-control" name="working_shift" id="working_shift" data-toggle="select" >
<option value="" disabled selected>Select Shift</option>
<option value="Morning">Morning (A)</option>
<option value="Evening">Evening (B)</option>
<option value="Night">Night (C)</option>
</select>
</div>
</div>
<div class="col-md-6 mb-3">
<div class="form-group">
<label class="form-control-label" for="traffic_doc">Violation Statement</label>
<input type="file" class="form-control" id="traffic_doc" name="traffic_doc" >
<span id="user_uploaded_image"></span>
</div>
</div>
<div class="col-md-6 mb-3">
<div class="form-group">
<label class="form-control-label" for="ccc_employee">CCC Employee</label>
<input type="text" class="form-control" id="ccc_employee" name="ccc_employee" >
</div>
</div>
<div class="col-md-12 mb-3">
<div class="form-group">
<label class="form-control-label" for="violation_action">Violation Action</label>
<textarea class="form-control" name="violation_action" id="violation_action" ></textarea>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="violation_id" id="violation_id" />
<input type="hidden" name="traffic_operation" id="traffic_operation" />
<input type="submit" name="traffic_action" id="traffic_action" class="btn btn-primary" value="Add" />
</div>
</form>
The issue is in your condition that you are trying to compare with "Add"
The output of $_POST["traffic_operation"]) will be TRUE OR FALSE.
So replace the below line
if (isset($_POST["traffic_operation"]) == "Add")
with
if ( (isset($_POST["traffic_operation"]) AND ($_POST["traffic_operation"] == "Add") )
<div class="form-group col-sm-6">
<label for="" class="control-label">Skill</label> <br>
<select name="skill[]" class="select-skill-only form-control" id="req-skill" multiple="multiple" required>
#foreach ($skill2 as $skill)
<option value="{{$skill->skill_id}}">{{$skill->skill_name}}</option>
#endforeach
</select>
</div>
<div class="form-group col-sm-6">
<label for="" class="control-label">Skill Priority</label> <br>
<select name="priority[]" class="select-skill-only form-control" id="req-priority" multiple="multiple" required>
#foreach ($skill2 as $priorityskill)
<option value="{{$priorityskill->skill_id}}">{{$priorityskill->skill_name}}</option>
#endforeach
</select>
</div>
set a listener for change any select and get value it after any change.
for this you give id to selects.
for example :
let skills = [];
$('#skill-select').on('change', function(){
skills = $(this).val();
$('#priority-select > option').each(function() {
if(!skills.includes($(this).val())){
$(this).prop('disabled', true)
}
});
});
and use skills selected array everywhere
I have select option input. When I choose the number on it and than click the button, I want to display the forms. The number of form displayed based on the select option I choose. I don't know how to loop it in jquery and make the form display:none (before the button click the form is not visible). And is it posible to input more than one data in one table in the same time and how to do that? I've tried this
Thank You
<div class="form-group col-sm-6">
<label for="sel1">Jrekrut : </label>
<select class="form-control" name="sel1" id="sel1" >
<option selected>Pilih</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option> </select>
</div>
<form class="form-horizontal striped-rows b-form" id="form1">
<div class="card-body">
<div class="form-group row">
<div class="col-sm-3">
<div class="b-label">
<label for="inputEmail3" class="control-label col-form-label">Full Name</label>
</div>
</div>
<div class="col-sm-9">
<input type="text" class="form-control" id="inputEmail3" placeholder="Full Name Here">
</div>
</div>
</form>
<script type="text/javascript">
var num;
$('#sel1').on('change', function(event) {
alert("This is the value selected in solutions: " + $(this).val());
num = $(this).val();
});
$("#btn").click(function(){
//$("#form1").hide();
$("#form1").toggle();
console.log(num);
});
Okey. So first you need to make a wrapper for all forms like '.form-container' and next you need to create html in javascript and push into it.
$(document).ready(function(){
$('#sel1').on('change', function(event) {
initForms($(this).val());
});
$('body').on('click', '.btn', function(){
$('.form-horizontal').each(function(){
$(this).show();
});
)};
});
function initForms(formCount){
var finalHTML= "";
for(i=0, i<formCount; i++){
var tempHTML ='<form id="$formid$" class="form-horizontal striped-rows b-form" style="display:none;"><div class="card-body"><div class="form-group row"><div class="col-sm-3"><div class="b-label"><label for="inputEmail3" class="control-label col-form-label">Full Name</label></div></div><div class="col-sm-9"><input type="text" class="form-control" id="inputEmail3" placeholder="Full Name Here"></div></div></div></form>';
tempHTML = tempHTML.split("$formid$").join("form-" + i);
finalHTML += tempHTML;
}
$('.form-container').empty().html(finalHTML);
}
I have placed your form in a div with id equal to form_container, so that you can alter the number of forms in a cleaner way.
<div id="form_container">
<form class="form-horizontal striped-rows b-form" id="form1">
...
</form>
</div>
You can then use append() to add more some forms to your div in a for loop.
var num;
$('#sel1').on('change', function(event) {
alert("This is the value selected in solutions: " + $(this).val());
num = $(this).val();
var formHTML = $("#form1").html(); // Get the HTML content of '#form1'
$('#form_container').html(''); // Clear the contents of form_container
for(var i = 0; i < num; i++){
var id = i + 1;
$('#form_container').append('<form class="form-horizontal striped-rows b-form" id="form'+id+'">'+formHTML+'</form>');
}
});
form display:none
<form class="form-horizontal striped-rows b-form" id="form1" style="display:none">
</form>
$('#sel1').click(function(){
$("#form1").show();
});
This question already has answers here:
Stop form refreshing page on submit
(20 answers)
How can I prevent refresh of page when button inside form is clicked?
(16 answers)
Closed 4 years ago.
Im trying to insert data with ajax, but i got error :
Symfony \ Component \ HttpKernel \ Exception \
MethodNotAllowedHttpException
This is my form in add-gallery.blade.php:
<form method="post" action="" enctype="multipart/form-data" autocomplete="off" class="mt-4 mb-4 card p-4">
<div class="form-group">
<div class="row">
<div class="col-md-2 align-self-center">
<label for="gallery_name">Name</label>
</div>
<div class="col-md-6 align-self-center">
<input type="text" name="gallery_name" id="gallery_name" class="form-control" placeholder="Type Gallery Name" />
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-2 align-self-center">
<label for="category">Category</label>
</div>
<div class="col-md-3 align-self-center">
<select class="form-control custom-select" name="category" id="category">
<option value="">Select Category</option>
<option value="Home">Home</option>
<option value="Office">Office</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-2 align-self-center">
<label for="subcategory">Sub Category</label>
</div>
<div class="col-md-3 align-self-center">
<select class="form-control custom-select" name="subcategory" id="subcategory">
<option value="">Select Sub Category</option>
<option value="Interior">Interior</option>
<option value="Eksterior">Eksterior</option>
<option value="Decoration">Decoration</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-2 align-self-center">
<label for="subsubcategory">Subsub Category</label>
</div>
<div class="col-md-3 align-self-center">
<select class="form-control custom-select" name="subsubcategory" id="subsubcategory">
<option value="">Select Subsub Category</option>
<option value="Room">Room</option>
<option value="Bathroom">Bathroom</option>
<option value="Kitchen">Kitchen</option>
<option value="Terrace">Terrace</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-2">
<label for="gallery_image">Image</label>
</div>
<div class="col-md-10">
<div class="fileinput fileinput-new" data-provides="fileinput">
<div class="fileinput-new thumbnail w-100" style="display: none;">
<img src="http://placehold.it/1186x800" />
</div>
<div id="toAnnotate" class="fileinput-preview fileinput-exists thumbnail w-100"></div>
<div>
<span class="btn btn-xs btn-success btn-file"><span class="fileinput-new">Select image</span><span class="fileinput-exists">Change</span><input type="file" name="gallery_image" id="gallery_image"></span>
Remove
</div>
</div>
<p><small><em>Image Size : 1186px (width), 800px (height)</em></small></p>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-2 align-self-center"> </div>
<div class="col-md-10 align-self-center">
<button type="button" class="btn btn-secondary">Cancel</button>
<button type="submit" class="btn btn-success" id="save">Save</button>
</div>
</div>
</div>
</form>
And below is my ajax in same page add-gallery.blade.php:
<script type="text/javascript">
$(document).ready(function (e) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
//Save
$('#save').on('click', function () {
var gallery_name = $('#gallery_name').val();
var category = $('#category').val();
var subcategory = $('#subcategory').val();
var subsubcategory = $('#subsubcategory').val();
var gallery_image = $('#gallery_image').val();
var dataSubmit = $(this).serialize();
var top = top;
var left = left;
var file_data = $('#gallery_image').prop('files')[0];
var form_data = new FormData();
form_data.append('file', file_data);
$.ajax({
url : "{{ url('galleries/store') }}",
dataType : 'text', // what to expect back from the server
cache : false,
contentType : false,
processData : false,
data : form_data,
type : 'post',
dataType : 'json',
success: function (response) {
console.log(response);
},
error: function (response) {
console.log(response);
}
});
});
});
</script>
This is my routes file web.php:
Route::post('galleries/store','Dashboard\GalleryController#store');
And this is my controller GalleryController.php:
public function store(Request $request){
if($request->hasFile('gallery_image')){
$fileImage = $request->file('gallery_image');
$fileImageExtension = $fileImage->extension();
$renameFileImage = 'ImageGalleries'.time().'.'.$fileImageExtension;
$pathFileImage = $fileImage->storeAs('public/galleries_documents/images_galleries', $renameFileImage); /images_articles
$galleries = new Gallery;
$points = new Point;
$galleries->name = $request->gallery_name;
$galleries->category = $request->category;
$galleries->sub_category = $request->subcategory;
$galleries->sub_subcategory = $request->subsubcategory;
$galleries->image = $renameFileImage;
$galleries->lang_id = session('lang_id');
$galleries->save();
$lastInsertId = $galleries->id;
for($i = 0; $i < count($request->node); $i++) {
$node[] = [
'node_position_top' => $request->node[$i],
'node_position_left' => $request->node[$i],
'id_gallery' => $lastInsertId,
];
$points->lang_id = session('lang_id');
}
Point::insert($node); //save to table
print_r($node[]);
exit();
}
}