I am trying to limit the amount of data based on particular roles. For example an admin may be able to see everything, but a user can only see some things. In order to limit that I use joins and where statements in each query. Using ORM, is there anyway I can take a user role in as a parameter and add a join based on the query? This is my current code.
public static function findData($parameters=null)
{
var_dump($parameters);
foreach ($parameters as $key => $value) {
if ($key == "role") {
if (in_array($value,array(5,6,7))){
self::query()->join('Mac\Models\Content','user_id = contentU.contentU_user_id ','contentU');
}
}
}
return parent::find($parameters);
}
Also Is there anyway to output the query as well from an ORM through static self? For example self::getQuery()?
Thanks for any help!