12345678910111213141516171819202122232425 |
- <?php
- namespace App\Http\Requests;
- use App\Models\NamingRule;
- use Illuminate\Support\Facades\Auth;
- trait NamingRuleHelper
- {
- protected function namingRuleCheck($namingRuleId): void
- {
- $namingRule = NamingRule::query()->where([
- 'company_id' => 0,
- 'global' => 1,
- 'status' => 1,
- ])->orWhere([
- 'company_id' => Auth::user()->company_id,
- 'status' => 1
- ])->find($namingRuleId);
- if (! $namingRule) {
- throw new \Exception("The current naming rule has no permission to use");
- }
- }
- }
|