You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Data classes are should be in a different layer. You can populate models in the controller layer. There is a pseudo code in the below code;
// list type model
List sampleModel {
public $id;
public$userName;
}
// foo controller
// get data from data layer
$data = $sampleData->getSampleData();
// init an array as sampleModel
var $sampleModel = newList<sampleModel>();
// iterate data and populate the array you initialized.foreach($dataas$modelData) {
sampleModel.Add(new sampleModel
{
$id => $modelData->id,
$userName => $modelData->userName;
});
}
// responseechojson_encode($sampleModel);
The text was updated successfully, but these errors were encountered:
Thanks for your valuable suggestions. When I was preparing SlimMVC, I thought the models as a data layer without solid rules. Your idea's more closest to OOP logic. But, the Slim hasn't a CLI like the Laravel Framework and the model layers not limited to single dependency. If I prepare your ideas in SlimMVC, I must write a CLI and I must find a dependency that supports SQL and NoSQL database platforms.
Therefore, I labeled this issue as an enhancement.
https://www.slimmvc.com/docs/basics/model
I read model documentation using the above URL.
I think models shouldn't contain functions.
Instead of this;
This example could be good.
Data classes are should be in a different layer. You can populate models in the controller layer. There is a pseudo code in the below code;
The text was updated successfully, but these errors were encountered: