Modifica delle route per i tags
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user