Browse Source

I know, I know, this is not how I’m supposed to do it, but I can't think of something better.

pull/2/head
Mohammad Akbari 4 years ago
parent
commit
fe4dd7f8dc
Signed by: akbarjimi GPG Key ID: 55726AEFECE5E683
  1. 2
      app/Console/Commands/CostCommand.php
  2. 26
      app/Enums/log.php
  3. 6
      app/Http/Controllers/AuthController.php
  4. 6
      app/Http/Controllers/BusinessController.php
  5. 2
      app/Http/Controllers/CommentController.php
  6. 4
      app/Http/Controllers/Controller.php
  7. 8
      app/Http/Controllers/FileController.php
  8. 2
      app/Http/Controllers/InvoiceController.php
  9. 2
      app/Http/Controllers/ProjectController.php
  10. 2
      app/Http/Controllers/SprintController.php
  11. 2
      app/Http/Controllers/StatisticController.php
  12. 2
      app/Http/Controllers/StatusController.php
  13. 2
      app/Http/Controllers/SystemController.php
  14. 2
      app/Http/Controllers/TagController.php
  15. 10
      app/Http/Controllers/TaskController.php
  16. 6
      app/Http/Controllers/TaskFileController.php
  17. 4
      app/Http/Controllers/UserController.php
  18. 4
      app/Http/Controllers/WorkController.php
  19. 2
      app/Http/Controllers/WorkflowController.php
  20. 2
      app/Http/Kernel.php
  21. 2
      app/Providers/AuthServiceProvider.php
  22. 2
      app/Providers/RouteServiceProvider.php
  23. 2
      app/Utilities/BusinessInfoRequestMixin.php
  24. 7
      app/Utilities/Middlewares/BindBusinessInfo.php
  25. 2
      app/Utilities/Providers/AuthServiceProvider.php
  26. 3
      composer.json
  27. 65
      composer.lock
  28. 122
      config/api-postman.php
  29. 3
      routes/api.php

2
app/Console/Commands/CostCommand.php

@ -3,7 +3,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use DB; use DB;
use App\Business;
use App\Models\Business;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;

26
app/Enums/log.php

@ -1 +1,25 @@
<?php use App\User; use App\Business; use App\Project; use App\Task; use App\SpentHour; return [ 'types' => [ User::class => 10, Business::class => 20, Project::class => 30, Task::class => 40, Spenthour::class => 50, ], 'actions' => [ 'created' => 10, 'updated' => 20, 'deleted' => 30, 'restored' => 40, ], ];
<?php
use App\Models\User;
use App\Models\Business;
use App\Project;
use App\Task;
use App\SpentHour;
return [
'types' => [
User::class => 10,
Business::class => 20,
Project::class => 30,
Task::class => 40,
Spenthour::class => 50,
],
'actions' => [
'created' => 10,
'updated' => 20,
'deleted' => 30,
'restored' => 40,
],
];

6
app/Http/Controllers/AuthController.php

@ -2,9 +2,9 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\User;
use App\Business;
use App\Fingerprint;
use App\Models\User;
use App\Models\Business;
use App\Models\Fingerprint;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Validation\Rule; use Illuminate\Validation\Rule;

6
app/Http/Controllers/BusinessController.php

@ -2,11 +2,11 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\User;
use App\Business;
use App\Models\User;
use App\Models\Business;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Auth;
class BusinessController extends Controller class BusinessController extends Controller
{ {

2
app/Http/Controllers/CommentController.php

@ -2,8 +2,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Comment;
use App\Models\Task; use App\Models\Task;
use App\Models\Comment;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;

4
app/Http/Controllers/Controller.php

@ -2,10 +2,10 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController; use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class Controller extends BaseController class Controller extends BaseController
{ {

8
app/Http/Controllers/FileController.php

@ -4,8 +4,8 @@ namespace App\Http\Controllers;
use App\File; use App\File;
use App\Project; use App\Project;
use App\Business;
use App\Rules\maxBound;
use App\Models\Business;
use App\Rules\MaxBound;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile; use Illuminate\Http\UploadedFile;
@ -32,8 +32,8 @@ class FileController extends Controller
{ {
$bound = 10; $bound = 10;
$this->validate($request, [ $this->validate($request, [
'filter.project_id' => [new maxBound($bound)] ,
'filter.user_id' => [new maxBound($bound)] ,
'filter.project_id' => [new MaxBound($bound)] ,
'filter.user_id' => [new MaxBound($bound)] ,
]); ]);
} }

2
app/Http/Controllers/InvoiceController.php

@ -3,7 +3,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Cost; use App\Cost;
use App\Business;
use App\Models\Business;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Spatie\QueryBuilder\QueryBuilder; use Spatie\QueryBuilder\QueryBuilder;
use Spatie\QueryBuilder\AllowedFilter; use Spatie\QueryBuilder\AllowedFilter;

2
app/Http/Controllers/ProjectController.php

@ -3,7 +3,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Project; use App\Project;
use App\Business;
use App\Models\Business;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;

2
app/Http/Controllers/SprintController.php

@ -4,8 +4,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Business;
use App\Sprint; use App\Sprint;
use App\Models\Business;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class SprintController extends Controller class SprintController extends Controller

2
app/Http/Controllers/StatisticController.php

@ -2,8 +2,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
class StatisticController extends Controller class StatisticController extends Controller

2
app/Http/Controllers/StatusController.php

@ -4,8 +4,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Business;
use App\Status; use App\Status;
use App\Models\Business;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Validation\Rule; use Illuminate\Validation\Rule;

2
app/Http/Controllers/SystemController.php

@ -2,8 +2,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Business;
use App\System; use App\System;
use App\Models\Business;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class SystemController extends Controller class SystemController extends Controller

2
app/Http/Controllers/TagController.php

@ -4,8 +4,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Business;
use App\Tag; use App\Tag;
use App\Models\Business;
use App\Workflow; use App\Workflow;
use Illuminate\Http\Request; use Illuminate\Http\Request;

10
app/Http/Controllers/TaskController.php

@ -2,18 +2,18 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Http\Resources\TaskCollection;
use App\Http\Resources\TaskResource;
use App\Rules\maxBound;
use App\TagTask; use App\TagTask;
use Carbon\Carbon;
use App\Models\Task; use App\Models\Task;
use App\Models\Work; use App\Models\Work;
use Carbon\Carbon;
use App\Rules\maxBound;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Spatie\QueryBuilder\AllowedFilter;
use App\Http\Resources\TaskResource;
use Spatie\QueryBuilder\QueryBuilder; use Spatie\QueryBuilder\QueryBuilder;
use App\Http\Resources\TaskCollection;
use Spatie\QueryBuilder\AllowedFilter;
class TaskController extends Controller class TaskController extends Controller
{ {

6
app/Http/Controllers/TaskFileController.php

@ -6,13 +6,13 @@ use Auth;
use App\File; use App\File;
use App\Task; use App\Task;
use App\Project; use App\Project;
use App\Business;
use Illuminate\Http\Exceptions\HttpResponseException;
use App\Models\Business;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use mysql_xdevapi\Exception;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Resources\FileResource; use App\Http\Resources\FileResource;
use mysql_xdevapi\Exception;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Illuminate\Http\Exceptions\HttpResponseException;
class TaskFileController extends Controller class TaskFileController extends Controller
{ {

4
app/Http/Controllers/UserController.php

@ -4,10 +4,10 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\User;
use App\Models\User;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Spatie\QueryBuilder\AllowedFilter;
use Spatie\QueryBuilder\QueryBuilder; use Spatie\QueryBuilder\QueryBuilder;
use Spatie\QueryBuilder\AllowedFilter;
class UserController extends Controller class UserController extends Controller
{ {

4
app/Http/Controllers/WorkController.php

@ -2,13 +2,13 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Carbon\Carbon;
use App\Models\Task; use App\Models\Task;
use App\Models\Work; use App\Models\Work;
use Carbon\Carbon;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Spatie\QueryBuilder\AllowedFilter;
use Spatie\QueryBuilder\QueryBuilder; use Spatie\QueryBuilder\QueryBuilder;
use Spatie\QueryBuilder\AllowedFilter;
class WorkController extends Controller class WorkController extends Controller
{ {

2
app/Http/Controllers/WorkflowController.php

@ -4,8 +4,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Business;
use App\Status; use App\Status;
use App\Models\Business;
use App\Workflow; use App\Workflow;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;

2
app/Http/Kernel.php

@ -2,6 +2,7 @@
namespace App\Http; namespace App\Http;
use App\Utilities\Middlewares\BindBusinessInfo;
use Illuminate\Foundation\Http\Kernel as HttpKernel; use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel class Kernel extends HttpKernel
@ -62,5 +63,6 @@ class Kernel extends HttpKernel
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'bindBusiness' => BindBusinessInfo::class,
]; ];
} }

2
app/Providers/AuthServiceProvider.php

@ -2,7 +2,7 @@
namespace App\Providers; namespace App\Providers;
use App\Fingerprint;
use App\Models\Fingerprint;
use App\Utilities\RequestMixin; use App\Utilities\RequestMixin;
use App\Utilities\BusinessInfoRequestMixin; use App\Utilities\BusinessInfoRequestMixin;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;

2
app/Providers/RouteServiceProvider.php

@ -26,7 +26,7 @@ class RouteServiceProvider extends ServiceProvider
* *
* @var string|null * @var string|null
*/ */
// protected $namespace = 'App\\Http\\Controllers';
protected $namespace = 'App\\Http\\Controllers';
/** /**
* Define your route model bindings, pattern filters, etc. * Define your route model bindings, pattern filters, etc.

2
app/Utilities/BusinessInfoRequestMixin.php

@ -2,7 +2,7 @@
namespace App\Utilities; namespace App\Utilities;
use App\User;
use App\Models\User;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Jenssegers\Agent\Agent; use Jenssegers\Agent\Agent;

7
app/Utilities/Middlewares/BindBusinessInfo.php

@ -3,6 +3,7 @@
namespace App\Utilities\Middlewares; namespace App\Utilities\Middlewares;
use Closure; use Closure;
use App\Models\Business;
class BindBusinessInfo class BindBusinessInfo
{ {
@ -10,11 +11,7 @@ class BindBusinessInfo
public function handle($request, Closure $next, $guard = null) public function handle($request, Closure $next, $guard = null)
{ {
$business_id = $request->has('business_id') ? $request->business_id : $request->route('business'); $business_id = $request->has('business_id') ? $request->business_id : $request->route('business');
$businessInfo = env('CONTAINER_NAME') == 'hi-user-app' ?
\App\Business::info($business_id) :
get('user', env('USER_URL') . 'actions/businesses/' . $business_id . '/info', []);
$businessInfo = Business::info($business_id);
$request->merge(['_business_info' => $businessInfo]); $request->merge(['_business_info' => $businessInfo]);
return $next($request); return $next($request);

2
app/Utilities/Providers/AuthServiceProvider.php

@ -2,7 +2,7 @@
namespace App\Utilities\Providers; namespace App\Utilities\Providers;
use App\User;
use App\Models\User;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;

3
composer.json

@ -36,7 +36,8 @@
"laravel/sail": "^1.0.1", "laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.2", "mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^5.0", "nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3.3"
"phpunit/phpunit": "^9.3.3",
"andreaselia/laravel-api-to-postman":"^1.0"
}, },
"config": { "config": {
"optimize-autoloader": true, "optimize-autoloader": true,

65
composer.lock

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "f9d97bc77997badf02ebb4ff03402453",
"content-hash": "e612fae4cbef3c536c8e43cb7732d4cb",
"packages": [ "packages": [
{ {
"name": "anik/amqp", "name": "anik/amqp",
@ -6832,6 +6832,69 @@
} }
], ],
"packages-dev": [ "packages-dev": [
{
"name": "andreaselia/laravel-api-to-postman",
"version": "v1.7.2",
"source": {
"type": "git",
"url": "https://github.com/AndreasElia/laravel-api-to-postman.git",
"reference": "c40892559137ac356268afb03d3e279ff3efb188"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/AndreasElia/laravel-api-to-postman/zipball/c40892559137ac356268afb03d3e279ff3efb188",
"reference": "c40892559137ac356268afb03d3e279ff3efb188",
"shasum": ""
},
"require": {
"ext-json": "*",
"illuminate/config": "^6.0|^7.0|^8.0",
"illuminate/console": "^6.0|^7.0|^8.0",
"illuminate/contracts": "^6.0|^7.0|^8.0",
"illuminate/routing": "^6.0|^7.0|^8.0",
"illuminate/support": "^6.0|^7.0|^8.0",
"php": "^7.4|^8.0"
},
"require-dev": {
"orchestra/testbench": "^6.12"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"AndreasElia\\PostmanGenerator\\PostmanGeneratorServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"AndreasElia\\PostmanGenerator\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andreas Elia",
"email": "andreaselia@live.co.uk"
}
],
"description": "Generate a Postman collection automatically from your Laravel API",
"keywords": [
"Postman",
"api",
"collection",
"generate",
"laravel"
],
"support": {
"issues": "https://github.com/AndreasElia/laravel-api-to-postman/issues",
"source": "https://github.com/AndreasElia/laravel-api-to-postman/tree/v1.7.2"
},
"time": "2021-02-28T23:49:29+00:00"
},
{ {
"name": "doctrine/instantiator", "name": "doctrine/instantiator",
"version": "1.4.0", "version": "1.4.0",

122
config/api-postman.php

@ -0,0 +1,122 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Base URL
|--------------------------------------------------------------------------
|
| The base URL for all of your endpoints.
|
*/
'base_url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Collection Filename
|--------------------------------------------------------------------------
|
| The name for the collection file to be saved.
|
*/
'filename' => '{timestamp}_{app}_collection.json',
/*
|--------------------------------------------------------------------------
| Structured
|--------------------------------------------------------------------------
|
| If you want folders to be generated based on namespace.
|
*/
'structured' => true,
/*
|--------------------------------------------------------------------------
| Auth Middleware
|--------------------------------------------------------------------------
|
| The middleware which wraps your authenticated API routes.
|
| E.g. auth:api, auth:sanctum
|
*/
'auth_middleware' => 'auth:api',
/*
|--------------------------------------------------------------------------
| Headers
|--------------------------------------------------------------------------
|
| The headers applied to all routes within the collection.
|
*/
'headers' => [
[
'key' => 'Accept',
'value' => 'application/json',
],
[
'key' => 'Content-Type',
'value' => 'application/json',
],
[
'key' => 'Authorization',
'value' => 'Bearer SBzUKamo6CrzQD0hzys2zDxeXiHmPnQcCmlmtCgHAo0JRglIApqJuFF0zxIY',
],
],
/*
|--------------------------------------------------------------------------
| Enable Form Data
|--------------------------------------------------------------------------
|
| Determines whether or not form data should be handled.
|
*/
'enable_formdata' => false,
/*
|--------------------------------------------------------------------------
| Form Data
|--------------------------------------------------------------------------
|
| The key/values to requests for form data dummy information.
|
*/
'formdata' => [
// 'email' => 'john@example.com',
// 'password' => 'changeme',
],
/*
|--------------------------------------------------------------------------
| Include Middleware
|--------------------------------------------------------------------------
|
| The routes of the included middleware are included in the export.
|
*/
'include_middleware' => ['api'],
/*
|--------------------------------------------------------------------------
| Disk Driver
|--------------------------------------------------------------------------
|
| Specify the configured disk for storing the postman collection file.
|
*/
'disk' => 'local',
];

3
routes/api.php

@ -12,7 +12,6 @@ $router->group(['prefix' => 'actions'], function () use ($router) {
$router->get('/callback', 'CreditController@callback'); $router->get('/callback', 'CreditController@callback');
$router->get('/{transaction}/redirection', 'CreditController@redirection'); $router->get('/{transaction}/redirection', 'CreditController@redirection');
$router->post('/log', 'ActivityController@store');
$router->group(['prefix' => 'auth'], function () use ($router) { $router->group(['prefix' => 'auth'], function () use ($router) {
$router->get('/', 'AuthController@auth'); $router->get('/', 'AuthController@auth');
@ -186,7 +185,7 @@ $router->group(['prefix' => 'businesses'], function () use ($router) {
}); });
}); });
$router->group(['prefix' => 'users'], function () use ($router) {
$router->group(['prefix' => 'users','middleware' => 'bindBusiness'], function () use ($router) {
$router->get('/', 'UserController@index'); $router->get('/', 'UserController@index');
$router->get('/search', 'UserController@search'); $router->get('/search', 'UserController@search');
$router->group(['prefix' => '{user}'], function () use ($router) { $router->group(['prefix' => '{user}'], function () use ($router) {

Loading…
Cancel
Save