diff --git a/.env.example b/.env.example index 6779d98..0a13e7c 100644 --- a/.env.example +++ b/.env.example @@ -15,8 +15,7 @@ DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret -AUTH0_DOMAIN=https://your-domain.auth0.com/ -AUTH0_AUD=https://authorsapi.com +AUTH_URI=https://auth.beitostolenlive.no/ CACHE_DRIVER=file QUEUE_CONNECTION=sync diff --git a/app/Http/Controllers/AddressController.php b/app/Http/Controllers/AddressController.php new file mode 100644 index 0000000..3983678 --- /dev/null +++ b/app/Http/Controllers/AddressController.php @@ -0,0 +1,70 @@ +validate($request, [ + 'countryCodeSetId' => 'required', + 'countryCodeId' => 'required|string', + 'postalCodeSetId' => 'required', + 'postalCodeId' => 'required|string', + 'address1' => 'required|string', + 'muncipalityCodeSetId' => 'required|string', + 'muncipalityCodeId' => 'required|string', + ]); + + $address = new Address; + + $address->countryCodeSetId= $request->countryCodeSetId; + $address->countryCodeId = $request->countryCodeId; + $address->postalCodeSetId = $request->postalCodeSetId; + $address->postalCodeId = $request->postalCodeId; + $address->address1 = $request->address1; + $address->address2 = $request->address2; + $address->muncipalityCodeSetId = $request->muncipalityCodeSetId; + $address->muncipalityCodeId = $request->muncipalityCodeId; + + $address->save(); + + return response()->json($address); + } + + public function show($id) + { + $address = Address::find($id); + + return response()->json($address); + } + + public function update(Request $request, $id) + { + $address = Address::find($id); + + $address->countryCodeSetId = $request->input('countryCodeSetId'); + $address->countryCodeId = $request->input('countryCodeId'); + $address->postalCodeSetId = $request->input('postalCodeSetId'); + $address->postalCodeId = $request->input('postalCodeId'); + $address->address1 = $request->input('address1'); + $address->address2 = $request->input('address2'); + $address->muncipalityCodeSetId = $request->input('muncipalityCodeSetId'); + $address->muncipalityCodeId = $request->input('muncipalityCodeId'); + $address->save(); + return response()->json($address); + } + + public function destroy($id) + { + $address = Address::find($id); + $address->delete(); + + return response()->json('address removed successfully'); + } +} +?> \ No newline at end of file diff --git a/app/Http/Controllers/CompanyController.php b/app/Http/Controllers/CompanyController.php new file mode 100644 index 0000000..23922ce --- /dev/null +++ b/app/Http/Controllers/CompanyController.php @@ -0,0 +1,65 @@ +json($companies); + } + + public function create(Request $request) + { + $company = new Company; + $company->orgno = $request->orgno; + $company->companyCategoryCodeSetId= $request->companyCategoryCodeSetId; + $company->companyCategoryCodeId = $request->companyCategoryCodeId; + $company->name = $request->name; + $company->orgformCodeSetId = $request->orgformCodeSetId; + $company->orgformCodeId = $request->orgformCodeId; + $company->postalAddress_id = $request->postalAddress_id; + $company->businessAddress_id = $request->businessAddress_id; + $company->save(); + return response()->json($company); + } + + public function show($orgno) + { + $company = Company::find($orgno); + return response()->json($company); + } + + public function update(Request $request, $orgno) + { + $company = Company::find($orgno); + $company->companyCategoryCodeSetId = $request->input('companyCategoryCodeSetId'); + $company->companyCategoryCodeId = $request->input('companyCategoryCodeId'); + $company->name = $request->input('name'); + $company->orgformCodeSetId = $request->input('orgformCodeSetId'); + $company->orgformCodeId = $request->input('orgformCodeId'); + $company->postalAddress_id = $request->input('postalAddress_id'); + $company->businessAddress_id = $request->input('businessAddress_id'); + $company->save(); + return response()->json($company); + } + + public function destroy($orgno) + { + $company = Company::find($orgno); + $company->delete(); + + return response()->json('company removed successfully'); + } +} +?> \ No newline at end of file diff --git a/app/Http/Controllers/CompanyCrewController.php b/app/Http/Controllers/CompanyCrewController.php new file mode 100644 index 0000000..ed88b67 --- /dev/null +++ b/app/Http/Controllers/CompanyCrewController.php @@ -0,0 +1,62 @@ +get(); + return response()->json($crew); + } + + public function create($orgno, Request $request) + { + $crew = new CompanyCrew; + $crew->orgno = $orgno; + $crew->name= $request->name; + $crew->email = $request->email; + $crew->phone = $request->phone; + $crew->comment = $request->comment; + $crew->save(); + return response()->json($crew); + } + + public function show($id) + { + $crew = CompanyCrew::find($id); + return response()->json($crew); + } + + public function update(Request $request, $id) + { + $crew = CompanyCrew::find($id); + if($request->input('name')) { + $crew->name = $request->input('name'); + } + if($request->input('email')) { + $crew->email = $request->input('email'); + } + if($request->input('phone')) { + $crew->phone = $request->input('phone'); + } + if($request->input('comment')) { + $crew->comment = $request->input('comment'); + } + $crew->save(); + return response()->json($crew); + } + + public function destroy($id) + { + $crew = CompanyCrew::find($id); + $crew->delete(); + + return response()->json('crew removed successfully'); + } +} +?> \ No newline at end of file diff --git a/app/Http/Controllers/CompanyNoteController.php b/app/Http/Controllers/CompanyNoteController.php new file mode 100644 index 0000000..e8f6fa4 --- /dev/null +++ b/app/Http/Controllers/CompanyNoteController.php @@ -0,0 +1,65 @@ +get(); + return response()->json($notes); + } + + public function notesByCrew($crew_id) + { + $notes = CompanyNote::where('companycrew_id', $crew_id)->get(); + return response()->json($notes); + } + + public function create($orgno, $crew_id, Request $request) + { + $note = new CompanyNote; + $note->companycrew_id = $crew_id; + $note->company_orgno= $orgno; + $note->noteCodeSetId = $request->noteCodeSetId; + $note->noteCodeId = $request->noteCodeId; + $note->note = $request->note; + $note->save(); + return response()->json($note); + } + + public function show($id) + { + $note = CompanyNote::find($id); + return response()->json($note); + } + + public function update(Request $request, $id) + { + $note = CompanyNote::find($id); + if($request->input('noteCodeSetId')) { + $note->noteCodeSetId = $request->input('noteCodeSetId'); + } + if($request->input('noteCodeId')) { + $note->noteCodeId = $request->input('noteCodeId'); + } + if($request->input('note')) { + $note->note = $request->input('note'); + } + $note->save(); + return response()->json($note); + } + + public function destroy($id) + { + $note = CompanyNote::find($id); + $note->delete(); + + return response()->json('note removed successfully'); + } +} +?> \ No newline at end of file diff --git a/app/Http/Controllers/PersonController.php b/app/Http/Controllers/PersonController.php deleted file mode 100644 index c1cedb0..0000000 --- a/app/Http/Controllers/PersonController.php +++ /dev/null @@ -1,32 +0,0 @@ -get(); - return response()->json($persons); - } - - public function create($supplier_id, Request $request) - { - $person = new Person; - - $person->name= $request->name; - $person->phone = $request->phone; - $person->email = $request->email; - $person->comment = $request->comment; - $person->supplier_id = $supplier_id; - - $person->save(); - - return response()->json($person); - } -} -?> \ No newline at end of file diff --git a/app/Http/Controllers/SupplierController.php b/app/Http/Controllers/SupplierController.php deleted file mode 100644 index 2fece4b..0000000 --- a/app/Http/Controllers/SupplierController.php +++ /dev/null @@ -1,67 +0,0 @@ -json($suppliers); - } - - public function create(Request $request) - { - $supplier = new Supplier; - - $supplier->name= $request->name; - $supplier->address = $request->address; - $supplier->postalcode = $request->postalcode; - $supplier->postal = $request->postal; - $supplier->comment = $request->comment; - - $supplier->save(); - - return response()->json($supplier); - } - - public function show($id) - { - $supplier = Supplier::find($id); - - return response()->json($supplier); - } - - public function update(Request $request, $id) - { - $supplier = Supplier::find($id); - - $supplier->name = $request->input('name'); - $supplier->address = $request->input('address'); - $supplier->postalcode = $request->input('postalcode'); - $supplier->postal = $request->input('postal'); - $supplier->postal = $request->input('postal'); - $supplier->save(); - return response()->json($supplier); - } - - public function destroy($id) - { - $supplier = Supplier::find($id); - $supplier->delete(); - - return response()->json('supplier removed successfully'); - } -} -?> \ No newline at end of file diff --git a/app/Http/Middleware/Auth0Middleware.php b/app/Http/Middleware/Auth0Middleware.php deleted file mode 100644 index f19a23e..0000000 --- a/app/Http/Middleware/Auth0Middleware.php +++ /dev/null @@ -1,48 +0,0 @@ -bearerToken(); - if(!$token) { - return response()->json('No token provided', 401); - } - - $this->validateToken($token); - - return $next($request); - } - - public function validateToken($token) - { - try { - $jwksUri = env('AUTH0_DOMAIN') . '.well-known/jwks.json'; - $jwksFetcher = new JWKFetcher(null, [ 'base_uri' => $jwksUri ]); - $signatureVerifier = new AsymmetricVerifier($jwksFetcher); - $tokenVerifier = new TokenVerifier(env('AUTH0_DOMAIN'), env('AUTH0_AUD'), $signatureVerifier); - - $decoded = $tokenVerifier->verify($token); - } - catch(InvalidTokenException $e) { - throw $e; - }; - } -} - -?> \ No newline at end of file diff --git a/app/Http/Middleware/AuthMiddleware.php b/app/Http/Middleware/AuthMiddleware.php new file mode 100644 index 0000000..d3f1356 --- /dev/null +++ b/app/Http/Middleware/AuthMiddleware.php @@ -0,0 +1,52 @@ +bearerToken(); + if(!$token) { + return response()->json('No token provided', 401); + } + + if($this->validateToken($token)) { + return $next($request); + } else { + return response()->json('Token is not valid', 401); + } + } + + public function validateToken($token) + { + try { + $client = new \GuzzleHttp\Client(); + $response = $client->request('GET', env('AUTH_URI').'api/v1/validate', [ + 'headers' => [ + 'Authorization' => 'Bearer ' . $token + ], + 'http_errors' => false + ]); + if($response->getStatusCode()==200) { + return true; + } else { + return false; + } + } + catch(\Exception $e) { + throw $e; + }; + } +} + +?> \ No newline at end of file diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php deleted file mode 100644 index 361a11e..0000000 --- a/app/Http/Middleware/Authenticate.php +++ /dev/null @@ -1,44 +0,0 @@ -auth = $auth; - } - - /** - * Handle an incoming request. - * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @param string|null $guard - * @return mixed - */ - public function handle($request, Closure $next, $guard = null) - { - if ($this->auth->guard($guard)->guest()) { - return response('Unauthorized.', 401); - } - - return $next($request); - } -} diff --git a/app/Http/Middleware/ExampleMiddleware.php b/app/Http/Middleware/ExampleMiddleware.php deleted file mode 100644 index 166581c..0000000 --- a/app/Http/Middleware/ExampleMiddleware.php +++ /dev/null @@ -1,20 +0,0 @@ -hasMany(Company::class, 'postalAddress_id', 'id'); + } + + public function companiesBussiness() + { + return $this->hasMany(Company::class, 'businessAddress_id', 'id'); + } +} +?> \ No newline at end of file diff --git a/app/Models/Company.php b/app/Models/Company.php new file mode 100644 index 0000000..845f64d --- /dev/null +++ b/app/Models/Company.php @@ -0,0 +1,45 @@ +belongsTo(Address::class, 'postalAddress_id', 'id'); + } + + public function businessAddress() + { + return $this->belongsTo(Address::class, 'businessAddress_id', 'id'); + } + + public function crew() + { + return $this->hasMany(CompanyCrew::class, 'orgno', 'orgno'); + } + + public function notes() + { + return $this->hasMany(CompanyNote::class, 'company_orgno', 'orgno'); + } +} +?> \ No newline at end of file diff --git a/app/Models/CompanyCrew.php b/app/Models/CompanyCrew.php new file mode 100644 index 0000000..7912e43 --- /dev/null +++ b/app/Models/CompanyCrew.php @@ -0,0 +1,31 @@ +belongsTo(Company::class, 'orgno', 'orgno'); + } + + public function notes() + { + return $this->hasMany(CompanyNote::class, 'companycrew_id', 'id'); + } +} +?> \ No newline at end of file diff --git a/app/Models/CompanyNote.php b/app/Models/CompanyNote.php new file mode 100644 index 0000000..dc8af96 --- /dev/null +++ b/app/Models/CompanyNote.php @@ -0,0 +1,32 @@ +belongsTo(Company::class, 'company_orgno', 'orgno'); + } + + public function companyCrew() + { + return $this->belongsTo(CompanyCrew::class, 'companycrew_id', 'id'); + } +} +?> \ No newline at end of file diff --git a/app/Models/Person.php b/app/Models/Person.php deleted file mode 100644 index c95269c..0000000 --- a/app/Models/Person.php +++ /dev/null @@ -1,18 +0,0 @@ -belongsTo(Supplier::class); - } -} -?> \ No newline at end of file diff --git a/app/Models/Supplier.php b/app/Models/Supplier.php deleted file mode 100644 index 3c99ee1..0000000 --- a/app/Models/Supplier.php +++ /dev/null @@ -1,18 +0,0 @@ -hasMany(Person::class); - } -} -?> \ No newline at end of file diff --git a/bootstrap/app.php b/bootstrap/app.php index 52dd761..b86c299 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -77,7 +77,7 @@ // ]); $app->routeMiddleware([ - 'auth' => App\Http\Middleware\Auth0Middleware::class, + 'auth' => App\Http\Middleware\AuthMiddleware::class, ]); /* diff --git a/composer.json b/composer.json index d10d970..37f0023 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,7 @@ "require": { "php": "^7.3|^8.0", "auth0/auth0-php": "^7.6", + "guzzlehttp/guzzle": "^7.3", "laravel/lumen-framework": "^8.0" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 156d950..a3cb143 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": "7435e04139ae57b3b24b15b1f40bc7b9", + "content-hash": "7d987dec4277aff08295190ccd554ff9", "packages": [ { "name": "auth0/auth0-php", @@ -560,22 +560,22 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.2.0", + "version": "7.3.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "0aa74dfb41ae110835923ef10a9d803a22d50e79" + "reference": "7008573787b430c1c1f650e3722d9bba59967628" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/0aa74dfb41ae110835923ef10a9d803a22d50e79", - "reference": "0aa74dfb41ae110835923ef10a9d803a22d50e79", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/7008573787b430c1c1f650e3722d9bba59967628", + "reference": "7008573787b430c1c1f650e3722d9bba59967628", "shasum": "" }, "require": { "ext-json": "*", "guzzlehttp/promises": "^1.4", - "guzzlehttp/psr7": "^1.7", + "guzzlehttp/psr7": "^1.7 || ^2.0", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0" }, @@ -583,6 +583,7 @@ "psr/http-client-implementation": "1.0" }, "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", "ext-curl": "*", "php-http/client-integration-tests": "^3.0", "phpunit/phpunit": "^8.5.5 || ^9.3.5", @@ -596,7 +597,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "7.1-dev" + "dev-master": "7.3-dev" } }, "autoload": { @@ -638,7 +639,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.2.0" + "source": "https://github.com/guzzle/guzzle/tree/7.3.0" }, "funding": [ { @@ -658,7 +659,7 @@ "type": "github" } ], - "time": "2020-10-10T11:47:56+00:00" + "time": "2021-03-23T11:33:13+00:00" }, { "name": "guzzlehttp/promises", diff --git a/database/migrations/2021_04_05_091133_supplier.php b/database/migrations/2021_04_05_091133_supplier.php deleted file mode 100644 index 7e11b42..0000000 --- a/database/migrations/2021_04_05_091133_supplier.php +++ /dev/null @@ -1,37 +0,0 @@ -bigIncrements('id'); - $table->string('name'); - $table->string('address'); - $table->string('postalcode'); - $table->string('postal'); - $table->text('comment'); - $table->softDeletes($column = 'deleted_at', $precision = 0); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('supplier'); - } -} diff --git a/database/migrations/2021_04_05_094128_contract.php b/database/migrations/2021_04_05_094128_contract.php deleted file mode 100644 index e9068b2..0000000 --- a/database/migrations/2021_04_05_094128_contract.php +++ /dev/null @@ -1,39 +0,0 @@ -bigIncrements('id'); - $table->string('name'); - $table->longText('description'); - $table->date('valid_from'); - $table->date('valid_to'); - $table->unsignedBigInteger('supplier_id'); - $table->foreign('supplier_id')->references('id')->on('supplier'); - $table->softDeletes($column = 'deleted_at', $precision = 0); - $table->string('file_path'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('contract'); - } -} diff --git a/database/migrations/2021_04_05_111221_role.php b/database/migrations/2021_04_05_111221_role.php deleted file mode 100644 index cac8fb1..0000000 --- a/database/migrations/2021_04_05_111221_role.php +++ /dev/null @@ -1,32 +0,0 @@ -bigIncrements('id'); - $table->string('name'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('role'); - } -} diff --git a/database/migrations/2021_04_05_111435_user.php b/database/migrations/2021_04_05_111435_user.php deleted file mode 100644 index f61234a..0000000 --- a/database/migrations/2021_04_05_111435_user.php +++ /dev/null @@ -1,39 +0,0 @@ -string('subject'); - $table->string('name'); - $table->string('email'); - $table->string('phone'); - $table->softDeletes($column = 'deleted_at', $precision = 0); - $table->unsignedBigInteger('role_id'); - $table->foreign('role_id')->references('id')->on('role'); - $table->timestamps(); - $table->primary('subject'); - $table->unique('email'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('user'); - } -} diff --git a/database/migrations/2021_04_09_214612_create_table_address.php b/database/migrations/2021_04_09_214612_create_table_address.php new file mode 100644 index 0000000..0d993cb --- /dev/null +++ b/database/migrations/2021_04_09_214612_create_table_address.php @@ -0,0 +1,39 @@ +bigIncrements('id'); + $table->bigInteger('countryCodeSetId')->notNullable(); + $table->string('countryCodeId')->notNullable(); + $table->bigInteger('postalCodeSetId')->notNullable(); + $table->string('postalCodeId')->notNullable(); + $table->string('address1')->notNullable(); + $table->string('address2'); + $table->bigInteger('muncipalityCodeSetId')->notNullable(); + $table->string('muncipalityCodeId')->notNullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('addresses'); + } +} diff --git a/database/migrations/2021_04_09_214841_create_table_company.php b/database/migrations/2021_04_09_214841_create_table_company.php new file mode 100644 index 0000000..d43946b --- /dev/null +++ b/database/migrations/2021_04_09_214841_create_table_company.php @@ -0,0 +1,41 @@ +bigInteger('orgno')->primary(); + $table->bigInteger('companyCategoryCodeSetId')->notNullable(); + $table->string('companyCategoryCodeId')->notNullable(); + $table->string('name')->notNullable(); + $table->bigInteger('orgformCodeSetId')->notNullable(); + $table->string('orgformCodeId')->notNullable(); + $table->unsignedBigInteger('postalAddress_id')->notNullable(); + $table->foreign('postalAddress_id')->references('id')->on('addresses'); + $table->unsignedBigInteger('businessAddress_id')->notNullable(); + $table->foreign('businessAddress_id')->references('id')->on('addresses'); + $table->softDeletesTz($column = 'deleted_at', $precision = 0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('companies'); + } +} diff --git a/database/migrations/2021_04_05_091509_person.php b/database/migrations/2021_04_09_220444_create_table_company_crew.php similarity index 54% rename from database/migrations/2021_04_05_091509_person.php rename to database/migrations/2021_04_09_220444_create_table_company_crew.php index 5ce40a3..e1bb402 100644 --- a/database/migrations/2021_04_05_091509_person.php +++ b/database/migrations/2021_04_09_220444_create_table_company_crew.php @@ -4,7 +4,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class Person extends Migration +class CreateTableCompanyCrew extends Migration { /** * Run the migrations. @@ -13,16 +13,16 @@ class Person extends Migration */ public function up() { - Schema::create('person', function (Blueprint $table) { + Schema::create('companycrew', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name'); - $table->string('phone'); $table->string('email'); - $table->longText('comment'); - $table->unsignedBigInteger('supplier_id'); - $table->foreign('supplier_id')->references('id')->on('supplier'); - $table->softDeletes($column = 'deleted_at', $precision = 0); - $table->timestamps(); + $table->string('phone'); + $table->string('comment'); + $table->bigInteger('orgno')->notNullable(); + $table->foreign('orgno')->references('orgno')->on('companies'); + $table->softDeletesTz($column = 'deleted_at', $precision = 0); + $table->timestamps(); }); } @@ -33,6 +33,6 @@ public function up() */ public function down() { - Schema::drop('person'); + Schema::dropIfExists('companycrew'); } } diff --git a/database/migrations/2021_04_10_082828_create_table_company_note.php b/database/migrations/2021_04_10_082828_create_table_company_note.php new file mode 100644 index 0000000..65dc941 --- /dev/null +++ b/database/migrations/2021_04_10_082828_create_table_company_note.php @@ -0,0 +1,39 @@ +bigIncrements('id'); + $table->bigInteger('noteCodeSetId')->notNullable(); + $table->string('noteCodeId')->notNullable(); + $table->mediumText('note')->notNullable(); + $table->bigInteger('company_orgno')->notNullable(); + $table->foreign('company_orgno')->references('orgno')->on('companies'); + $table->unsignedBigInteger('companycrew_id')->notNullable(); + $table->foreign('companycrew_id')->references('id')->on('companycrew'); + $table->softDeletesTz($column = 'deleted_at', $precision = 0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('companynote'); + } +} diff --git a/database/seeders/RoleSeeder.php b/database/seeders/RoleSeeder.php deleted file mode 100644 index 3777ff4..0000000 --- a/database/seeders/RoleSeeder.php +++ /dev/null @@ -1,20 +0,0 @@ -insert([ - 'name' => 'Administrator', - ]); - } -} diff --git a/routes/web.php b/routes/web.php index 240e36e..c0f8ac0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -17,20 +17,35 @@ return $router->app->version(); }); -$router->group(['prefix'=>'api/v1'], function() use($router){ +$router->group(['prefix'=>'api/v1', 'middleware' => 'auth'], function() use($router){ // Festival $router->get('/festival', 'FestivalController@index'); $router->post('/festival', 'FestivalController@create'); $router->get('/festival/{id}', 'FestivalController@show'); $router->put('/festival/{id}', 'FestivalController@update'); $router->delete('/festival/{id}', 'FestivalController@destroy'); - // Supplier - $router->get('/supplier', 'SupplierController@index'); - $router->post('/supplier', 'SupplierController@create'); - $router->get('/supplier/{id}', 'SupplierController@show'); - $router->put('/supplier/{id}', 'SupplierController@update'); - $router->delete('/supplier/{id}', 'SupplierController@destroy'); - // Person - $router->get('/supplier/{supplier_id}/person', 'PersonController@index'); - $router->post('/supplier/{supplier_id}/person', 'PersonController@create'); + // Address + $router->post('/address', 'AddressController@create'); + $router->get('/address/{id}', 'AddressController@show'); + $router->put('/address/{id}', 'AddressController@update'); + $router->delete('/address/{id}', 'AddressController@destroy'); + // Company + $router->get('/company', 'CompanyController@index'); + $router->get('/company/{orgno}', 'CompanyController@show'); + $router->post('/company', 'CompanyController@create'); + $router->put('/company/{orgno}', 'CompanyController@update'); + $router->delete('/company/{orgno}', 'CompanyController@destroy'); + // Company Crew + $router->get('/company/{orgno}/crew', 'CompanyCrewController@index'); + $router->post('/company/{orgno}/crew', 'CompanyCrewController@create'); + $router->get('/crew/{id}', 'CompanyCrewController@show'); + $router->put('/crew/{id}', 'CompanyCrewController@update'); + $router->delete('/crew/{id}', 'CompanyCrewController@destroy'); + // Company Note + $router->get('/company/{orgno}/notes', 'CompanyNoteController@notesByCompany'); + $router->get('/crew/{crew_id}/notes', 'CompanyNoteController@notesByCrew'); + $router->get('/note/{id}', 'CompanyNoteController@show'); + $router->post('/company/{orgno}/crew/{crew_id}/note', 'CompanyNoteController@create'); + $router->put('/note/{id}', 'CompanyNoteController@update'); + $router->delete('/note/{id}', 'CompanyNoteController@destroy'); }); \ No newline at end of file