Welcome Guest, Not a member yet? Register   Sign In
Filter object not of user
#1

Hi , i have several table's row with user_id field , for example table a,b and c ,for  every controller about  this table i must filter user to prevent show and modify of every row that haven't user_id not equal to session->get('user_id') . How can i do this? I must create a filter for every table or a single filter ?
Reply
#2

Maybe something similare where I'm in too ;-) I hope I understand you right:

It seems, that you want a "basicUserModel" where you create a function for filter like this:


PHP Code:
public function filter($id)
{
    $this->whereNot('id'$id);
    return $this;

And then you extend this model with userAModel() or userBModel() and so on. In your controller you can use $userAModel()->filter($id)->findAll();
So you have one function to filter and you can you use it in serveral models.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB