|
|
@@ -126,7 +126,43 @@ class ProjectController extends Controller
|
|
|
return $this->ok(new ProjectResource($project));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Show the form for editing the specified resource.
|
|
|
+ *
|
|
|
+ * @param \App\Models\Project $project
|
|
|
+ * @return \Illuminate\Http\Response
|
|
|
+ */
|
|
|
+ public function edit(Project $project)
|
|
|
+ {
|
|
|
+ //
|
|
|
+ }
|
|
|
+
|
|
|
+ $user = AuthApi::current($request);
|
|
|
+ if (!$user) {
|
|
|
+ return $this->error(__('auth.failed'), 401, 401);
|
|
|
+ }
|
|
|
+ if (!self::canEdit($user['user_uid'], $project->owner_id)) {
|
|
|
+ return $this->error(__('auth.failed'), 403, 403);
|
|
|
+ }
|
|
|
+
|
|
|
+ $project->title = $request->get('title');
|
|
|
+ $project->description = $request->get('description');
|
|
|
+ $project->parent_id = $request->get('parent_id');
|
|
|
+ $project->editor_id = $user['user_uid'];
|
|
|
+
|
|
|
|
|
|
+ if (Str::isUuid($request->get('parent_id'))) {
|
|
|
+ $parentPath = Project::where('uid', $request->get('parent_id'))->value('path');
|
|
|
+ $parentPath = json_decode($parentPath);
|
|
|
+ if (!is_array($parentPath)) {
|
|
|
+ $parentPath = array();
|
|
|
+ }
|
|
|
+ array_push($parentPath, $project->parent_id);
|
|
|
+ $project->path = json_encode($parentPath, JSON_UNESCAPED_UNICODE);
|
|
|
+ }
|
|
|
+ $project->save();
|
|
|
+
|
|
|
+ return $this->ok(new ProjectResource($project));
|
|
|
/**
|
|
|
* Update the specified resource in storage.
|
|
|
*
|