feat: product team members
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
768c814762
commit
fbb4862454
@@ -112,7 +112,7 @@ class ProductController extends Controller
|
||||
'category_id' => 'required|exists:categories,id',
|
||||
'tags' => 'nullable|array',
|
||||
'tags.*' => 'exists:tags,id',
|
||||
] + $this->detailRules());
|
||||
] + $this->detailRules(Auth::id()));
|
||||
|
||||
foreach (array_keys(Product::BADGES) as $badge) {
|
||||
$validated[$badge] = $request->boolean($badge);
|
||||
@@ -150,7 +150,7 @@ class ProductController extends Controller
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$product->load(['user', 'category', 'tags', 'comments.user', 'upvotes', 'bookmarks']);
|
||||
$product->load(['user', 'category', 'tags', 'members', 'comments.user', 'upvotes', 'bookmarks']);
|
||||
|
||||
return view('products.show', compact('product'));
|
||||
}
|
||||
@@ -182,7 +182,7 @@ class ProductController extends Controller
|
||||
'category_id' => 'required|exists:categories,id',
|
||||
'tags' => 'nullable|array',
|
||||
'tags.*' => 'exists:tags,id',
|
||||
] + $this->detailRules());
|
||||
] + $this->detailRules($product->user_id));
|
||||
|
||||
// Badges are locked for non-moderators once the product is approved
|
||||
if ($product->status !== 'approved' || Auth::user()->hasAnyRole(['moderator', 'admin'])) {
|
||||
@@ -218,7 +218,7 @@ class ProductController extends Controller
|
||||
/**
|
||||
* Validation rules for the product detail fields.
|
||||
*/
|
||||
protected function detailRules(): array
|
||||
protected function detailRules(int $ownerId): array
|
||||
{
|
||||
return [
|
||||
'free_tier' => 'boolean',
|
||||
@@ -234,6 +234,9 @@ class ProductController extends Controller
|
||||
'plans.*.price' => 'required|numeric|min:0|max:99999',
|
||||
'plans.*.period' => ['required', Rule::in(PricingPlan::PERIODS)],
|
||||
'plans.*.description' => 'nullable|string|max:255',
|
||||
'members' => 'nullable|array',
|
||||
'members.*.user_id' => ['required', 'distinct', 'exists:users,id', Rule::notIn([$ownerId])],
|
||||
'members.*.role' => 'required|string|max:100',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -254,6 +257,13 @@ class ProductController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
// The submitted member list replaces all existing members
|
||||
$members = [];
|
||||
foreach ((array) $request->input('members', []) as $member) {
|
||||
$members[$member['user_id']] = ['role' => $member['role']];
|
||||
}
|
||||
$product->members()->sync($members);
|
||||
|
||||
// Only rows belonging to this product may be removed
|
||||
$ids = array_filter((array) $request->input('remove_screenshots', []));
|
||||
if ($ids) {
|
||||
|
||||
Reference in New Issue
Block a user