Popup Modifica categorie aggiornato e funzionante
This commit is contained in:
parent
b191cfc133
commit
377b41c629
@ -28,17 +28,17 @@ class CategorieController extends Controller
|
||||
Categorie::deleteById($request['id']);
|
||||
return redirect(route('categorie'));
|
||||
}
|
||||
public function updateCategorie(Request $request)
|
||||
/*public function updateCategorie(Request $request)
|
||||
{
|
||||
$id=$request['id'];
|
||||
|
||||
$categorie = Categorie::getById($id);
|
||||
/* return view('conti.categorie.update',
|
||||
return view('conti.categorie.update',
|
||||
[
|
||||
'categorie'=> $categorie,
|
||||
]);*/
|
||||
return json_encode($categorie);
|
||||
}
|
||||
]);
|
||||
|
||||
}*/
|
||||
|
||||
public function updatePostCategorie(Request $request)
|
||||
{
|
||||
@ -52,4 +52,10 @@ class CategorieController extends Controller
|
||||
$categorie=Categorie::list();
|
||||
return response()->json($categorie);
|
||||
}
|
||||
|
||||
public function updateCategorie($id)
|
||||
{
|
||||
$categorie = Categorie::getById($id);
|
||||
return json_encode($categorie);
|
||||
}
|
||||
}
|
||||
|
@ -66,17 +66,18 @@
|
||||
<div class="panel-heading">Modifica categorie</div>
|
||||
<div class="panel-body">
|
||||
<form action="catmodify" method="POST">
|
||||
@foreach($categorie as $categoria) @csrf
|
||||
|
||||
@csrf
|
||||
<div class="mb-3">
|
||||
<label for="categoria" class="form-label">Categoria</label> <input
|
||||
type="text" class="form-control" id="categoria" size="50"
|
||||
name="cat_name" value="{{ $categoria->cat_name }}">
|
||||
<label for="H_cat_cat_name" class="form-label">Categoria</label> <input
|
||||
type="text" class="form-control" id="H_cat_cat_name" size="50"
|
||||
name="cat_name" value="">
|
||||
</div>
|
||||
<input type="hidden" name="id" id="id" value="{{ $_GET['id']; }}">
|
||||
<input type="hidden" name="id" id="H_cat_id" >
|
||||
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
|
||||
@endforeach
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@ -99,12 +100,12 @@
|
||||
$(document).on('click','.open_modal',function(){
|
||||
var url = "catmodify";
|
||||
var riga_id= $(this).val();
|
||||
$.get(url + '/' + riga_id, function (data) {
|
||||
$.getJSON(url + '/' + riga_id, function (data) {
|
||||
//success data
|
||||
console.log(data);
|
||||
console.log(data[0].descrizione);
|
||||
$('#categoria').val(data[0].cat_name);
|
||||
$('#id').val(data[0].id);
|
||||
console.log(data[0]);
|
||||
console.log(data[0].cat_name);
|
||||
$('#H_cat_cat_name').val(data[0].cat_name);
|
||||
$('#H_cat_id').val(data[0].id);
|
||||
$('#myModal').modal('show');
|
||||
});
|
||||
});
|
||||
|
@ -49,7 +49,7 @@ Route::get('/', [MovimentiController::class,'dashboard']);
|
||||
Route::get('categorie', [CategorieController::class,'listCategorie'])->name('categorie');
|
||||
Route::post('categorie', [CategorieController::class,'insCategorie']);
|
||||
Route::get('catdelete', [CategorieController::class,'deleteCategorie']);
|
||||
Route::get('catmodify', [CategorieController::class,'updateCategorie']);
|
||||
Route::get('catmodify/{id}', [CategorieController::class,'updateCategorie']);
|
||||
Route::post('catmodify', [CategorieController::class,'updatePostCategorie']);
|
||||
// TAGS
|
||||
Route::get('tags', [TagController::class,'listTags'])->name('tags');
|
||||
|
Loading…
Reference in New Issue
Block a user