retrieving user data from mitarbeiter and benutzer models

This commit is contained in:
SimonGschnell
2023-11-14 14:36:47 +01:00
parent 5b385d376e
commit 9227cc12f0
4 changed files with 28 additions and 5 deletions
+18 -5
View File
@@ -18,6 +18,8 @@ class Profil extends Auth_Controller
'index' => ['student/anrechnung_beantragen:r','user:r'], // TODO(chris): permissions?
'getUser' => ['student/anrechnung_beantragen:r','user:r']
]);
$this->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel');
$this->load->model('person/Benutzer_model', 'BenutzerModel');
}
// -----------------------------------------------------------------------------------------------------------------
@@ -33,15 +35,26 @@ class Profil extends Auth_Controller
$this->load->view('Cis/Profil', ["uid" => getAuthUID()]);
}
//? public function getUser returns information related to a user
public function getUser()
{
$myObj = new stdClass();
$myObj->name = "John";
$myObj->age = 30;
$myObj->city = "New York";
echo json_encode($myObj);
//* retrieve info from the Mitarbeiter model
$mitarbeiter_result = $this->MitarbeiterModel->load(getAuthUID());
//* retrieve info from the Benutzer model
$benutzer_result = $this->BenutzerModel->load([getAuthUID()]);
//* return JSON with info
$res = ['mitarbeiter' => $mitarbeiter_result,
'Benutzer' => $benutzer_result];
echo json_encode($res);
}
//? this idea was to use _remap, to call different views based on the type of user
/*
public function _remap($param)
{
+3
View File
@@ -17,6 +17,9 @@ const app = Vue.createApp({
methods: {
testsearch: function() {
return Vue.$fhcapi.UserData.getUser();
},
testsearch2: function() {
return Vue.$fhcapi.UserData.getUser2("ma0594");
}
},
+5
View File
@@ -5,6 +5,11 @@ export default {
+ 'Cis/Profil/getUser';
return axios.get(url);
},
getUser2: function(uid) {
const url = FHC_JS_DATA_STORAGE_OBJECT.app_root
+ 'models/person/Benutzer_model/getFromPersonId';
return axios.get(url,{params: {uid}});
},
getUserDumy: function(){
const url = FHC_JS_DATA_STORAGE_OBJECT.app_root
+ 'public/js/apps/api/dummyapi.php/getUser';
@@ -16,6 +16,8 @@ export default {
this.$parent.testsearch().then((res) => {
this.person = res.data;
});
},
template: `