diff --git a/app/Console/Commands/CostCommand.php b/app/Console/Commands/CostCommand.php index 1ad1095..99a9db5 100644 --- a/app/Console/Commands/CostCommand.php +++ b/app/Console/Commands/CostCommand.php @@ -3,7 +3,7 @@ namespace App\Console\Commands; use DB; -use App\Business; +use App\Models\Business; use Illuminate\Console\Command; use Illuminate\Support\Facades\Cache; diff --git a/app/Enums/log.php b/app/Enums/log.php index a49f08d..3157502 100644 --- a/app/Enums/log.php +++ b/app/Enums/log.php @@ -1 +1,25 @@ - [ User::class => 10, Business::class => 20, Project::class => 30, Task::class => 40, Spenthour::class => 50, ], 'actions' => [ 'created' => 10, 'updated' => 20, 'deleted' => 30, 'restored' => 40, ], ]; \ No newline at end of file + [ + User::class => 10, + Business::class => 20, + Project::class => 30, + Task::class => 40, + Spenthour::class => 50, + ], + + 'actions' => [ + 'created' => 10, + 'updated' => 20, + 'deleted' => 30, + 'restored' => 40, + ], +]; diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 6d41a8d..dae25ac 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -2,9 +2,9 @@ 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\Http\Request; use Illuminate\Validation\Rule; diff --git a/app/Http/Controllers/BusinessController.php b/app/Http/Controllers/BusinessController.php index 179837c..aafdd41 100644 --- a/app/Http/Controllers/BusinessController.php +++ b/app/Http/Controllers/BusinessController.php @@ -2,11 +2,11 @@ namespace App\Http\Controllers; -use App\User; -use App\Business; +use App\Models\User; +use App\Models\Business; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Auth; class BusinessController extends Controller { diff --git a/app/Http/Controllers/CommentController.php b/app/Http/Controllers/CommentController.php index 116bf70..898d232 100644 --- a/app/Http/Controllers/CommentController.php +++ b/app/Http/Controllers/CommentController.php @@ -2,8 +2,8 @@ namespace App\Http\Controllers; -use App\Models\Comment; use App\Models\Task; +use App\Models\Comment; use Illuminate\Http\Request; use Illuminate\Http\Response; diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index a0a2a8a..03e02a2 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -2,10 +2,10 @@ namespace App\Http\Controllers; -use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Bus\DispatchesJobs; -use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Routing\Controller as BaseController; +use Illuminate\Foundation\Validation\ValidatesRequests; +use Illuminate\Foundation\Auth\Access\AuthorizesRequests; class Controller extends BaseController { diff --git a/app/Http/Controllers/FileController.php b/app/Http/Controllers/FileController.php index b57455c..88eac5b 100644 --- a/app/Http/Controllers/FileController.php +++ b/app/Http/Controllers/FileController.php @@ -4,8 +4,8 @@ namespace App\Http\Controllers; use App\File; use App\Project; -use App\Business; -use App\Rules\maxBound; +use App\Models\Business; +use App\Rules\MaxBound; use Illuminate\Support\Str; use Illuminate\Http\Request; use Illuminate\Http\UploadedFile; @@ -32,8 +32,8 @@ class FileController extends Controller { $bound = 10; $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)] , ]); } diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 1bf3ea2..c277488 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -3,7 +3,7 @@ namespace App\Http\Controllers; use App\Cost; -use App\Business; +use App\Models\Business; use Illuminate\Http\Request; use Spatie\QueryBuilder\QueryBuilder; use Spatie\QueryBuilder\AllowedFilter; diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 707625d..5822f40 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -3,7 +3,7 @@ namespace App\Http\Controllers; use App\Project; -use App\Business; +use App\Models\Business; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; diff --git a/app/Http/Controllers/SprintController.php b/app/Http/Controllers/SprintController.php index 7f26dcd..46bcbf1 100644 --- a/app/Http/Controllers/SprintController.php +++ b/app/Http/Controllers/SprintController.php @@ -4,8 +4,8 @@ namespace App\Http\Controllers; -use App\Business; use App\Sprint; +use App\Models\Business; use Illuminate\Http\Request; class SprintController extends Controller diff --git a/app/Http/Controllers/StatisticController.php b/app/Http/Controllers/StatisticController.php index 572aae5..27ed05d 100644 --- a/app/Http/Controllers/StatisticController.php +++ b/app/Http/Controllers/StatisticController.php @@ -2,8 +2,8 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; use Illuminate\Support\Arr; +use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; class StatisticController extends Controller diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 7740503..6270132 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -4,8 +4,8 @@ namespace App\Http\Controllers; -use App\Business; use App\Status; +use App\Models\Business; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Validation\Rule; diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index aadc34b..a5d9436 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -2,8 +2,8 @@ namespace App\Http\Controllers; -use App\Business; use App\System; +use App\Models\Business; use Illuminate\Http\Request; class SystemController extends Controller diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 7d661ba..83dd849 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -4,8 +4,8 @@ namespace App\Http\Controllers; -use App\Business; use App\Tag; +use App\Models\Business; use App\Workflow; use Illuminate\Http\Request; diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php index f447782..9093701 100644 --- a/app/Http/Controllers/TaskController.php +++ b/app/Http/Controllers/TaskController.php @@ -2,18 +2,18 @@ namespace App\Http\Controllers; -use App\Http\Resources\TaskCollection; -use App\Http\Resources\TaskResource; -use App\Rules\maxBound; use App\TagTask; +use Carbon\Carbon; use App\Models\Task; use App\Models\Work; -use Carbon\Carbon; +use App\Rules\maxBound; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Facades\DB; -use Spatie\QueryBuilder\AllowedFilter; +use App\Http\Resources\TaskResource; use Spatie\QueryBuilder\QueryBuilder; +use App\Http\Resources\TaskCollection; +use Spatie\QueryBuilder\AllowedFilter; class TaskController extends Controller { diff --git a/app/Http/Controllers/TaskFileController.php b/app/Http/Controllers/TaskFileController.php index ab35061..b29c048 100644 --- a/app/Http/Controllers/TaskFileController.php +++ b/app/Http/Controllers/TaskFileController.php @@ -6,13 +6,13 @@ use Auth; use App\File; use App\Task; use App\Project; -use App\Business; -use Illuminate\Http\Exceptions\HttpResponseException; +use App\Models\Business; use Illuminate\Http\Request; +use mysql_xdevapi\Exception; use App\Http\Controllers\Controller; use App\Http\Resources\FileResource; -use mysql_xdevapi\Exception; use Symfony\Component\HttpFoundation\Response; +use Illuminate\Http\Exceptions\HttpResponseException; class TaskFileController extends Controller { diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index fba4e8d..ceded14 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -4,10 +4,10 @@ namespace App\Http\Controllers; -use App\User; +use App\Models\User; use Illuminate\Http\Request; -use Spatie\QueryBuilder\AllowedFilter; use Spatie\QueryBuilder\QueryBuilder; +use Spatie\QueryBuilder\AllowedFilter; class UserController extends Controller { diff --git a/app/Http/Controllers/WorkController.php b/app/Http/Controllers/WorkController.php index a2fa6ba..89b00f9 100644 --- a/app/Http/Controllers/WorkController.php +++ b/app/Http/Controllers/WorkController.php @@ -2,13 +2,13 @@ namespace App\Http\Controllers; +use Carbon\Carbon; use App\Models\Task; use App\Models\Work; -use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Http\Response; -use Spatie\QueryBuilder\AllowedFilter; use Spatie\QueryBuilder\QueryBuilder; +use Spatie\QueryBuilder\AllowedFilter; class WorkController extends Controller { diff --git a/app/Http/Controllers/WorkflowController.php b/app/Http/Controllers/WorkflowController.php index 80fdc3d..faaa219 100644 --- a/app/Http/Controllers/WorkflowController.php +++ b/app/Http/Controllers/WorkflowController.php @@ -4,8 +4,8 @@ namespace App\Http\Controllers; -use App\Business; use App\Status; +use App\Models\Business; use App\Workflow; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 30020a5..4bd9d18 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -2,6 +2,7 @@ namespace App\Http; +use App\Utilities\Middlewares\BindBusinessInfo; use Illuminate\Foundation\Http\Kernel as HttpKernel; class Kernel extends HttpKernel @@ -62,5 +63,6 @@ class Kernel extends HttpKernel 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + 'bindBusiness' => BindBusinessInfo::class, ]; } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index a5cc37f..7936e8d 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -2,7 +2,7 @@ namespace App\Providers; -use App\Fingerprint; +use App\Models\Fingerprint; use App\Utilities\RequestMixin; use App\Utilities\BusinessInfoRequestMixin; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 3bd3c81..927be5d 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -26,7 +26,7 @@ class RouteServiceProvider extends ServiceProvider * * @var string|null */ - // protected $namespace = 'App\\Http\\Controllers'; + protected $namespace = 'App\\Http\\Controllers'; /** * Define your route model bindings, pattern filters, etc. diff --git a/app/Utilities/BusinessInfoRequestMixin.php b/app/Utilities/BusinessInfoRequestMixin.php index 5966ae3..2fd1da3 100644 --- a/app/Utilities/BusinessInfoRequestMixin.php +++ b/app/Utilities/BusinessInfoRequestMixin.php @@ -2,7 +2,7 @@ namespace App\Utilities; -use App\User; +use App\Models\User; use Illuminate\Support\Arr; use Jenssegers\Agent\Agent; diff --git a/app/Utilities/Middlewares/BindBusinessInfo.php b/app/Utilities/Middlewares/BindBusinessInfo.php index f49bb95..788a54d 100644 --- a/app/Utilities/Middlewares/BindBusinessInfo.php +++ b/app/Utilities/Middlewares/BindBusinessInfo.php @@ -3,6 +3,7 @@ namespace App\Utilities\Middlewares; use Closure; +use App\Models\Business; class BindBusinessInfo { @@ -10,11 +11,7 @@ class BindBusinessInfo public function handle($request, Closure $next, $guard = null) { $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]); return $next($request); diff --git a/app/Utilities/Providers/AuthServiceProvider.php b/app/Utilities/Providers/AuthServiceProvider.php index a206351..4b25477 100644 --- a/app/Utilities/Providers/AuthServiceProvider.php +++ b/app/Utilities/Providers/AuthServiceProvider.php @@ -2,7 +2,7 @@ namespace App\Utilities\Providers; -use App\User; +use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Auth; diff --git a/composer.json b/composer.json index 566fa2d..ca1dcad 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,8 @@ "laravel/sail": "^1.0.1", "mockery/mockery": "^1.4.2", "nunomaduro/collision": "^5.0", - "phpunit/phpunit": "^9.3.3" + "phpunit/phpunit": "^9.3.3", + "andreaselia/laravel-api-to-postman":"^1.0" }, "config": { "optimize-autoloader": true, diff --git a/composer.lock b/composer.lock index d8a10cf..91600a6 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": "f9d97bc77997badf02ebb4ff03402453", + "content-hash": "e612fae4cbef3c536c8e43cb7732d4cb", "packages": [ { "name": "anik/amqp", @@ -6832,6 +6832,69 @@ } ], "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", "version": "1.4.0", diff --git a/config/api-postman.php b/config/api-postman.php new file mode 100644 index 0000000..7d9727b --- /dev/null +++ b/config/api-postman.php @@ -0,0 +1,122 @@ + 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', + +]; diff --git a/routes/api.php b/routes/api.php index 463c255..aa1192e 100644 --- a/routes/api.php +++ b/routes/api.php @@ -12,7 +12,6 @@ $router->group(['prefix' => 'actions'], function () use ($router) { $router->get('/callback', 'CreditController@callback'); $router->get('/{transaction}/redirection', 'CreditController@redirection'); -$router->post('/log', 'ActivityController@store'); $router->group(['prefix' => 'auth'], function () use ($router) { $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('/search', 'UserController@search'); $router->group(['prefix' => '{user}'], function () use ($router) {