Modifica delle route per i tags
This commit is contained in:
parent
51b0d71204
commit
6f16876a69
@ -12,34 +12,39 @@ class TagController extends Controller
|
||||
$tags = tag::getList();
|
||||
return view('conti.tags.list',['tags'=>$tags]);
|
||||
}
|
||||
|
||||
|
||||
public static function insTags(Request $request)
|
||||
{
|
||||
tag::inserisci($request);
|
||||
$tags = tag::getList();
|
||||
return view('conti.tags.list',['tags'=>$tags]);
|
||||
}
|
||||
|
||||
|
||||
public function calendartest()
|
||||
{
|
||||
return view('components.calendar');
|
||||
}
|
||||
|
||||
|
||||
public function updateTag($id)
|
||||
{
|
||||
$tags=tag::getById($id);
|
||||
return json_encode($tags);
|
||||
}
|
||||
|
||||
|
||||
public function updatePostTag(Request $request)
|
||||
{
|
||||
tag::updateById($request);
|
||||
return redirect(route('tags'));
|
||||
}
|
||||
|
||||
|
||||
public function apiList()
|
||||
{
|
||||
$tags=tag::getList();
|
||||
return json_encode($tags);
|
||||
}
|
||||
|
||||
public function deleteTag($id){
|
||||
tag::delete($id);
|
||||
return redirect(route('tags'));
|
||||
}
|
||||
}
|
||||
|
@ -9,28 +9,35 @@ use Illuminate\Support\Facades\DB;
|
||||
class tag extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
public static function getList() {
|
||||
return DB::table('tags')->orderBy('tag_name')->get();
|
||||
return DB::table('tags')->orderBy('tag_name')->get();
|
||||
}
|
||||
|
||||
|
||||
public static function inserisci($param) {
|
||||
DB::table('tags')->insert(['tag_name'=> $param['tag_name']]);
|
||||
}
|
||||
|
||||
|
||||
public static function getById($param) {
|
||||
return DB::table('tags')
|
||||
->where('tags.id','=',$param)
|
||||
->get();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function updateById($param) {
|
||||
DB::table('tags')
|
||||
->where('id','=', $param['id'])
|
||||
->update([
|
||||
'tag_name' => $param['tag_name'],
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static function delete($id)
|
||||
{
|
||||
DB::table('tags')
|
||||
->where('id','=',$id)
|
||||
->delete();
|
||||
}
|
||||
}
|
||||
|
4
public/js/app/tag.js
vendored
4
public/js/app/tag.js
vendored
@ -3,7 +3,7 @@ $(document).ready(function() {
|
||||
responsive: true
|
||||
});
|
||||
$(document).on('click', '.open_modal', function() {
|
||||
var url = "tagmodify";
|
||||
var url = "tags/modify";
|
||||
var riga_id = $(this).val();
|
||||
$.getJSON(url + '/' + riga_id, function(data) {
|
||||
//success data
|
||||
@ -18,4 +18,4 @@ $(document).ready(function() {
|
||||
$('#myModal_new').modal('show');
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -23,7 +23,7 @@
|
||||
$tag->tag_name; }}</a></td>
|
||||
<td><button class="btn btn-warning btn-detail open_modal"
|
||||
value="{{ $tag->id; }}">Edit</button> <a
|
||||
class="btn btn-danger" href="/admin/tagdelete?id={{ $tag->id; }}"><i
|
||||
class="btn btn-danger" href="/admin/tags/delete/{{ $tag->id; }}"><i
|
||||
class="fa fa-trash-o fa-fw"></i></a> </td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@ -34,7 +34,7 @@
|
||||
</div>
|
||||
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
|
||||
aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<form action="tagmodify" method="POST">
|
||||
<form action="/admin/tags/modify" method="POST">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
|
@ -60,8 +60,9 @@ Route::get('/', [MovimentiController::class,'dashboard']);
|
||||
// TAGS
|
||||
Route::get('tags', [TagController::class,'listTags'])->name('tags');
|
||||
Route::post('tags', [TagController::class,'insTags']);
|
||||
Route::get('tagmodify/{id}', [TagController::class,'updateTag']);
|
||||
Route::post('tagmodify', [TagController::class,'updatePostTag']);
|
||||
Route::get('tags/modify/{id}', [TagController::class,'updateTag']);
|
||||
Route::post('tags/modify', [TagController::class,'updatePostTag']);
|
||||
Route::get('tags/delete/{id}',[TagController::class,'deleteTag']);
|
||||
|
||||
// CONSUMI
|
||||
Route::get('consumi/gas', [ContatoreGasController::class,'listLettureGas'])->name('gas');
|
||||
|
Loading…
Reference in New Issue
Block a user