Skip to content

A free open source IT asset/license management system

scoping shared templates

akemidxef0ff6516286
diff --git a/app/Models/ReportTemplate.php b/app/Models/ReportTemplate.php
index 1d73ce1684..2e5e13768e 100644
--- a/app/Models/ReportTemplate.php
+++ b/app/Models/ReportTemplate.php
@@ -39,14 +39,16 @@ class ReportTemplate extends Model
protected static function booted()
{
- // Scope to current user
-// static::addGlobalScope(
-// 'current_user', function (Builder $builder) {
-// if (auth()->check()) {
-// $builder->where('created_by', auth()->id());
-// }
-// }
-// );
+ // Scope to current user or if template is shared
+ static::addGlobalScope(
+ 'current_user', function (Builder $builder) {
+
+ if (auth()->check()) {
+ $builder->where('created_by', auth()->id())
+ ->orWhere('share_report_template', 1);
+ }
+ }
+ );
}
/**