diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php new file mode 100644 index 0000000..50c467c --- /dev/null +++ b/app/Http/Controllers/ProjectController.php @@ -0,0 +1,149 @@ +user_type == User::ROLE['PRODUCT_OWNER']){ + //$projects = Project::get(); + $q = $request->q; // search keyword, will search for name + $pageIndex = $request->pageIndex ? $request->pageIndex : 0; // the index of the page to shown, default 0 + $pageSize = $request->pageSize ? $request->pageSize : 3; // how many items to return, default 3 + $sortBy = $request->sortBy ? $request->sortBy : 'name' ; // attribute to sort, default name + $sortDirection = $request->sortDirection ? $request->sortDirection : 'ASC'; // direction of the sort, default ASC + $query =Project::query(); + // Search by name + if (isset($q)) { + $query->where('name', 'LIKE', '%'.$q.'%'); + } + // search by sort by and direction + $query->orderBy($sortBy, $sortDirection); + $projects = $query->paginate($pageSize); + return response()->json(['status' => 'success','projects'=>$projects]); + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + // + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + if(Auth::user()->user_type == User::ROLE['PRODUCT_OWNER']){ + $validator = Validator::make($request->all(), [ + 'name' => 'required|unique:projects,name|min:5|max:10', + ]); + + if ($validator->fails()) { + return response()->json(['errors' => $validator->messages()], 422); + } + if ($validator->passes()) { + $create = Project::create([ + 'name' => $request['name'] + ]); + return response()->json(['status' => 'Project created successfully'], 201); + } + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } + + /** + * Display the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function show($id) + { + if(Auth::user()->user_type == User::ROLE['PRODUCT_OWNER']){ + $project = Project::find($id); + return response()->json(['status' => 'success','project'=>$project]); + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + if(Auth::user()->user_type == User::ROLE['PRODUCT_OWNER']){ + $validator = Validator::make($request->all(), [ + 'name' => 'required|string|min:5|max:50' + ]); + + if ($validator->fails()) { + return response()->json(['errors' => $validator->messages()], 422); + } + if ($validator->passes()) { + $updateProject = Project::where('id',$id)->firstOrFail(); + $updateProject->update([ + 'name' => $request['name'] + ]); + return response()->json(['status' => 'Project updated successfully'], 200); + } + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + if(Auth::user()->user_type == User::ROLE['PRODUCT_OWNER']){ + $project = Project::find($id); + $project->delete(); + return response()->json(['status' => 'Project deleted successfully'], 200); + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } +} diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php new file mode 100644 index 0000000..edc5b07 --- /dev/null +++ b/app/Http/Controllers/TaskController.php @@ -0,0 +1,195 @@ +user_type == User::ROLE['PRODUCT_OWNER']){ + $tasks = Task::get(); + return response()->json(['status' => 'success','tasks'=>$tasks]); + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + // + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + if(Auth::user()->user_type == User::ROLE['PRODUCT_OWNER']){ + $validator = Validator::make($request->all(), [ + 'title' => 'required|unique:tasks,title|min:5|max:10', + 'description' => 'required|string|min:5|max:50', + 'project_id' => 'required' + ]); + + if ($validator->fails()) { + return response()->json(['errors' => $validator->messages()], 422); + } + if ($validator->passes()) { + $create = Task::create([ + 'title' => $request['title'], + 'description' => $request['description'], + 'project_id' => $request['project_id'], + ]); + return response()->json(['status' => 'Task created successfully'], 201); + } + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } + + /** + * Display the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function show($id) + { + if(Auth::user()->user_type == User::ROLE['PRODUCT_OWNER']){ + $task = Task::find($id); + return response()->json(['status' => 'success','task'=>$task]); + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + // + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + if(Auth::user()->user_type == User::ROLE['PRODUCT_OWNER']){ + $validator = Validator::make($request->all(), [ + 'title' => 'required|min:5|max:10', + 'description' => 'required|string|min:5|max:50', + 'project_id' => 'required' + ]); + + if ($validator->fails()) { + return response()->json(['errors' => $validator->messages()], 422); + } + if ($validator->passes()) { + $updateTask = Task::where('id',$id)->firstOrFail(); + $updateTask->update([ + 'title' => $request['title'], + 'description' => $request['description'], + 'project_id' => $request['project_id'], + ]); + return response()->json(['status' => 'Task updated successfully'], 200); + } + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + if(Auth::user()->user_type == User::ROLE['PRODUCT_OWNER']){ + $task = Task::find($id); + $task->delete(); + return response()->json(['status' => 'Task deleted successfully'], 200); + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } + public function getTeams(){ + if(Auth::user()->user_type == User::ROLE['PRODUCT_OWNER']){ + $users = User::where('user_type',User::ROLE['TEAM_MEMBER'])->get(); + return response()->json(['status' => 'success','users'=>$users]); + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } + + public function assignTask(Request $request){ + if(Auth::user()->user_type == User::ROLE['PRODUCT_OWNER']){ + $validator = Validator::make($request->all(), [ + 'team_user_id' => 'required', + 'task_id' => 'required' + ]); + + if ($validator->fails()) { + return response()->json(['errors' => $validator->messages()], 422); + } + if ($validator->passes()) { + $updateTask = Task::find($request['task_id']); + $updateTask->user_id = $request['team_user_id']; + $updateTask->save(); + return response()->json(['status' => 'Task assigned successfully'], 200); + } + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } + + public function updateStatus(Request $request){ + if(Auth::user()->user_type == User::ROLE['TEAM_MEMBER']){ + $validator = Validator::make($request->all(), [ + 'status' => 'required', + 'task_id' => 'required' + ]); + + if ($validator->fails()) { + return response()->json(['errors' => $validator->messages()], 422); + } + if ($validator->passes()) { + $updateTask = Task::find($request['task_id']); + $updateTask->status = $request['status']; + $updateTask->save(); + return response()->json(['status' => 'Task status updated successfully'], 200); + } + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } +} diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php new file mode 100644 index 0000000..1388a37 --- /dev/null +++ b/app/Http/Controllers/UserController.php @@ -0,0 +1,164 @@ +first(); + if($request->has('password')){ + if ($user && Hash::check($request["password"], $user->password)) { + // user password matched + $token = $user->createToken("auth-token")->plainTextToken; + return response()->json(['status' => 'Loggedin','token'=>$token]); + }else{ + // user password not matched + $msg = array('msg'=>'Invalid E-mail ID / Password'); + return response()->json(['errors' => $msg], 401); + } + }else{ + $msg = array('msg'=>'Password is required'); + return response()->json(['errors' => $msg], 401); + } + } + + public function index() + { + if(Auth::user()->user_type == User::ROLE['ADMIN']){ + $users = User::where('id','!=',Auth::user()->id)->get(); + return response()->json(['status' => 'success','users'=>$users]); + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + // + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + if(Auth::user()->user_type == User::ROLE['ADMIN']){ + $validator = Validator::make($request->all(), [ + 'user_name' => 'required|unique:users|min:5|max:10', + 'name' => 'required|string|min:5|max:50', + 'password' => 'required|min:5|max:8', + 'user_type'=>'required|string|min:5|max:18' + ]); + + if ($validator->fails()) { + return response()->json(['errors' => $validator->messages()], 422); + } + if ($validator->passes()) { + $pwd=Hash::make($request['password']); + $create = User::create([ + 'name' => $request['name'], + 'user_name' => $request['user_name'], + 'password' => $pwd, + 'user_type' => $request['user_type'], + ]); + return response()->json(['status' => 'User created successfully'], 201); + } + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } + + /** + * Display the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function show($id) + { + if(Auth::user()->user_type == User::ROLE['ADMIN']){ + $user = User::find($id); + return response()->json(['status' => 'success','user'=>$user]); + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + if(Auth::user()->user_type == User::ROLE['ADMIN']){ + $validator = Validator::make($request->all(), [ + 'name' => 'required|string|min:5|max:50', + 'user_type'=>'required|string|min:5|max:18' + ]); + + if ($validator->fails()) { + return response()->json(['errors' => $validator->messages()], 422); + } + if ($validator->passes()) { + $updateUser = User::where('id',$id)->firstOrFail(); + $updateUser->update([ + 'name' => $request['name'], + 'user_type' => $request['user_type'], + ]); + return response()->json(['status' => 'User updated successfully'], 200); + } + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + if(Auth::user()->user_type == User::ROLE['ADMIN']){ + $user = User::find($id); + $user->delete(); + return response()->json(['status' => 'User deleted successfully'], 200); + }else{ + return response()->json(['errors' => 'You does not have an access'], 401); + } + } +} diff --git a/app/Models/Project.php b/app/Models/Project.php new file mode 100644 index 0000000..2ccf891 --- /dev/null +++ b/app/Models/Project.php @@ -0,0 +1,32 @@ + 'not_started', + 'IN_PROGRESS' => 'inprogress', + 'READY_FOR_TEST'=>'ready_for_test', + 'COMPLETED'=>'completed' + ]; +} diff --git a/app/Models/User.php b/app/Models/User.php index 8996368..960a38c 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -7,10 +7,27 @@ use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; - +use Dyrynda\Database\Support\GeneratesUuid; class User extends Authenticatable { - use HasApiTokens, HasFactory, Notifiable; + use HasApiTokens, HasFactory, Notifiable, GeneratesUuid; + + public $incrementing = false; + + /** + * @var string + */ + protected $keyType = 'string'; + + /** + * The name of the column that should be used for the UUID. + * + * @return string + */ + public function uuidColumn(): string + { + return 'id'; + } /** * The attributes that are mass assignable. @@ -19,8 +36,10 @@ class User extends Authenticatable */ protected $fillable = [ 'name', - 'email', - 'password', + 'user_name', + 'user_type', + 'password' + ]; /** @@ -41,4 +60,10 @@ class User extends Authenticatable protected $casts = [ 'email_verified_at' => 'datetime', ]; + + const ROLE = [ + 'ADMIN' => 'admin', + 'PRODUCT_OWNER' => 'product_owner', + 'TEAM_MEMBER'=>'team_member' + ]; } diff --git a/composer.json b/composer.json index 2b0c115..8dc6a33 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "license": "MIT", "require": { "php": "^7.3|^8.0", + "dyrynda/laravel-model-uuid": "6.5", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", "laravel/framework": "^8.75", diff --git a/composer.lock b/composer.lock index 59a2b32..f57ee5f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c61ff82cbf0142a401a48a8161e1595a", + "content-hash": "692b3f588a76ae66ed02340b54d30d82", "packages": [ { "name": "brick/math", @@ -369,6 +369,63 @@ ], "time": "2022-01-18T15:43:28+00:00" }, + { + "name": "dyrynda/laravel-model-uuid", + "version": "6.5.0", + "source": { + "type": "git", + "url": "https://github.com/michaeldyrynda/laravel-model-uuid.git", + "reference": "0934119b125807b71e656696e0d6814154a9b905" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/michaeldyrynda/laravel-model-uuid/zipball/0934119b125807b71e656696e0d6814154a9b905", + "reference": "0934119b125807b71e656696e0d6814154a9b905", + "shasum": "" + }, + "require": { + "illuminate/database": "^8.12", + "illuminate/events": "^8.12", + "illuminate/support": "^8.12", + "php": "^7.3|^8.0", + "ramsey/uuid": "^4.1" + }, + "require-dev": { + "dyrynda/laravel-efficient-uuid": "^4.3", + "laravel/legacy-factories": "^1.0.4", + "nunomaduro/collision": "^5.0", + "orchestra/testbench": "^6.0", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "dyrynda/laravel-efficient-uuid": "Override Laravel's default query grammar to efficiently store UUIDs." + }, + "type": "library", + "autoload": { + "psr-4": { + "Dyrynda\\Database\\Support\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dyrynda", + "email": "michael@dyrynda.com.au", + "homepage": "https://dyrynda.com.au" + } + ], + "description": "This package allows you to easily work with UUIDs in your Laravel models.", + "keywords": [ + "eloquent", + "laravel", + "model", + "uuid" + ], + "time": "2021-09-30T00:31:42+00:00" + }, { "name": "egulias/email-validator", "version": "2.1.25", @@ -514,6 +571,7 @@ "type": "github" } ], + "abandoned": true, "time": "2022-02-19T14:17:28+00:00" }, { @@ -7918,5 +7976,5 @@ "php": "^7.3|^8.0" }, "platform-dev": [], - "plugin-api-version": "2.1.0" + "plugin-api-version": "1.1.0" } diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 621a24e..8e39e5e 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -3,7 +3,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; - +use App\Models\User; class CreateUsersTable extends Migration { /** @@ -14,10 +14,12 @@ class CreateUsersTable extends Migration public function up() { Schema::create('users', function (Blueprint $table) { - $table->id(); + $table->uuid('id')->primary(); + $table + ->enum('user_type', User::ROLE) + ->default(User::ROLE['ADMIN']); $table->string('name'); - $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); + $table->string('user_name')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); diff --git a/database/migrations/2023_03_03_081118_create_projects_table.php b/database/migrations/2023_03_03_081118_create_projects_table.php new file mode 100644 index 0000000..fd314d1 --- /dev/null +++ b/database/migrations/2023_03_03_081118_create_projects_table.php @@ -0,0 +1,32 @@ +uuid('id')->primary(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('projects'); + } +} diff --git a/database/migrations/2023_03_03_081141_create_tasks_table.php b/database/migrations/2023_03_03_081141_create_tasks_table.php new file mode 100644 index 0000000..eeaa5f4 --- /dev/null +++ b/database/migrations/2023_03_03_081141_create_tasks_table.php @@ -0,0 +1,42 @@ +uuid('id')->primary(); + $table->string('title'); + $table->longText('description'); + $table + ->enum('status', Task::STATUS) + ->default(Task::STATUS['NOT_STARTED']); + $table->uuid('project_id'); + $table + ->foreign('project_id') + ->references('id') + ->on('projects'); + $table->uuid('user_id')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('tasks'); + } +} diff --git a/database/seeders/UserSeeder.php b/database/seeders/UserSeeder.php new file mode 100644 index 0000000..3fe46d6 --- /dev/null +++ b/database/seeders/UserSeeder.php @@ -0,0 +1,23 @@ + "admin", + "user_name" => "admin", + "password" => Hash::make('12345'), + ]); + } +} diff --git a/docs/test.postman_collection b/docs/test.postman_collection new file mode 100644 index 0000000..c5a89b1 --- /dev/null +++ b/docs/test.postman_collection @@ -0,0 +1,1140 @@ +{ + "info": { + "_postman_id": "6ade2340-9d21-44ea-b35d-f303f68f1949", + "name": "3-3-test", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "users-login", + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "user_name", + "value": "admin", + "type": "text" + }, + { + "key": "password", + "value": "12345", + "type": "text" + } + ] + }, + "url": { + "raw": "http://127.0.0.1:8000/api/users/login", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "login" + ] + } + }, + "response": [] + }, + { + "name": "add users", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "2|WBnS3NTciDAMTf22DBJSbkVlVA6wg6GTwYkFMU1c", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "name", + "value": "vaishu", + "type": "text" + }, + { + "key": "user_name", + "value": "vaishu", + "type": "text" + }, + { + "key": "password", + "value": "12345", + "type": "text" + }, + { + "key": "user_type", + "value": "product_owner", + "description": "product_owner,team_member", + "type": "text" + } + ] + }, + "url": { + "raw": "http://127.0.0.1:8000/api/users/add", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "add" + ] + } + }, + "response": [] + }, + { + "name": "users-list", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "2|WBnS3NTciDAMTf22DBJSbkVlVA6wg6GTwYkFMU1c", + "type": "string" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "http://127.0.0.1:8000/api/users/list", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "list" + ] + } + }, + "response": [] + }, + { + "name": "user-view ", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "2|WBnS3NTciDAMTf22DBJSbkVlVA6wg6GTwYkFMU1c", + "type": "string" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "http://127.0.0.1:8000/api/users/view/9944f9b2-78cd-433a-96fb-085100176fcc", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "view", + "9944f9b2-78cd-433a-96fb-085100176fcc" + ] + } + }, + "response": [] + }, + { + "name": "user-update", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "2|WBnS3NTciDAMTf22DBJSbkVlVA6wg6GTwYkFMU1c", + "type": "string" + } + ] + }, + "method": "PUT", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "name", + "value": "athyap", + "type": "text" + }, + { + "key": "_method", + "value": "PUT", + "type": "text" + }, + { + "key": "user_type", + "value": "team_member", + "description": "product_owner,team_member", + "type": "text" + } + ] + }, + "url": { + "raw": "http://127.0.0.1:8000/api/users/update/9944f9b2-78cd-433a-96fb-085100176fcc", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "update", + "9944f9b2-78cd-433a-96fb-085100176fcc" + ] + } + }, + "response": [] + }, + { + "name": "users-remove", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "2|WBnS3NTciDAMTf22DBJSbkVlVA6wg6GTwYkFMU1c", + "type": "string" + } + ] + }, + "method": "DELETE", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "http://127.0.0.1:8000/api/users/remove/d9670477-84a6-4f9d-81e6-1c3310397a4c", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "remove", + "d9670477-84a6-4f9d-81e6-1c3310397a4c" + ] + } + }, + "response": [] + }, + { + "name": "project-list", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "5|YD2SRlRZY3W23odhxFBdq64FCGOrvc40zNpuP0Kf", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "http://127.0.0.1:8000/api/users/project/list?sortDirection=ASC&pageSize=1&q=project2", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "project", + "list" + ], + "query": [ + { + "key": "sortDirection", + "value": "ASC" + }, + { + "key": "pageSize", + "value": "1" + }, + { + "key": "q", + "value": "project2" + } + ] + } + }, + "response": [] + }, + { + "name": "project-add", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "3|fSP1bfaek9bdWC7hP2xPXpgOQt2IDcS6hM8Y09fw", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "name", + "value": "project3", + "type": "text" + } + ] + }, + "url": { + "raw": "http://127.0.0.1:8000/api/users/add-project", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "add-project" + ] + } + }, + "response": [] + }, + { + "name": "project-view", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "3|fSP1bfaek9bdWC7hP2xPXpgOQt2IDcS6hM8Y09fw", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "name", + "value": "project3", + "type": "text" + } + ] + }, + "url": { + "raw": "http://127.0.0.1:8000/api/users/view-project/14667e03-ff1d-4542-8adf-6f5594dceaee", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "view-project", + "14667e03-ff1d-4542-8adf-6f5594dceaee" + ] + } + }, + "response": [] + }, + { + "name": "project-update", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "3|fSP1bfaek9bdWC7hP2xPXpgOQt2IDcS6hM8Y09fw", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "name", + "value": "project312", + "type": "text" + }, + { + "key": "_method", + "value": "PUT", + "type": "text" + } + ] + }, + "url": { + "raw": "http://127.0.0.1:8000/api/users/update-project/14667e03-ff1d-4542-8adf-6f5594dceaee", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "update-project", + "14667e03-ff1d-4542-8adf-6f5594dceaee" + ] + } + }, + "response": [] + }, + { + "name": "project-delete", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "3|fSP1bfaek9bdWC7hP2xPXpgOQt2IDcS6hM8Y09fw", + "type": "string" + } + ] + }, + "method": "DELETE", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "name", + "value": "project312", + "type": "text", + "disabled": true + }, + { + "key": "_method", + "value": "PUT", + "type": "text", + "disabled": true + } + ] + }, + "url": { + "raw": "http://127.0.0.1:8000/api/users/remove-project/14667e03-ff1d-4542-8adf-6f5594dceaee", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "remove-project", + "14667e03-ff1d-4542-8adf-6f5594dceaee" + ] + } + }, + "response": [] + }, + { + "name": "task-add", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "3|fSP1bfaek9bdWC7hP2xPXpgOQt2IDcS6hM8Y09fw", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "title", + "value": "task1", + "type": "text" + }, + { + "key": "description", + "value": "testtww", + "type": "text" + }, + { + "key": "project_id", + "value": "0c113200-2965-467a-a505-15c607795b79", + "type": "text" + } + ] + }, + "url": { + "raw": "http://127.0.0.1:8000/api/users/add-task", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "add-task" + ] + } + }, + "response": [] + }, + { + "name": "task-update", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "3|fSP1bfaek9bdWC7hP2xPXpgOQt2IDcS6hM8Y09fw", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "title", + "value": "task1", + "type": "text" + }, + { + "key": "description", + "value": "testtwwaf", + "type": "text" + }, + { + "key": "project_id", + "value": "0c113200-2965-467a-a505-15c607795b79", + "type": "text" + }, + { + "key": "_method", + "value": "PUT", + "type": "text" + } + ] + }, + "url": { + "raw": "http://127.0.0.1:8000/api/users/update-task/adde34ed-f009-4e46-9120-4fa4aecac693", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "update-task", + "adde34ed-f009-4e46-9120-4fa4aecac693" + ] + } + }, + "response": [] + }, + { + "name": "task-list", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "3|fSP1bfaek9bdWC7hP2xPXpgOQt2IDcS6hM8Y09fw", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "title", + "value": "task1", + "type": "text", + "disabled": true + }, + { + "key": "description", + "value": "testtwwaf", + "type": "text", + "disabled": true + }, + { + "key": "project_id", + "value": "0c113200-2965-467a-a505-15c607795b79", + "type": "text", + "disabled": true + }, + { + "key": "_method", + "value": "PUT", + "type": "text" + } + ] + }, + "url": { + "raw": "http://127.0.0.1:8000/api/users/task/list", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "task", + "list" + ] + } + }, + "response": [] + }, + { + "name": "task-view", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "3|fSP1bfaek9bdWC7hP2xPXpgOQt2IDcS6hM8Y09fw", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "title", + "value": "task1", + "type": "text", + "disabled": true + }, + { + "key": "description", + "value": "testtwwaf", + "type": "text", + "disabled": true + }, + { + "key": "project_id", + "value": "0c113200-2965-467a-a505-15c607795b79", + "type": "text", + "disabled": true + }, + { + "key": "_method", + "value": "PUT", + "type": "text" + } + ] + }, + "url": { + "raw": "http://127.0.0.1:8000/api/users/view-task/2fb9569a-fd65-4bb3-b596-a1227d48b3a9", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "view-task", + "2fb9569a-fd65-4bb3-b596-a1227d48b3a9" + ] + } + }, + "response": [] + }, + { + "name": "task-remove", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "3|fSP1bfaek9bdWC7hP2xPXpgOQt2IDcS6hM8Y09fw", + "type": "string" + } + ] + }, + "method": "DELETE", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "title", + "value": "task1", + "type": "text", + "disabled": true + }, + { + "key": "description", + "value": "testtwwaf", + "type": "text", + "disabled": true + }, + { + "key": "project_id", + "value": "0c113200-2965-467a-a505-15c607795b79", + "type": "text", + "disabled": true + }, + { + "key": "_method", + "value": "PUT", + "type": "text" + } + ] + }, + "url": { + "raw": "http://127.0.0.1:8000/api/users/remove-task/2fb9569a-fd65-4bb3-b596-a1227d48b3a9", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "remove-task", + "2fb9569a-fd65-4bb3-b596-a1227d48b3a9" + ] + } + }, + "response": [] + }, + { + "name": "team-members", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "3|fSP1bfaek9bdWC7hP2xPXpgOQt2IDcS6hM8Y09fw", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "title", + "value": "task1", + "type": "text", + "disabled": true + }, + { + "key": "description", + "value": "testtwwaf", + "type": "text", + "disabled": true + }, + { + "key": "project_id", + "value": "0c113200-2965-467a-a505-15c607795b79", + "type": "text", + "disabled": true + }, + { + "key": "_method", + "value": "PUT", + "type": "text" + } + ] + }, + "url": { + "raw": "http://127.0.0.1:8000/api/users/teams", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "teams" + ] + } + }, + "response": [] + }, + { + "name": "assign-task to team-members", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "3|fSP1bfaek9bdWC7hP2xPXpgOQt2IDcS6hM8Y09fw", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "title", + "value": "task1", + "type": "text", + "disabled": true + }, + { + "key": "description", + "value": "testtwwaf", + "type": "text", + "disabled": true + }, + { + "key": "project_id", + "value": "0c113200-2965-467a-a505-15c607795b79", + "type": "text", + "disabled": true + }, + { + "key": "_method", + "value": "PUT", + "type": "text", + "disabled": true + }, + { + "key": "task_id", + "value": "1dc9bedb-b398-43d2-8d09-5f948675b8cf", + "type": "text" + }, + { + "key": "team_user_id", + "value": "9944f9b2-78cd-433a-96fb-085100176fcc", + "type": "text" + } + ] + }, + "url": { + "raw": "http://127.0.0.1:8000/api/users/assign-task", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "assign-task" + ] + } + }, + "response": [] + }, + { + "name": "task status update by team-member", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "4|3VeNdLTZEhmMkhOe2VyTTJilkHJkjQQ6L6SCKQOt", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "title", + "value": "task1", + "type": "text", + "disabled": true + }, + { + "key": "description", + "value": "testtwwaf", + "type": "text", + "disabled": true + }, + { + "key": "project_id", + "value": "0c113200-2965-467a-a505-15c607795b79", + "type": "text", + "disabled": true + }, + { + "key": "_method", + "value": "PUT", + "type": "text", + "disabled": true + }, + { + "key": "task_id", + "value": "1dc9bedb-b398-43d2-8d09-5f948675b8cf", + "type": "text" + }, + { + "key": "team_user_id", + "value": "9944f9b2-78cd-433a-96fb-085100176fcc", + "type": "text", + "disabled": true + }, + { + "key": "status", + "value": "inprogress", + "description": "completed,inprogress,ready_for_test", + "type": "text" + } + ] + }, + "url": { + "raw": "http://127.0.0.1:8000/api/users/update-task-status", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "api", + "users", + "update-task-status" + ] + } + }, + "response": [] + } + ] +} \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index eb6fa48..90aacec 100644 --- a/routes/api.php +++ b/routes/api.php @@ -13,7 +13,29 @@ | is assigned the "api" middleware group. Enjoy building your API! | */ +Route::post('users/login',[\App\Http\Controllers\UserController::class,'login']); +Route::group(['prefix' => 'users','middleware' => 'auth:sanctum'],function () { + //user + Route::get('list', [\App\Http\Controllers\UserController::class,'index']); + Route::get('view/{id}', [\App\Http\Controllers\UserController::class,'show']); + Route::post('add', [\App\Http\Controllers\UserController::class,'store']); + Route::put('update/{id}', [\App\Http\Controllers\UserController::class,'update']); + Route::delete('remove/{id}', [\App\Http\Controllers\UserController::class,'destroy']); -Route::middleware('auth:sanctum')->get('/user', function (Request $request) { - return $request->user(); + //project + Route::get('project/list', [\App\Http\Controllers\ProjectController::class,'index']); + Route::get('view-project/{id}', [\App\Http\Controllers\ProjectController::class,'show']); + Route::post('add-project', [\App\Http\Controllers\ProjectController::class,'store']); + Route::put('update-project/{id}', [\App\Http\Controllers\ProjectController::class,'update']); + Route::delete('remove-project/{id}', [\App\Http\Controllers\ProjectController::class,'destroy']); + + //task + Route::get('task/list', [\App\Http\Controllers\TaskController::class,'index']); + Route::get('view-task/{id}', [\App\Http\Controllers\TaskController::class,'show']); + Route::post('add-task', [\App\Http\Controllers\TaskController::class,'store']); + Route::put('update-task/{id}', [\App\Http\Controllers\TaskController::class,'update']); + Route::delete('remove-task/{id}', [\App\Http\Controllers\TaskController::class,'destroy']); + Route::get('teams', [\App\Http\Controllers\TaskController::class,'getTeams']); + Route::post('assign-task', [\App\Http\Controllers\TaskController::class,'assignTask']); + Route::post('update-task-status', [\App\Http\Controllers\TaskController::class,'updateStatus']); });