From 1a057270a5414454729684710cb280721041a0c1 Mon Sep 17 00:00:00 2001
From: Daniel Batista Maia dos Santos
)>}8gaoM0FYTSa&vtf@dvWg9VA(_s%57Y$oQO((YD zgRL^#gu+ + + + + + Laravel + + + + + + + + + + ++ @if (Route::has('login')) + + @endif + ++ + diff --git a/laravel/routes/channels.php b/laravel/routes/channels.php new file mode 100644 index 000000000..5d451e1fa --- /dev/null +++ b/laravel/routes/channels.php @@ -0,0 +1,18 @@ +id === (int) $id; +}); diff --git a/laravel/routes/console.php b/laravel/routes/console.php new file mode 100644 index 000000000..e05f4c9a1 --- /dev/null +++ b/laravel/routes/console.php @@ -0,0 +1,19 @@ +comment(Inspiring::quote()); +})->purpose('Display an inspiring quote'); diff --git a/laravel/routes/v1/api.php b/laravel/routes/v1/api.php new file mode 100644 index 000000000..269d45bf4 --- /dev/null +++ b/laravel/routes/v1/api.php @@ -0,0 +1,26 @@ +get('/user', function (Request $request) { + return $request->user(); +}); + + +Route::get('/', function () { + return response()->json(['code' => 200, 'status' => 'Connected', 'message' => 'API is working']); +}); diff --git a/laravel/routes/web.php b/laravel/routes/web.php new file mode 100644 index 000000000..b13039731 --- /dev/null +++ b/laravel/routes/web.php @@ -0,0 +1,18 @@ +zp=w#`(Q*ektY1YC-o=R%Z6vv^8_N`}{bP zTvoBo47%*mxrxKpD$0N|pbTt{0n}`k{!T!hl>ucy8CWsE-v^7q=mhJ4{?mcUw*bHt zYA;xGFTpWZ&+++ ++ +++ +++++ ++ + ++ ++++ Laravel has wonderful, thorough documentation covering every aspect of the framework. Whether you are new to the framework or have previous experience with Laravel, we recommend reading all of the documentation from beginning to end. ++++ ++ + ++ ++++ Laracasts offers thousands of video tutorials on Laravel, PHP, and JavaScript development. Check them out, see for yourself, and massively level up your development skills in the process. ++++ + ++ + ++ ++++ Laravel News is a community driven portal and newsletter aggregating all of the latest and most important news in the Laravel ecosystem, including new package releases and tutorials. ++++++ ++ + + + Shop + + + + + + Sponsor + +++ Laravel v{{ Illuminate\Foundation\Application::VERSION }} (PHP v{{ PHP_VERSION }}) ++o< zGN25^4D`a~kn8{H@BM!qq*uy-GVre$Fljc)#<(S^t*x8mT5B;bFj&~H4!8=z!k1$B eaw*=!@B+Q%1<(oB0il8DkASB^CuLx(4Ez8$8f8}i literal 0 HcmV?d00001 diff --git a/laravel/storage/app/.gitignore b/laravel/storage/app/.gitignore new file mode 100644 index 000000000..8f4803c05 --- /dev/null +++ b/laravel/storage/app/.gitignore @@ -0,0 +1,3 @@ +* +!public/ +!.gitignore diff --git a/laravel/storage/app/public/.gitignore b/laravel/storage/app/public/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/laravel/storage/app/public/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/laravel/storage/framework/.DS_Store b/laravel/storage/framework/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..eef549e3dacc8fde9e6e98da09e3f434e617e032 GIT binary patch literal 6148 zcmeHK%}&EG40fOs6G&)Bj*)nR-QZTHa^Sodfc S5dNkHta$0s 6l&*@n`j;7LSh zVD{UcpG@*)$?gV#Ot$keFaj{7Dh|%r^oaUZJ2J=?b&6eMi&rd`kK^e>-H8svZ)8B< z-6^iIz&$qDdw;97->$rMBUW`)&6f3y9?k!}dH=ZVi<*BUYW<|MWmiq-Aqw2$1<%;{ zOxpQGYqh>3_ps;ht={^3>T2zfU?3O>2L1yBT(eb%=Z?_^1HnKr&@!OkheTB@Gd7O) z>0o0=0AfM23H!E(BPKNv%Z!a9Efn!oqNhqeVu+{Ho^o87v2pZth*jowa%I~bGD566 zF>yeV(jb~(AQ(7c;KauxUH`9+pZ^cCVi*hr1AmDDDXM8T;S=SxwexJc)+Xv5RYl_( l$2Nr>TZ$R0|7k9$CbTE*5X+2>BQ2EJ2pA2~1Oq?Hz!xfAL)ZWS literal 0 HcmV?d00001 diff --git a/laravel/tests/CreatesApplication.php b/laravel/tests/CreatesApplication.php new file mode 100644 index 000000000..547152f6a --- /dev/null +++ b/laravel/tests/CreatesApplication.php @@ -0,0 +1,22 @@ +make(Kernel::class)->bootstrap(); + + return $app; + } +} diff --git a/laravel/tests/Feature/ExampleTest.php b/laravel/tests/Feature/ExampleTest.php new file mode 100644 index 000000000..1eafba615 --- /dev/null +++ b/laravel/tests/Feature/ExampleTest.php @@ -0,0 +1,21 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/laravel/tests/TestCase.php b/laravel/tests/TestCase.php new file mode 100644 index 000000000..2932d4a69 --- /dev/null +++ b/laravel/tests/TestCase.php @@ -0,0 +1,10 @@ +assertTrue(true); + } +} diff --git a/laravel/vite.config.js b/laravel/vite.config.js new file mode 100644 index 000000000..421b56956 --- /dev/null +++ b/laravel/vite.config.js @@ -0,0 +1,11 @@ +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; + +export default defineConfig({ + plugins: [ + laravel({ + input: ['resources/css/app.css', 'resources/js/app.js'], + refresh: true, + }), + ], +}); From 6c3c3ff660ea33ba6b98df4d280704466a6ce3c2 Mon Sep 17 00:00:00 2001 From: Daniel Batista Maia dos Santos Date: Wed, 23 Nov 2022 22:18:03 -0300 Subject: [PATCH 2/6] Criacao de logica com o calculo dos ganhos do investmento --- laravel/.DS_Store | Bin 8196 -> 8196 bytes laravel/app/Exceptions/Handler.php | 3 + .../Http/Controllers/InvestmentController.php | 56 ++--- .../app/Http/Requests/InvestmentRequest.php | 28 +++ .../app/Http/Resources/InvestmentResource.php | 22 ++ .../InvestmentRepositoryInterface.php | 10 + .../Interface/OwnerRepositoryInterface.php | 8 + laravel/app/Models/Investment.php | 26 ++- laravel/app/Models/Owner.php | 22 +- .../Providers/RepositoryServiceProvider.php | 33 +++ .../app/Repositories/InvestmentRepository.php | 65 ++++++ laravel/app/Repositories/OwnerRepository.php | 18 ++ laravel/app/Traits/ApiResponser.php | 52 +++++ laravel/composer.json | 5 +- laravel/composer.lock | 209 +++++++++++++++++- laravel/config/app.php | 1 + ..._08_19_000000_create_failed_jobs_table.php | 36 --- ...01_create_personal_access_tokens_table.php | 37 ---- ...2022_11_23_223451_create_owners_table.php} | 10 +- ...11_24_222854_create_investments_table.php} | 13 +- laravel/routes/v1/api.php | 6 +- laravel/storage/.DS_Store | Bin 6148 -> 6148 bytes 22 files changed, 540 insertions(+), 120 deletions(-) create mode 100644 laravel/app/Http/Requests/InvestmentRequest.php create mode 100644 laravel/app/Http/Resources/InvestmentResource.php create mode 100644 laravel/app/Interface/InvestmentRepositoryInterface.php create mode 100644 laravel/app/Interface/OwnerRepositoryInterface.php create mode 100644 laravel/app/Providers/RepositoryServiceProvider.php create mode 100644 laravel/app/Repositories/InvestmentRepository.php create mode 100644 laravel/app/Repositories/OwnerRepository.php create mode 100644 laravel/app/Traits/ApiResponser.php delete mode 100644 laravel/database/migrations/2019_08_19_000000_create_failed_jobs_table.php delete mode 100644 laravel/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php rename laravel/database/migrations/{2014_10_12_100000_create_password_resets_table.php => 2022_11_23_223451_create_owners_table.php} (60%) rename laravel/database/migrations/{2014_10_12_000000_create_users_table.php => 2022_11_24_222854_create_investments_table.php} (54%) diff --git a/laravel/.DS_Store b/laravel/.DS_Store index 40e22844b6e265e9a9d820a373dc0067d0a848e1..b868452f2f304b294ba5f364cf0a6b4ade50fed9 100644 GIT binary patch delta 39 icmZp1XmQvODaOpi)HyjuESrhx!se4=6WCGt){Fr6ZwyBO delta 39 icmZp1XmQvODaOpWQF3yOST+;0!RC`<6WCGt){Fr0lM96a diff --git a/laravel/app/Exceptions/Handler.php b/laravel/app/Exceptions/Handler.php index 82a37e400..b161f1c74 100644 --- a/laravel/app/Exceptions/Handler.php +++ b/laravel/app/Exceptions/Handler.php @@ -2,11 +2,14 @@ namespace App\Exceptions; +use App\Traits\ApiResponser; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Throwable; class Handler extends ExceptionHandler { + use ApiResponser; + /** * A list of exception types with their corresponding custom log levels. * diff --git a/laravel/app/Http/Controllers/InvestmentController.php b/laravel/app/Http/Controllers/InvestmentController.php index 2200c42d0..fd7cd8466 100644 --- a/laravel/app/Http/Controllers/InvestmentController.php +++ b/laravel/app/Http/Controllers/InvestmentController.php @@ -2,11 +2,18 @@ namespace App\Http\Controllers; +use App\Http\Requests\InvestmentRequest; use App\Models\Investment; +use App\Models\Owner; +use App\Repositories\InvestmentRepository; +use App\Repositories\OwnerRepository; +use App\Traits\ApiResponser; use Illuminate\Http\Request; class InvestmentController extends Controller { + use ApiResponser; + /** * Display a listing of the resource. * @@ -17,47 +24,44 @@ public function index() // } - /** - * 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) + public function store(InvestmentRequest $request) { - // + try { + $ownerRepo = new OwnerRepository; + $ownerId = $ownerRepo->setOwner($request->owner_id, $request->owner_name); + + $investmentRepo = new InvestmentRepository; + $investmentRepo->setInvestment($request->invesment, $ownerId); + + return $this->success($request->input(), "Investmento criado com sucesso"); + } catch (\Exception $e) { + return $this->error("Houve um erro interno ao criar um investimento.", 500, ["detail" => $e->getMessage()]); + } } /** * Display the specified resource. * - * @param \App\Models\Investment $investment + * @param int $ownerId * @return \Illuminate\Http\Response */ - public function show(Investment $investment) + public function show(int $ownerId) { - // - } - - /** - * Show the form for editing the specified resource. - * - * @param \App\Models\Investment $investment - * @return \Illuminate\Http\Response - */ - public function edit(Investment $investment) - { - // + try { + $investmentRepo = new InvestmentRepository; + $investment = $investmentRepo->getInvestmentByOwner($ownerId); + $investmentGain = $investmentRepo->getValueWithGain($investment); + + return $this->success($investmentGain, "Investmento consultado com sucesso"); + } catch (\Exception $e) { + return $this->error("Houve um erro interno ao buscar um investimento.", 500, ["detail" => $e->getMessage()]); + } } /** diff --git a/laravel/app/Http/Requests/InvestmentRequest.php b/laravel/app/Http/Requests/InvestmentRequest.php new file mode 100644 index 000000000..8f484e7c8 --- /dev/null +++ b/laravel/app/Http/Requests/InvestmentRequest.php @@ -0,0 +1,28 @@ + + */ + public function rules() + { + return []; + } +} diff --git a/laravel/app/Http/Resources/InvestmentResource.php b/laravel/app/Http/Resources/InvestmentResource.php new file mode 100644 index 000000000..f9f82bc61 --- /dev/null +++ b/laravel/app/Http/Resources/InvestmentResource.php @@ -0,0 +1,22 @@ + $this->owner + ]; + } +} diff --git a/laravel/app/Interface/InvestmentRepositoryInterface.php b/laravel/app/Interface/InvestmentRepositoryInterface.php new file mode 100644 index 000000000..702467ec7 --- /dev/null +++ b/laravel/app/Interface/InvestmentRepositoryInterface.php @@ -0,0 +1,10 @@ + "owner_id", + "create_at" => "create_at", + "value_decimal" => "value_decimal", + ]; + + /** + * Get the Owner associated with the Investment + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function owner() : HasOne + { + return $this->hasOne(Owner::class, 'owner_id', 'owner_id'); + } } diff --git a/laravel/app/Models/Owner.php b/laravel/app/Models/Owner.php index e1af643aa..16519358e 100644 --- a/laravel/app/Models/Owner.php +++ b/laravel/app/Models/Owner.php @@ -2,10 +2,28 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\HasMany; class Owner extends Model { - use HasFactory; + + + protected $fillable = ['id', 'owner_name']; + + + protected $maps = [ + "id" => "owner_id", + "owner_name" => "owner_name" + ]; + + /** + * Get the Owner associated with the Investment + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function investments() : HasMany + { + return $this->hasMany(Investment::class, 'owner_id', 'id'); + } } diff --git a/laravel/app/Providers/RepositoryServiceProvider.php b/laravel/app/Providers/RepositoryServiceProvider.php new file mode 100644 index 000000000..0df0e2fa7 --- /dev/null +++ b/laravel/app/Providers/RepositoryServiceProvider.php @@ -0,0 +1,33 @@ +app->bind(InvestmentRepositoryInterface::class, InvestmentRepository::class); + $this->app->bind(OwnerRepositoryInterface::class, OwnerRepository::class); + } + + /** + * Bootstrap services. + * + * @return void + */ + public function boot() + { + // + } +} diff --git a/laravel/app/Repositories/InvestmentRepository.php b/laravel/app/Repositories/InvestmentRepository.php new file mode 100644 index 000000000..37ef35a40 --- /dev/null +++ b/laravel/app/Repositories/InvestmentRepository.php @@ -0,0 +1,65 @@ +owner_id = $ownerId; + + $investmentNew->create_at = "2023-05-10"; + + $investmentNew->value_decimal = $investment["value_decimal"]; + return $investmentNew->save(); + } + + public function getAllInvestments() + { + return Investment::all(); + } + + public function getInvestmentByOwner(int $ownerId) + { + return Investment::where("owner_id", "=", $ownerId)->get()->first(); + } + + public function getValueWithGain(Investment $investment) + { + return [ + "initial_amount" => floatval($investment->value_decimal), + "expected_balance" => floatval(self::calculateGain($investment->create_at, $investment->value_decimal)) + ]; + } + + + public function calculateGain(string $investmentDate, string $investmentValue) + { + $toDate = Carbon::parse($investmentDate); + $fromDate = Carbon::parse(now()); + $countDiffMonth = $toDate->diffInMonths($fromDate); + + if ($countDiffMonth > 0) { + return self::multiGain($countDiffMonth - 1, $investmentValue); + } + return number_format($investmentValue, 2, '.', ''); + } + + public function multiGain($qtdMes, $value1) + { + $novoValor = ($value1 * 0.0052) + $value1; + if ($qtdMes > 0) { + return self::multiGain($qtdMes - 1, $novoValor); + } + return number_format($novoValor, 2, '.', ''); + } +} \ No newline at end of file diff --git a/laravel/app/Repositories/OwnerRepository.php b/laravel/app/Repositories/OwnerRepository.php new file mode 100644 index 000000000..ebaf0676b --- /dev/null +++ b/laravel/app/Repositories/OwnerRepository.php @@ -0,0 +1,18 @@ +id = $ownerId; + $owner->owner_name = $ownerName; + $owner->save(); + return $ownerId; + } + +} diff --git a/laravel/app/Traits/ApiResponser.php b/laravel/app/Traits/ApiResponser.php new file mode 100644 index 000000000..3548065ad --- /dev/null +++ b/laravel/app/Traits/ApiResponser.php @@ -0,0 +1,52 @@ +json([ + 'status' => 'Success', + 'message' => $message, + 'data' => $data + ], $code); + } + + /** + * Return an error JSON response. + * + * @param string $message + * @param int $code + * @param array|string|null $data + * @return \Illuminate\Http\JsonResponse + */ + protected function error(string $message = null, int $code, $data = null) + { + return response()->json([ + 'status' => 'Error', + 'message' => $message, + 'data' => $data + ], $code); + } + +} \ No newline at end of file diff --git a/laravel/composer.json b/laravel/composer.json index 299b7e8a1..a62f4273f 100644 --- a/laravel/composer.json +++ b/laravel/composer.json @@ -24,7 +24,8 @@ "psr-4": { "App\\": "app/", "Database\\Factories\\": "database/factories/", - "Database\\Seeders\\": "database/seeders/" + "Database\\Seeders\\": "database/seeders/", + "App\\Interface\\": "app//interface" } }, "autoload-dev": { @@ -62,4 +63,4 @@ }, "minimum-stability": "dev", "prefer-stable": true -} +} \ No newline at end of file diff --git a/laravel/composer.lock b/laravel/composer.lock index 991b45fe2..316626f28 100644 --- a/laravel/composer.lock +++ b/laravel/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": "ccbd816a07b206f971042295b899d1ba", + "content-hash": "8ff9e09982df10f1396e6537fed7ef13", "packages": [ { "name": "brick/math", @@ -2834,6 +2834,139 @@ ], "time": "2022-11-05T23:03:38+00:00" }, + { + "name": "ryangjchandler/orbit", + "version": "v1.1.4", + "source": { + "type": "git", + "url": "https://github.com/ryangjchandler/orbit.git", + "reference": "79c665e08d00d9b1528df619517c1cfd9a2b865a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ryangjchandler/orbit/zipball/79c665e08d00d9b1528df619517c1cfd9a2b865a", + "reference": "79c665e08d00d9b1528df619517c1cfd9a2b865a", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/console": "^9.0", + "illuminate/database": "^9.0", + "illuminate/events": "^9.0", + "illuminate/support": "^9.0", + "php": "^8.0", + "spatie/yaml-front-matter": "^2.0", + "symfony/yaml": "^6.0" + }, + "require-dev": { + "laravel/scout": "^9.4", + "nunomaduro/larastan": "^2.0", + "orchestra/testbench": "^7.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Orbit\\OrbitServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Orbit\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ryan Chandler", + "email": "support@ryangjchandler.co.uk", + "homepage": "https://ryangjchandler.co.uk", + "role": "Developer" + } + ], + "description": "A flat-file database driver for Eloquent.", + "support": { + "issues": "https://github.com/ryangjchandler/orbit/issues", + "source": "https://github.com/ryangjchandler/orbit/tree/v1.1.4" + }, + "funding": [ + { + "url": "https://github.com/ryangjchandler", + "type": "github" + } + ], + "time": "2022-08-19T09:10:44+00:00" + }, + { + "name": "spatie/yaml-front-matter", + "version": "2.0.7", + "source": { + "type": "git", + "url": "https://github.com/spatie/yaml-front-matter.git", + "reference": "f49f228994de70827ca857efffdd3bd7703aea34" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/yaml-front-matter/zipball/f49f228994de70827ca857efffdd3bd7703aea34", + "reference": "f49f228994de70827ca857efffdd3bd7703aea34", + "shasum": "" + }, + "require": { + "php": "^7.0|^8.0", + "symfony/yaml": "^3.0|^4.0|^5.0|^6.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\YamlFrontMatter\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sebastian De Deyne", + "email": "sebastian@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "A to the point yaml front matter parser", + "homepage": "https://github.com/sebastiandedeyne/yaml-front-matter", + "keywords": [ + "front matter", + "jekyll", + "spatie", + "yaml" + ], + "support": { + "source": "https://github.com/spatie/yaml-front-matter/tree/2.0.7" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2022-04-06T12:03:55+00:00" + }, { "name": "symfony/console", "version": "v6.1.7", @@ -5094,6 +5227,80 @@ ], "time": "2022-10-07T08:04:03+00:00" }, + { + "name": "symfony/yaml", + "version": "v6.1.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "66c6b0cf52b00f74614a2cf7ae7db08ea1095931" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/66c6b0cf52b00f74614a2cf7ae7db08ea1095931", + "reference": "66c6b0cf52b00f74614a2cf7ae7db08ea1095931", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "symfony/console": "<5.4" + }, + "require-dev": { + "symfony/console": "^5.4|^6.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, + "bin": [ + "Resources/bin/yaml-lint" + ], + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Loads and dumps YAML files", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/yaml/tree/v6.1.6" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-10-07T08:04:03+00:00" + }, { "name": "tijsverkoyen/css-to-inline-styles", "version": "2.2.5", diff --git a/laravel/config/app.php b/laravel/config/app.php index ef76a7ed6..a940a260d 100644 --- a/laravel/config/app.php +++ b/laravel/config/app.php @@ -194,6 +194,7 @@ // App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, + App\Providers\RepositoryServiceProvider::class, ], diff --git a/laravel/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/laravel/database/migrations/2019_08_19_000000_create_failed_jobs_table.php deleted file mode 100644 index 17191986b..000000000 --- a/laravel/database/migrations/2019_08_19_000000_create_failed_jobs_table.php +++ /dev/null @@ -1,36 +0,0 @@ -id(); - $table->string('uuid')->unique(); - $table->text('connection'); - $table->text('queue'); - $table->longText('payload'); - $table->longText('exception'); - $table->timestamp('failed_at')->useCurrent(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('failed_jobs'); - } -}; diff --git a/laravel/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php b/laravel/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php deleted file mode 100644 index 6c81fd229..000000000 --- a/laravel/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php +++ /dev/null @@ -1,37 +0,0 @@ -id(); - $table->morphs('tokenable'); - $table->string('name'); - $table->string('token', 64)->unique(); - $table->text('abilities')->nullable(); - $table->timestamp('last_used_at')->nullable(); - $table->timestamp('expires_at')->nullable(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('personal_access_tokens'); - } -}; diff --git a/laravel/database/migrations/2014_10_12_100000_create_password_resets_table.php b/laravel/database/migrations/2022_11_23_223451_create_owners_table.php similarity index 60% rename from laravel/database/migrations/2014_10_12_100000_create_password_resets_table.php rename to laravel/database/migrations/2022_11_23_223451_create_owners_table.php index fcacb80b3..bb136ac45 100644 --- a/laravel/database/migrations/2014_10_12_100000_create_password_resets_table.php +++ b/laravel/database/migrations/2022_11_23_223451_create_owners_table.php @@ -13,10 +13,10 @@ */ public function up() { - Schema::create('password_resets', function (Blueprint $table) { - $table->string('email')->index(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); + Schema::create('owners', function (Blueprint $table) { + $table->bigInteger('id'); + $table->string('owner_name'); + $table->timestamps(); }); } @@ -27,6 +27,6 @@ public function up() */ public function down() { - Schema::dropIfExists('password_resets'); + Schema::dropIfExists('owners'); } }; diff --git a/laravel/database/migrations/2014_10_12_000000_create_users_table.php b/laravel/database/migrations/2022_11_24_222854_create_investments_table.php similarity index 54% rename from laravel/database/migrations/2014_10_12_000000_create_users_table.php rename to laravel/database/migrations/2022_11_24_222854_create_investments_table.php index cf6b77661..af652d23c 100644 --- a/laravel/database/migrations/2014_10_12_000000_create_users_table.php +++ b/laravel/database/migrations/2022_11_24_222854_create_investments_table.php @@ -13,14 +13,11 @@ */ public function up() { - Schema::create('users', function (Blueprint $table) { + Schema::create('investments', function (Blueprint $table) { $table->id(); - $table->string('name'); - $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); - $table->string('password'); - $table->rememberToken(); - $table->timestamps(); + $table->decimal("value_decimal", 10, 2); + $table->timestamp("create_at"); + $table->biginteger('owner_id'); }); } @@ -31,6 +28,6 @@ public function up() */ public function down() { - Schema::dropIfExists('users'); + Schema::dropIfExists('investments'); } }; diff --git a/laravel/routes/v1/api.php b/laravel/routes/v1/api.php index 269d45bf4..b88824dd2 100644 --- a/laravel/routes/v1/api.php +++ b/laravel/routes/v1/api.php @@ -1,5 +1,6 @@ json(['code' => 200, 'status' => 'Connected', 'message' => 'API is working']); }); + + +Route::apiResource("investment", InvestmentController::class); \ No newline at end of file diff --git a/laravel/storage/.DS_Store b/laravel/storage/.DS_Store index d7c78a45df37357623372a7e9ddc7acf83539182..d362afb6098cca113919142a3f568183803cb5b5 100644 GIT binary patch delta 47 zcmV+~0MP%0FoZC$paKF>@{`O07?ZjJU;*Hh8v`2xm~N9e16cwAu(P29W(1LN4zmXc F{STUI5LEyG delta 47 zcmV+~0MP%0FoZC$paKFlRg=sD7?ZjJU;(g`8v`2xW1EvW16cwBK(nC(W(1LN4zmXc F{SR`g4)p*4 From ff28d9280b2cd5dc702907e574d4244cbd5e39d9 Mon Sep 17 00:00:00 2001 From: Daniel Batista Maia dos Santos Date: Thu, 24 Nov 2022 19:49:08 -0300 Subject: [PATCH 3/6] Realizado criacao de demais funcionalidades com paginacao na busca --- .../Http/Controllers/InvestmentController.php | 68 ++++++++++++++----- .../app/Http/Requests/InvestmentRequest.php | 28 -------- .../app/Repositories/InvestmentRepository.php | 62 +++++++++++++++-- ..._11_24_222854_create_investments_table.php | 4 +- laravel/routes/v1/api.php | 4 -- 5 files changed, 110 insertions(+), 56 deletions(-) delete mode 100644 laravel/app/Http/Requests/InvestmentRequest.php diff --git a/laravel/app/Http/Controllers/InvestmentController.php b/laravel/app/Http/Controllers/InvestmentController.php index fd7cd8466..3e0a88e42 100644 --- a/laravel/app/Http/Controllers/InvestmentController.php +++ b/laravel/app/Http/Controllers/InvestmentController.php @@ -9,6 +9,8 @@ use App\Repositories\OwnerRepository; use App\Traits\ApiResponser; use Illuminate\Http\Request; +use Symfony\Component\HttpFoundation\Response; +use Illuminate\Support\Facades\Validator; class InvestmentController extends Controller { @@ -19,9 +21,16 @@ class InvestmentController extends Controller * * @return \Illuminate\Http\Response */ - public function index() + public function index(Request $request) { - // + try { + $investmentRepo = new InvestmentRepository; + $allInvestments = $investmentRepo->getInvestmentByOwner($request->owner_id); + + return $this->success($allInvestments, "Investmento criado com sucesso"); + } catch (\Exception $e) { + return $this->error("Houve um erro interno ao buscar a lista de todos os investimentos.", 500, ["detail" => $e->getMessage()]); + } } /** @@ -30,7 +39,7 @@ public function index() * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ - public function store(InvestmentRequest $request) + public function store(Request $request) { try { $ownerRepo = new OwnerRepository; @@ -51,16 +60,26 @@ public function store(InvestmentRequest $request) * @param int $ownerId * @return \Illuminate\Http\Response */ - public function show(int $ownerId) + public function show(int $investmentId) { try { + $validator = Validator::make(["investmentId" => $investmentId], [ + 'investmentId' => 'required|numeric', + ]); + if ($validator->fails()) { + return $this->error( + 'Falha ao realizar ao consultar um investmento.', + Response::HTTP_BAD_REQUEST, + $validator->errors() + ); + } $investmentRepo = new InvestmentRepository; - $investment = $investmentRepo->getInvestmentByOwner($ownerId); + $investment = $investmentRepo->getInvestmentById($investmentId); $investmentGain = $investmentRepo->getValueWithGain($investment); return $this->success($investmentGain, "Investmento consultado com sucesso"); } catch (\Exception $e) { - return $this->error("Houve um erro interno ao buscar um investimento.", 500, ["detail" => $e->getMessage()]); + return $this->error("Houve um erro interno ao buscar um investimento.", Response::HTTP_INTERNAL_SERVER_ERROR, ["detail" => $e->getMessage()]); } } @@ -73,17 +92,30 @@ public function show(int $ownerId) */ public function update(Request $request, Investment $investment) { - // - } - - /** - * Remove the specified resource from storage. - * - * @param \App\Models\Investment $investment - * @return \Illuminate\Http\Response - */ - public function destroy(Investment $investment) - { - // + try { + $validator = Validator::make( + [ + "investmentId" => $investment->id, + "date" => $request->date + ], + [ + 'investmentId' => 'required|numeric|exists:investments,id', + 'date' => 'required' + ]); + if ($validator->fails()) { + return $this->error( + 'Falha ao realizar a retirada de um investmento.', + Response::HTTP_BAD_REQUEST, + $validator->errors() + ); + } + $investmentRepo = new InvestmentRepository; + $investment = $investmentRepo->withdrawalInvestment($investment, $request->date); + + return $this->success($investment, "Investmento retirado com sucesso"); + } catch (\Exception $e) { + return $this->error("Houve um erro interno ao retirar um investimento.", Response::HTTP_INTERNAL_SERVER_ERROR, ["detail" => $e->getMessage()]); + } + } } diff --git a/laravel/app/Http/Requests/InvestmentRequest.php b/laravel/app/Http/Requests/InvestmentRequest.php deleted file mode 100644 index 8f484e7c8..000000000 --- a/laravel/app/Http/Requests/InvestmentRequest.php +++ /dev/null @@ -1,28 +0,0 @@ - - */ - public function rules() - { - return []; - } -} diff --git a/laravel/app/Repositories/InvestmentRepository.php b/laravel/app/Repositories/InvestmentRepository.php index 37ef35a40..1dc6a5fc8 100644 --- a/laravel/app/Repositories/InvestmentRepository.php +++ b/laravel/app/Repositories/InvestmentRepository.php @@ -6,18 +6,26 @@ use App\Models\Investment; use Carbon\Carbon; use DateTime; +use Exception; use Illuminate\Support\Facades\Date; use PhpParser\Node\Expr\Cast\Double; +use function PHPUnit\Framework\throwException; + class InvestmentRepository { + public function getInvestmentByOwner(int $ownerId) + { + return Investment::where('owner_id', '=', $ownerId)->paginate(3); + } + public function setInvestment(array $investment, int $ownerId) { $investmentNew = new Investment(); $investmentNew->owner_id = $ownerId; - $investmentNew->create_at = "2023-05-10"; + $investmentNew->create_at = $investment["create_at"]; $investmentNew->value_decimal = $investment["value_decimal"]; return $investmentNew->save(); @@ -28,16 +36,17 @@ public function getAllInvestments() return Investment::all(); } - public function getInvestmentByOwner(int $ownerId) + public function getInvestmentById(int $investmentId) { - return Investment::where("owner_id", "=", $ownerId)->get()->first(); + return Investment::where("id", "=", $investmentId)->get()->first(); } public function getValueWithGain(Investment $investment) { + $gain = self::setGain($investment, floatval(self::calculateGain($investment->create_at, $investment->value_decimal))); return [ "initial_amount" => floatval($investment->value_decimal), - "expected_balance" => floatval(self::calculateGain($investment->create_at, $investment->value_decimal)) + "expected_balance" => $gain ]; } @@ -62,4 +71,49 @@ public function multiGain($qtdMes, $value1) } return number_format($novoValor, 2, '.', ''); } + + public function setGain(Investment $investment, float $gain) + { + $investment->value_final = $gain; + $investment->save(); + return $gain; + } + + public function withdrawalInvestment(Investment $investment, string $date) + { + if ($date > $investment->create_at && $investment->value_final > 0) { + $taxes = self::getValueWitoutTaxes($investment); + + $value = $investment->value_final - $taxes; + + $investment->value_final = 0.00; + $investment->value_decimal = 0.00; + $investment->save(); + + return [ + "withdrawalValue" => floatval(number_format($value, 2, '.', '')), + "taxes" => floatval(number_format($taxes, 2, '.', '')) + ]; + } else if ($investment->value_final == 0 && $investment->value_decimal == 0) { + return throw new Exception("O investmento desejado já não possui mais saldo para retirada."); + } + return throw new Exception("A data de retirada informada é menor que a data do investmento."); + } + + + public function getValueWitoutTaxes(Investment $investment) + { + $toDate = Carbon::parse($investment->create_at); + $fromDate = Carbon::parse(now()); + $investmentAge = $toDate->diffInMonths($fromDate); + + if ($investmentAge <= 12) { + $taxes = 0.225; + }elseif ($investmentAge > 12 && $investment <= 24) { + $taxes = 0.185; + }else { + $taxes = 0.15; + } + return ($investment->value_final * $taxes); + } } \ No newline at end of file diff --git a/laravel/database/migrations/2022_11_24_222854_create_investments_table.php b/laravel/database/migrations/2022_11_24_222854_create_investments_table.php index af652d23c..39d9f195b 100644 --- a/laravel/database/migrations/2022_11_24_222854_create_investments_table.php +++ b/laravel/database/migrations/2022_11_24_222854_create_investments_table.php @@ -16,6 +16,7 @@ public function up() Schema::create('investments', function (Blueprint $table) { $table->id(); $table->decimal("value_decimal", 10, 2); + $table->decimal("value_final", 10, 2); $table->timestamp("create_at"); $table->biginteger('owner_id'); }); @@ -23,8 +24,7 @@ public function up() /** * Reverse the migrations. - * - * @return void + * * @return void */ public function down() { diff --git a/laravel/routes/v1/api.php b/laravel/routes/v1/api.php index b88824dd2..d60efc686 100644 --- a/laravel/routes/v1/api.php +++ b/laravel/routes/v1/api.php @@ -17,10 +17,6 @@ | */ -Route::middleware('auth:sanctum')->get('/user', function (Request $request) { - return $request->user(); -}); - Route::get('/status', function () { return response()->json(['code' => 200, 'status' => 'Connected', 'message' => 'API is working']); From b32b58643f3390d101a1cd07594f8b14a3449494 Mon Sep 17 00:00:00 2001 From: Daniel Batista Maia dos Santos Date: Thu, 24 Nov 2022 19:52:43 -0300 Subject: [PATCH 4/6] commitando alteracoes no repo --- .DS_Store | Bin 0 -> 6148 bytes laravel/.DS_Store | Bin 8196 -> 10244 bytes laravel/app/.DS_Store | Bin 6148 -> 8196 bytes laravel/app/Http/.DS_Store | Bin 6148 -> 6148 bytes laravel/bootstrap/.DS_Store | Bin 0 -> 6148 bytes laravel/database/.DS_Store | Bin 6148 -> 6148 bytes laravel/storage/.DS_Store | Bin 6148 -> 6148 bytes laravel/storage/framework/.DS_Store | Bin 6148 -> 6148 bytes 8 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 .DS_Store create mode 100644 laravel/bootstrap/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0fb2c3f20d5b8c21735b023301d4a0528e27db89 GIT binary patch literal 6148 zcmeHK!EVz)5S>j8*-# tEdGbRVEGRN*I+xLBX!0)Zlod#AyyuB;Q-k z?WG5<`~f}l4V?K2D)q+9?nZSI3O9u4jx_VuJ2ShU7kM`W0IWWUT!1P7a8yF)7MfoO z`AO%bWM(Lj(HcqH_4j0_I~QpuECZH-e~|(Db{%*KZHOT&e!pz*^J&r7k&Q-}$PnlF zr|loRODA8SPy3_a`n&s=XG7`iJElSz5(uD&dH^j*!ePH_cK8x@lenL)u6|>s1?R@i zGB5K*{?^}@Lq7|$LBAgKcIoMrlu0-l2jNcK8aAtUwq%+GaoXysgg9zp$eY)38p&Z@ z4$`Qva((UK6<%pp?~g|A( BvihuZ}9x>@2I-npx+-@1==M z+vuBAp~9@WZVZ^8pD$jw!fm~l0n5N28KCn)pb~lpbB*fgK%-g!L UN)j{kQj5SEGE-84N@Bt@^HTE5o$^cb zQi{QPgMku(Kp75B4$gQ1$?9rDOA8$ZV?)DQ9ffK`Lo*W{1v6vw+FDKyQDuGWp!n>Z z+`Rm5pnHLU5$G#0;DypKs%JBgz#&Gag~pRF2#T>aJ?))eG=1_LK?y|&^N1r*A=JMG z8HT~h`MCvPtxOJ+RfPhX!Y)j%5SppH7%0ZZkj#+JkjIe5kjapqoA2TR4MC3e><7P| zpElV HrRcL?|0K*Iv-3*fp ZWO~^ca)7a(H(5bga&w?aJ-H6d0RW2Pt{VUV delta 383 zcmZn(XmOBWU|?W$DortDU;r^WfEYvza8E20o2aKKst=L}@)^nsl5+BsfSf5w1se;e zu}^H^-OSFx!ojG&`L@6zMy8bcljjSGP0keN=3-_@WGG-L$jwigoFFVB2IUrH7zQWj z=N14B1e#JX`HN5>Q|RQ$g~Ae( fD%5H0V-xF=r~3ub0w>YN-XE;89(Je-N?!sHp^ z^O&!HjG1gHA;b1FC||05%H(JXIT*8ELXMgF?}UkkW`fLMM=?ln18G-~?>82HXP(Tj Z637AcJ19&TCdczkoqR_0GWBdV1^}eQZZ`k` diff --git a/laravel/app/.DS_Store b/laravel/app/.DS_Store index 822ca5fc28e91044bd9f15006c7340f181a3f71b..73e06e1a7dedaec011f70ceacbc0e9ec07314f46 100644 GIT binary patch literal 8196 zcmeI1&uSDw5XP(HU=kG)Z#g#N3*-TWF>b&d6iFoK{Ml6(X6-e*ir{6yi=Y=Fphu61 zh!5aFFClq~Jc1_?!Grj9S8uj^re_H`h+;KN*V6q}_m8i4W>XU)QcI89i$n`VG=s~= z`HSch&Cc7a)~5W3MpVcrGE`8fxWBlzZE9*65C_BoaX=gp2gHHD!2$ec+cwkiyU(-I ziv!}of9ZgIK4@Gv=027j-J=7YD*+HQ47-NUr~_P%_A&Rd -s`h?YQL`N znO1A7Fk6_hx83o|>x1hlRr?gG{sa5AV6>aNdoR#3J*92xP@jg>Wj21RFw$kK*e|JT zU~AAO36t6cXGS-{H>7^dcKZX^PUb?MAJ=xT&b@VB1@mKu)O@tB(pZ{iX$7Y>gg-lU zk2bASF@buPR)s8IJNjtw#<3*U>zOgtWM#z15AE}G3uo2_UqOSIEc*_!Xg*~6w)eSs zwd I5^SU@s1HvvwDxS@~o1_g{f3AQ0^oUs-*A7qiH2RoZ0|n=I7o?kxxx$*QSLZ{% z_lGZ@8|I7F2$`BRF~_|B^Fe<9?SV)W2hQNYInG(I_5X77`~NenEGgoEIPkAHpt9Cl zYYDWzwyts8T3h4Vz-61&l^k6PIxDf`t{g`^`G+AsYd@F!SaQS+n!E^bHb^H9{80yf E14kzwl>h($ delta 246 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{Mvv5r;6q~50$SATgU^g?P$YdUY?Tk{BKL|)o zz9-PYWc+<{f}q4?9|7*k&4QwAKn-_2Cr+LxD9yxhVRE#PJQMSj$u&YUU Ji=8e_o5LKViv>>M0|%uwCjK-v}L^o@nznJ4qhc!E5_zy$FW$e#?G<9X&V F0{~-LH8KDI diff --git a/laravel/app/Http/.DS_Store b/laravel/app/Http/.DS_Store index 241e258cf913f1a6d7d4c6b2ab02c69f5184ea08..01776b97b74f238658e7b6ae08c1d63fdbe48ef4 100644 GIT binary patch delta 234 zcmZoMXfc@J&&abeU^gQp&tx7Z4JL`@KuT(I022>ephs6q&y>j%m}Dl`A#=5u92h1G zFiT9n!Zf*_lOc#9m7$m+pP`hYh#?uo&Pg{6PR`FQU;qQ=av+68Rc^kEOHxjL5>S>y lJN3r;^65t$aj8tfsZtiz>Vgbps}(jEGPAI3X6N|J4*=|PJ2(IU delta 79 zcmZoMXfc@J&&aVcU^gQp$7CKR4JO7+ASE?9fQg5Vfq~(!=fueqm}Dl`A#=5u1Q;d@ YFiT9n!ZdlaD2EWs#D>1j>>Pjj0Vq)wKmY&$ diff --git a/laravel/bootstrap/.DS_Store b/laravel/bootstrap/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..73cd0e0dced35d030c7773bd593354de3b881a00 GIT binary patch literal 6148 zcmeHKJ5B>J5S@WUT8Snl1% gnAk;ZTAnX%VTTH8ZJJbPG8i6%r;K?PZi0g>TB*NF#@fUI-eZtkXwWxL%CO!GH~ z *|<4X*h8 +B)JgOJ<44d-1^~d()u1(NusEEWBF(9xzj{tP!9648~`IFd)%Z|lR UW|47C2gXA{35g~c_yq<&0aYL?t^fc4 literal 0 HcmV?d00001 diff --git a/laravel/database/.DS_Store b/laravel/database/.DS_Store index 7652bb3720d1b002f42e78873dd4ddf00215e2db..93ea12e333cbb92b9bba7af26aabc144da19cbed 100644 GIT binary patch delta 60 zcmZoMXffDuiHV6dcoMVJ @{`O07?ZjJUjhK&lN$pX0|A(BlQ;ue0s*kIp#x?Fk#G*P H2MGNSs(%nx diff --git a/laravel/storage/framework/.DS_Store b/laravel/storage/framework/.DS_Store index eef549e3dacc8fde9e6e98da09e3f434e617e032..679aa337ac699aee38e0f320319716fe01b793c9 100644 GIT binary patch delta 173 zcmZoMXffEJ!NL^aF 51gzwC>$zCinFlG*m9Mc4b$s1TiCNE&&V`A #WcWmUnfDMuVp)fQwJ1}Ep|763(o;KIhjD~y}jIsWnk05g3ww*UYD delta 158 zcmZoMXffEJ!NSC#JXwoHYH}AV_hf$-aWGxTBFUt{FnI%u$m9hqd`t{{K&Ap%W;2WM z Q46F=g44Dk64CM^Px%n iRROc69C1WdTaaNGoSdIq02Bp+jfqzoH?wp6 U_ From fce2f56c3286fcbbccc15fefc80d6542e9b29119 Mon Sep 17 00:00:00 2001 From: "danielmaia150@gmail.com"
Date: Thu, 24 Nov 2022 19:57:55 -0300 Subject: [PATCH 5/6] Subindo update da documentacao --- postman/collections/API Collections.json | 154 +++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 postman/collections/API Collections.json diff --git a/postman/collections/API Collections.json b/postman/collections/API Collections.json new file mode 100644 index 000000000..7f8b8434c --- /dev/null +++ b/postman/collections/API Collections.json @@ -0,0 +1,154 @@ +{ + "info": { + "_postman_id": "6e6f38b0-b691-496c-9307-37ee31cdb89c", + "name": "API Collections", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_uid": "9534004-6e6f38b0-b691-496c-9307-37ee31cdb89c" + }, + "item": [ + { + "name": "Check if API is up", + "id": "b1dfc547-1580-4102-be7b-c7bc22e4f4af", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{enviroment_url}}/api/v1/status", + "host": [ + "{{enviroment_url}}" + ], + "path": [ + "api", + "v1", + "status" + ] + } + }, + "response": [] + }, + { + "name": "Create new Investment", + "id": "0f3835ab-810f-4f17-bf25-d001cf7a5c14", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"owner_id\": 1,\n \"owner_name\": \"Daniel Maia\",\n \"invesment\": {\n \"create_at\": \"2023-05-01\",\n \"value_decimal\": 990000.00\n }\n\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{enviroment_url}}/api/v1/investment", + "host": [ + "{{enviroment_url}}" + ], + "path": [ + "api", + "v1", + "investment" + ] + } + }, + "response": [] + }, + { + "name": "Get Investment by Id", + "id": "bd89752f-4bc6-42fc-a7c9-1f6d4f58eae6", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{enviroment_url}}/api/v1/investment/5", + "host": [ + "{{enviroment_url}}" + ], + "path": [ + "api", + "v1", + "investment", + "5" + ] + } + }, + "response": [] + }, + { + "name": "Withdrawal", + "id": "a5f5b8c4-e794-49c0-b6ac-43b82701f6f8", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"date\": \"2024-06-10\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{enviroment_url}}/api/v1/investment/1", + "host": [ + "{{enviroment_url}}" + ], + "path": [ + "api", + "v1", + "investment", + "1" + ] + } + }, + "response": [] + }, + { + "name": "Get All Investments by Owner", + "id": "9a13215c-0f4b-42b7-8a43-424fc951518b", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"owner_id\": 1\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{enviroment_url}}/api/v1/investment", + "host": [ + "{{enviroment_url}}" + ], + "path": [ + "api", + "v1", + "investment" + ] + } + }, + "response": [] + } + ] +} \ No newline at end of file From 8e87d0f981cec6fe0dee40fc9752489734e3915f Mon Sep 17 00:00:00 2001 From: Daniel Batista Maia Dos Santos <42100390+danielsantos150@users.noreply.github.com> Date: Thu, 24 Nov 2022 20:10:45 -0300 Subject: [PATCH 6/6] Update README.md atualizando o readme.md do projeto --- laravel/README.md | 73 +++++++++++------------------------------------ 1 file changed, 17 insertions(+), 56 deletions(-) diff --git a/laravel/README.md b/laravel/README.md index bf0ddd92c..16a9a8394 100644 --- a/laravel/README.md +++ b/laravel/README.md @@ -1,66 +1,27 @@ - + - +## Documentação API em Laravel -## About Laravel +Esta aplicação é responsável por realizar o controle de um investmento, sendo possível criar um investmento, sacar e visualizar. -Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: +Bibliotecas e versões utilizadas nesse sistema: -- [Simple, fast routing engine](https://laravel.com/docs/routing). -- [Powerful dependency injection container](https://laravel.com/docs/container). -- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. -- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). -- Database agnostic [schema migrations](https://laravel.com/docs/migrations). -- [Robust background job processing](https://laravel.com/docs/queues). -- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). +- "php": ^8.0.2, +- "laravel/framework": 9.19 -Laravel is accessible, powerful, and provides tools required for large, robust applications. -## Learning Laravel +Abaixo segue o passo a passo para executar o projeto e realizar os testes -Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. +### Passo a Passo -You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch. +- Realizar o download do repositório +- Abrir o CMD no diretório root do projeto e executar "composer update" +- Executar comando para criar o .env e "application key" no .env "cp .env.example .env" e em seguida "php artisan key:generate" +- Atualizar as informações do arquivo .env com a sua conexão de banco de dados +- Executar os migrations para o sistema criar a base de dados "php artisan migrate" +- Iniciar o ambiente de desenvolvimento do laravel "php artisan serve" -If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. +#### Rotas e Funcionalidades -## Laravel Sponsors - -We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell). - -### Premium Partners - -- **[Vehikl](https://vehikl.com/)** -- **[Tighten Co.](https://tighten.co)** -- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** -- **[64 Robots](https://64robots.com)** -- **[Cubet Techno Labs](https://cubettech.com)** -- **[Cyber-Duck](https://cyber-duck.co.uk)** -- **[Many](https://www.many.co.uk)** -- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)** -- **[DevSquad](https://devsquad.com)** -- **[Curotec](https://www.curotec.com/services/technologies/laravel/)** -- **[OP.GG](https://op.gg)** -- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)** -- **[Lendio](https://lendio.com)** - -## Contributing - -Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). - -## Code of Conduct - -In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). - -## Security Vulnerabilities - -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. - -## License - -The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). +- Documentação das Rotas: + - https://documenter.getpostman.com/view/9534004/2s8YsqUuEy