Skip to content

Commit

Permalink
Make role image optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinecraft committed Nov 24, 2024
1 parent 59d293b commit 1037465
Show file tree
Hide file tree
Showing 195 changed files with 1,849 additions and 1,818 deletions.
4 changes: 3 additions & 1 deletion app/Http/Controllers/Admin/RoleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public function store(CreateRoleRequest $request)

$role->givePermissionTo($request->permissions);

$role->addMediaFromRequest('photo')->toMediaCollection('role');
if ($request->photo) {
$role->addMediaFromRequest('photo')->toMediaCollection('role');
}

return redirect()->route('admin.role.index')
->with(['toast' => ['type' => 'success', 'title' => __('Created Successfully'), 'body' => __('New Role is created successfully')]]);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Admin/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public function index()
'updated_at',
'country_id',
'last_login_at',
'roles.display_name',
'country.name',
'discord_user_id',
AllowedFilter::exact('roles.display_name'),
AllowedFilter::custom('q', new FilterMultipleFields(['name', 'email', 'username', 'discord_user_id'])),
AllowedFilter::scope('is_verified'),
])
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/CreateRoleRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function rules()
'display_name' => 'required|string|max:255',
'is_staff' => 'required|boolean',
'is_hidden_from_staff_list' => 'required|boolean',
'photo' => 'required|image|max:300',
'photo' => 'nullable|image|max:300',
'weight' => 'required|integer',
'web_message_format' => 'nullable|string|max:255',
'permissions' => 'sometimes|nullable|array|exists:permissions,name'
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function registerMediaCollections(): void

public function getPhotoUrlAttribute()
{
$photo_url = url('images/default-roles/'.$this->name.'.png');
$photo_url = null;
if ($this->getFirstMediaUrl('role')) {
$photo_url = $this->getFirstMediaUrl('role');
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1037465

Please sign in to comment.