← Back to Cumulus Core Support
Hello again :)
I have problem!
One user has access to multiple clusters for example schools. Each school has different Classes and Lessons, assigned for this user.
So my problem is -
How to get to correct Classes and Lessons
I was using
class Course extends Model
public $hasMany = [
'lessons' => [
'LoginGrupa\Mbook\Models\Service',
'scope' => 'authLessons',
'order' => 'order asc',
],
In my scope I check to witch to witch cluster/school user belongs, and display correct data.
public function scopeAuthLessons($query)
{
if (\BackendAuth::getUser()) {
return $query->where('school_id', '=', \BackendAuth::getUser()->current_cluster_id);
}
if (\Auth::getUser()) {
return $query->where('school_id', '=', \Auth::getUser()->current_cluster_id);
}
return $query;
// TODO: Add this check only for Add services view
// ->whereNull('course_id')
}
But I do not like this approach, because, I need to all the time check when the user changes cluster, and store it in DB How would you solve this problem?
Last updated
I had a problem that when backend and the fronted user are both authenticated on the same device, then this part does not work right!
My solution was just to make new Frontend model for work with frontend stuff/components and regular model for backend work.
As I have mentioned before, frontend (Cumulus) users and backend users are two different things. Of course you can give access to the same data in frontend and backend as well.
But. By design backend admin is developer like me and you while frontend (Cumulus) user is your client. Your clients are using your application but they must not see any other clients' data. While you as admin can have access to all data of your clients - those are two completely different points of view on application.
So right now, making long story short: in frontend you may use ClusterFiltrable
trait in your models:
class Course extends Model
{
use \Initbiz\CumulusCore\Traits\ClusterFiltrable;
...
After that you can use clusterFiltered()
method on model to filter the data using currently picked cluster :)
Last updated
InIT.biz said:
As I have mentioned before, frontend (Cumulus) users and backend users are two different things. Of course you can give access to the same data in frontend and backend as well.
But. By design backend admin is developer like me and you while frontend (Cumulus) user is your client. Your clients are using your application but they must not see any other clients' data. While you as admin can have access to all data of your clients - those are two completely different points of view on application.
So right now, making long story short: in frontend you may use
ClusterFiltrable
trait in your models:class Course extends Model { use \Initbiz\CumulusCore\Traits\ClusterFiltrable; ...
After that you can use
clusterFiltered()
method on model to filter the data using currently picked cluster :)
Thanks! My app just needs also for few users to access backend data, Yes, I could rebuild in fronted backend functionality, that is in the roadmap. :)
If you want some backend functionality in frontend than maybe you will like Power Components plugin.
It is still under development, but maybe you will like to use it and share your thoughts :)
InIT.biz said:
If you want some backend functionality in frontend than maybe you will like Power Components plugin.
It is still under development, but maybe you will like to use it and share your thoughts :)
Wow, awesome, what crazy tools do you have more up your sleeves :D Awesome work!
1-7 of 7