Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model - problem with parameters #17

Open
SilverEngineTeam opened this issue Jan 15, 2018 · 3 comments
Open

Model - problem with parameters #17

SilverEngineTeam opened this issue Jan 15, 2018 · 3 comments

Comments

@SilverEngineTeam
Copy link
Member

We need to fix problem with ReflectORM and model to filter the methods from App/Models/* $hidden, $selectable, $fiterable, $includable, $editable,...

@mawaishanif
Copy link
Member

mawaishanif commented Jan 16, 2018

Can you elaborate more on this? I can take it.

@SilverEngineTeam
Copy link
Member Author

SilverEngineTeam commented Jan 18, 2018

App/Models/*.php

namespace App\Models;

use Silver\Database\Model;

/**
 * Users Model
 */
class Users extends Model
{
    protected static $_table = 'users';
    
    // this need to catch when you do in controller    Users::all();    or Users::find($id);  
    protected $hidden = [
        'password',
    ];
}

if users have for example: "email, password, token, activate" -> when you call model if is something inside hidden must not show to the view or in response

Path to DB:
System/Database/* -> inside here is entire ORM

ORM docs
https://github.com/SilverEngine/Framework/wiki/ReflectORM

@SilverEngineTeam
Copy link
Member Author

SilverEngineTeam commented Jan 18, 2018

Simple way of fixing just to show

$model  = new $class;
$hidden = [];
 try {
     $hidden = $model->getHidden();
     $hidden = array_combine($hidden, $hidden);
 }catch (Exception $ex){
      ...
 }

gethidden is from model line 100+

    /**
     * @return mixed
     */
    public function getHidden()
    {
        return $this->hidden;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants