Model for Companies.
More...
Model for Companies.
- Version
- v1.8
Definition at line 12 of file Company.php.
static App\Models\Company::canManageUsersCompanies |
( |
| ) |
|
|
static |
Definition at line 115 of file Company.php.
117 return (!static::isFullMultipleCompanySupportEnabled() || Auth::user()->isSuperUser() ||
118 Auth::user()->company_id == null);
static App\Models\Company::getIdForCurrentUser |
( |
|
$unescaped_input | ) |
|
|
static |
Definition at line 81 of file Company.php.
83 if (!static::isFullMultipleCompanySupportEnabled()) {
84 return static::getIdFromInput($unescaped_input);
86 $current_user = Auth::user();
88 if ($current_user->company_id != null) {
89 return $current_user->company_id;
91 return static::getIdFromInput($unescaped_input);
static App\Models\Company::getIdForUser |
( |
|
$unescaped_input | ) |
|
|
static |
Definition at line 121 of file Company.php.
123 if (!static::isFullMultipleCompanySupportEnabled() || Auth::user()->isSuperUser()) {
124 return static::getIdFromInput($unescaped_input);
126 return static::getIdForCurrentUser($unescaped_input);
static App\Models\Company::getIdFromInput |
( |
|
$unescaped_input | ) |
|
|
static |
Definition at line 70 of file Company.php.
72 $escaped_input = e($unescaped_input);
74 if ($escaped_input ==
'0') {
77 return $escaped_input;
static App\Models\Company::getName |
( |
|
$companyable | ) |
|
|
static |
Definition at line 162 of file Company.php.
164 $company = $companyable->company;
166 if (is_null($company)) {
169 return e($company->name);
static App\Models\Company::getSelectList |
( |
| ) |
|
|
static |
Definition at line 64 of file Company.php.
66 $select_company = Lang::get(
'general.select_company');
67 return [
'0' => $select_company] + DB::table(
'companies')->orderBy(
'name',
'ASC')->lists(
'name',
'id');
static App\Models\Company::isCurrentUserAuthorized |
( |
| ) |
|
|
static |
Definition at line 110 of file Company.php.
112 return (!static::isFullMultipleCompanySupportEnabled() || Auth::user()->company_id == null);
static App\Models\Company::isCurrentUserHasAccess |
( |
|
$companyable | ) |
|
|
static |
Definition at line 96 of file Company.php.
98 if (is_null($companyable)) {
100 } elseif (!static::isFullMultipleCompanySupportEnabled()) {
103 $current_user_company_id = Auth::user()->company_id;
104 $companyable_company_id = $companyable->company_id;
106 return ($current_user_company_id == null || $current_user_company_id == $companyable_company_id);
static App\Models\Company::scopeCompanyableChildren |
( |
array |
$companyable_names, |
|
|
|
$query |
|
) |
| |
|
static |
Definition at line 139 of file Company.php.
141 if (count($companyable_names) == 0) {
142 throw new Exception(
'No Companyable Children to scope');
143 } elseif (!static::isFullMultipleCompanySupportEnabled()) {
148 static::scopeCompanyablesDirectly($q);
151 $q = $query->where(
function ($q) use ($companyable_names, $f) {
152 $q2 = $q->whereHas($companyable_names[0], $f);
154 for ($i = 1; $i < count($companyable_names); $i++) {
155 $q2 = $q2->orWhereHas($companyable_names[$i], $f);
static App\Models\Company::scopeCompanyables |
( |
|
$query, |
|
|
|
$column = 'company_id' |
|
) |
| |
|
static |
Definition at line 130 of file Company.php.
132 if (!static::isFullMultipleCompanySupportEnabled()) {
135 return static::scopeCompanyablesDirectly($query, $column);
App\Models\Company::$fillable = ['name'] |
|
protected |
App\Models\Company::$injectUniqueIdentifier = true |
|
protected |
App\Models\Company::$rules = ['name' => 'required|min:2|max:255|unique:companies,name'] |
|
protected |
App\Models\Company::$table = 'companies' |
|
protected |
The documentation for this class was generated from the following file: