NamingRuleHelper.php 598 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace App\Http\Requests;
  3. use App\Models\NamingRule;
  4. use Illuminate\Support\Facades\Auth;
  5. trait NamingRuleHelper
  6. {
  7. protected function namingRuleCheck($namingRuleId): void
  8. {
  9. $namingRule = NamingRule::query()->where([
  10. 'company_id' => 0,
  11. 'global' => 1,
  12. 'status' => 1,
  13. ])->orWhere([
  14. 'company_id' => Auth::user()->company_id,
  15. 'status' => 1
  16. ])->find($namingRuleId);
  17. if (! $namingRule) {
  18. throw new \Exception("The current naming rule has no permission to use");
  19. }
  20. }
  21. }