├── public
├── favicon.ico
├── robots.txt
├── docs
│ ├── images
│ │ └── navbar.png
│ ├── js
│ │ └── theme-default-4.21.2.js
│ ├── css
│ │ └── theme-default.print.css
│ └── collection.json
├── .htaccess
└── index.php
├── resources
├── css
│ └── app.css
└── js
│ ├── app.js
│ └── bootstrap.js
├── database
├── .gitignore
├── seeders
│ ├── RoleSeeder.php
│ └── DatabaseSeeder.php
├── factories
│ ├── TravelFactory.php
│ ├── TourFactory.php
│ └── UserFactory.php
└── migrations
│ ├── 2023_06_01_125352_create_roles_table.php
│ ├── 2023_06_01_125740_create_role_user_table.php
│ ├── 2014_10_12_100000_create_password_reset_tokens_table.php
│ ├── 2014_10_12_000000_create_users_table.php
│ ├── 2023_06_01_130614_create_tours_table.php
│ ├── 2019_08_19_000000_create_failed_jobs_table.php
│ ├── 2023_06_01_125944_create_travels_table.php
│ └── 2019_12_14_000001_create_personal_access_tokens_table.php
├── bootstrap
├── cache
│ └── .gitignore
└── app.php
├── storage
├── logs
│ └── .gitignore
├── app
│ ├── public
│ │ └── .gitignore
│ └── .gitignore
└── framework
│ ├── testing
│ └── .gitignore
│ ├── views
│ └── .gitignore
│ ├── cache
│ ├── data
│ │ └── .gitignore
│ └── .gitignore
│ ├── sessions
│ └── .gitignore
│ └── .gitignore
├── tests
├── TestCase.php
├── CreatesApplication.php
└── Feature
│ ├── LoginTest.php
│ ├── TravelsListTest.php
│ ├── AdminTourTest.php
│ ├── AdminTravelTest.php
│ └── ToursListTest.php
├── .gitattributes
├── .scribe
├── .filehashes
├── auth.md
├── intro.md
├── endpoints
│ ├── 02.yaml
│ ├── custom.0.yaml
│ ├── 00.yaml
│ └── 01.yaml
└── endpoints.cache
│ ├── 02.yaml
│ ├── 00.yaml
│ └── 01.yaml
├── package.json
├── phpstan.neon
├── vite.config.js
├── .gitignore
├── .editorconfig
├── app
├── Models
│ ├── Role.php
│ ├── Tour.php
│ ├── Travel.php
│ └── User.php
├── Http
│ ├── Controllers
│ │ ├── Controller.php
│ │ └── Api
│ │ │ └── V1
│ │ │ ├── Admin
│ │ │ ├── TourController.php
│ │ │ └── TravelController.php
│ │ │ ├── Auth
│ │ │ └── LoginController.php
│ │ │ ├── TravelController.php
│ │ │ └── TourController.php
│ ├── Middleware
│ │ ├── EncryptCookies.php
│ │ ├── VerifyCsrfToken.php
│ │ ├── PreventRequestsDuringMaintenance.php
│ │ ├── TrimStrings.php
│ │ ├── TrustHosts.php
│ │ ├── Authenticate.php
│ │ ├── ValidateSignature.php
│ │ ├── RoleMiddleware.php
│ │ ├── TrustProxies.php
│ │ └── RedirectIfAuthenticated.php
│ ├── Resources
│ │ ├── TourResource.php
│ │ └── TravelResource.php
│ ├── Requests
│ │ ├── LoginRequest.php
│ │ ├── TravelRequest.php
│ │ ├── TourRequest.php
│ │ └── ToursListRequest.php
│ └── Kernel.php
├── Providers
│ ├── BroadcastServiceProvider.php
│ ├── AppServiceProvider.php
│ ├── AuthServiceProvider.php
│ ├── EventServiceProvider.php
│ └── RouteServiceProvider.php
├── Console
│ ├── Kernel.php
│ └── Commands
│ │ └── CreateUserCommand.php
└── Exceptions
│ └── Handler.php
├── routes
├── web.php
├── channels.php
├── console.php
└── api.php
├── config
├── cors.php
├── services.php
├── view.php
├── hashing.php
├── broadcasting.php
├── sanctum.php
├── filesystems.php
├── cache.php
├── queue.php
├── mail.php
├── auth.php
├── logging.php
├── database.php
├── app.php
└── session.php
├── phpunit.xml
├── .env.example
├── artisan
├── composer.json
└── README.md
/public/favicon.ico:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/resources/css/app.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/database/.gitignore:
--------------------------------------------------------------------------------
1 | *.sqlite*
2 |
--------------------------------------------------------------------------------
/bootstrap/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/resources/js/app.js:
--------------------------------------------------------------------------------
1 | import './bootstrap';
2 |
--------------------------------------------------------------------------------
/storage/logs/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow:
3 |
--------------------------------------------------------------------------------
/storage/app/public/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/app/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !public/
3 | !.gitignore
4 |
--------------------------------------------------------------------------------
/storage/framework/testing/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/views/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/cache/data/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/sessions/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !data/
3 | !.gitignore
4 |
--------------------------------------------------------------------------------
/public/docs/images/navbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaravelDaily/Laravel-Travel-API-Course/HEAD/public/docs/images/navbar.png
--------------------------------------------------------------------------------
/storage/framework/.gitignore:
--------------------------------------------------------------------------------
1 | compiled.php
2 | config.php
3 | down
4 | events.scanned.php
5 | maintenance.php
6 | routes.php
7 | routes.scanned.php
8 | schedule-*
9 | services.json
10 |
--------------------------------------------------------------------------------
/tests/TestCase.php:
--------------------------------------------------------------------------------
1 | 'admin']);
16 | Role::create(['name' => 'editor']);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/Http/Middleware/EncryptCookies.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | protected $except = [
15 | //
16 | ];
17 | }
18 |
--------------------------------------------------------------------------------
/database/seeders/DatabaseSeeder.php:
--------------------------------------------------------------------------------
1 | call(RoleSeeder::class);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/Http/Middleware/VerifyCsrfToken.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | protected $except = [
15 | //
16 | ];
17 | }
18 |
--------------------------------------------------------------------------------
/app/Providers/BroadcastServiceProvider.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | protected $except = [
15 | //
16 | ];
17 | }
18 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrimStrings.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | protected $except = [
15 | 'current_password',
16 | 'password',
17 | 'password_confirmation',
18 | ];
19 | }
20 |
--------------------------------------------------------------------------------
/tests/CreatesApplication.php:
--------------------------------------------------------------------------------
1 | make(Kernel::class)->bootstrap();
18 |
19 | return $app;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrustHosts.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | public function hosts(): array
15 | {
16 | return [
17 | $this->allSubdomainsOfApplicationUrl(),
18 | ];
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/Providers/AppServiceProvider.php:
--------------------------------------------------------------------------------
1 | expectsJson() ? null : route('login');
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/routes/web.php:
--------------------------------------------------------------------------------
1 |
6 | Base URL: http://travelapi.test
7 |
8 |
9 | This documentation aims to provide all the information you need to work with our API.
10 |
11 |
13 |
14 |
--------------------------------------------------------------------------------
/app/Http/Middleware/ValidateSignature.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | protected $except = [
15 | // 'fbclid',
16 | // 'utm_campaign',
17 | // 'utm_content',
18 | // 'utm_medium',
19 | // 'utm_source',
20 | // 'utm_term',
21 | ];
22 | }
23 |
--------------------------------------------------------------------------------
/routes/channels.php:
--------------------------------------------------------------------------------
1 | id === (int) $id;
18 | });
19 |
--------------------------------------------------------------------------------
/app/Providers/AuthServiceProvider.php:
--------------------------------------------------------------------------------
1 |
14 | */
15 | protected $policies = [
16 | //
17 | ];
18 |
19 | /**
20 | * Register any authentication / authorization services.
21 | */
22 | public function boot(): void
23 | {
24 | //
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/routes/console.php:
--------------------------------------------------------------------------------
1 | comment(Inspiring::quote());
19 | })->purpose('Display an inspiring quote');
20 |
--------------------------------------------------------------------------------
/public/.htaccess:
--------------------------------------------------------------------------------
1 |
2 |
3 | Options -MultiViews -Indexes
4 |
5 |
6 | RewriteEngine On
7 |
8 | # Handle Authorization Header
9 | RewriteCond %{HTTP:Authorization} .
10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
11 |
12 | # Redirect Trailing Slashes If Not A Folder...
13 | RewriteCond %{REQUEST_FILENAME} !-d
14 | RewriteCond %{REQUEST_URI} (.+)/$
15 | RewriteRule ^ %1 [L,R=301]
16 |
17 | # Send Requests To Front Controller...
18 | RewriteCond %{REQUEST_FILENAME} !-d
19 | RewriteCond %{REQUEST_FILENAME} !-f
20 | RewriteRule ^ index.php [L]
21 |
22 |
--------------------------------------------------------------------------------
/app/Console/Kernel.php:
--------------------------------------------------------------------------------
1 | command('inspire')->hourly();
16 | }
17 |
18 | /**
19 | * Register the commands for the application.
20 | */
21 | protected function commands(): void
22 | {
23 | $this->load(__DIR__.'/Commands');
24 |
25 | require base_path('routes/console.php');
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/database/factories/TravelFactory.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 | class TravelFactory extends Factory
11 | {
12 | /**
13 | * Define the model's default state.
14 | *
15 | * @return array
16 | */
17 | public function definition(): array
18 | {
19 | return [
20 | 'is_public' => fake()->boolean(),
21 | 'name' => fake()->text(20),
22 | 'description' => fake()->text(100),
23 | 'number_of_days' => rand(1, 10),
24 | ];
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/database/factories/TourFactory.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 | class TourFactory extends Factory
11 | {
12 | /**
13 | * Define the model's default state.
14 | *
15 | * @return array
16 | */
17 | public function definition(): array
18 | {
19 | return [
20 | 'name' => fake()->text(20),
21 | 'starting_date' => now(),
22 | 'ending_date' => now()->addDays(rand(1, 10)),
23 | 'price' => fake()->randomFloat(2, 10, 999),
24 | ];
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/database/migrations/2023_06_01_125352_create_roles_table.php:
--------------------------------------------------------------------------------
1 | uuid('id')->primary();
16 | $table->string('name');
17 | $table->timestamps();
18 | });
19 | }
20 |
21 | /**
22 | * Reverse the migrations.
23 | */
24 | public function down(): void
25 | {
26 | Schema::dropIfExists('roles');
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/app/Http/Resources/TourResource.php:
--------------------------------------------------------------------------------
1 |
17 | */
18 | public function toArray(Request $request): array
19 | {
20 | return [
21 | 'id' => $this->id,
22 | 'name' => $this->name,
23 | 'starting_date' => $this->starting_date,
24 | 'ending_date' => $this->ending_date,
25 | 'price' => number_format($this->price, 2),
26 | ];
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/database/migrations/2023_06_01_125740_create_role_user_table.php:
--------------------------------------------------------------------------------
1 | foreignUuid('role_id')->constrained();
16 | $table->foreignUuid('user_id')->constrained();
17 | });
18 | }
19 |
20 | /**
21 | * Reverse the migrations.
22 | */
23 | public function down(): void
24 | {
25 | Schema::dropIfExists('role_user');
26 | }
27 | };
28 |
--------------------------------------------------------------------------------
/app/Http/Middleware/RoleMiddleware.php:
--------------------------------------------------------------------------------
1 | check()) {
19 | abort(401);
20 | }
21 |
22 | if (! auth()->user()->roles()->where('name', $role)->exists()) {
23 | abort(403);
24 | }
25 |
26 | return $next($request);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/Http/Requests/LoginRequest.php:
--------------------------------------------------------------------------------
1 |
21 | */
22 | public function rules(): array
23 | {
24 | return [
25 | 'email' => ['required', 'string', 'email'],
26 | 'password' => ['required', 'string'],
27 | ];
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/Exceptions/Handler.php:
--------------------------------------------------------------------------------
1 |
14 | */
15 | protected $dontFlash = [
16 | 'current_password',
17 | 'password',
18 | 'password_confirmation',
19 | ];
20 |
21 | /**
22 | * Register the exception handling callbacks for the application.
23 | */
24 | public function register(): void
25 | {
26 | $this->reportable(function (Throwable $e) {
27 | //
28 | });
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrustProxies.php:
--------------------------------------------------------------------------------
1 | |string|null
14 | */
15 | protected $proxies;
16 |
17 | /**
18 | * The headers that should be used to detect proxies.
19 | *
20 | * @var int
21 | */
22 | protected $headers =
23 | Request::HEADER_X_FORWARDED_FOR |
24 | Request::HEADER_X_FORWARDED_HOST |
25 | Request::HEADER_X_FORWARDED_PORT |
26 | Request::HEADER_X_FORWARDED_PROTO |
27 | Request::HEADER_X_FORWARDED_AWS_ELB;
28 | }
29 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php:
--------------------------------------------------------------------------------
1 | string('email')->primary();
16 | $table->string('token');
17 | $table->timestamp('created_at')->nullable();
18 | });
19 | }
20 |
21 | /**
22 | * Reverse the migrations.
23 | */
24 | public function down(): void
25 | {
26 | Schema::dropIfExists('password_reset_tokens');
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/app/Http/Resources/TravelResource.php:
--------------------------------------------------------------------------------
1 |
18 | */
19 | public function toArray(Request $request): array
20 | {
21 | return [
22 | 'id' => $this->id,
23 | 'name' => $this->name,
24 | 'slug' => $this->slug,
25 | 'description' => $this->description,
26 | 'number_of_days' => $this->number_of_days,
27 | 'number_of_nights' => $this->number_of_nights,
28 | ];
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/Http/Requests/TravelRequest.php:
--------------------------------------------------------------------------------
1 |
21 | */
22 | public function rules(): array
23 | {
24 | return [
25 | 'is_public' => 'boolean',
26 | 'name' => ['required', 'unique:travels'],
27 | 'description' => ['required'],
28 | 'number_of_days' => ['required', 'integer'],
29 | ];
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/Http/Requests/TourRequest.php:
--------------------------------------------------------------------------------
1 |
21 | */
22 | public function rules(): array
23 | {
24 | return [
25 | 'name' => ['required'],
26 | 'starting_date' => ['required', 'date'],
27 | 'ending_date' => ['required', 'date', 'after:starting_date'],
28 | 'price' => ['required', 'numeric'],
29 | ];
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/Http/Middleware/RedirectIfAuthenticated.php:
--------------------------------------------------------------------------------
1 | check()) {
24 | return redirect(RouteServiceProvider::HOME);
25 | }
26 | }
27 |
28 | return $next($request);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/Models/Tour.php:
--------------------------------------------------------------------------------
1 | belongsTo(Travel::class);
26 | }
27 |
28 | public function price(): Attribute
29 | {
30 | return Attribute::make(
31 | get: fn ($value) => $value / 100,
32 | set: fn ($value) => $value * 100
33 | );
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_000000_create_users_table.php:
--------------------------------------------------------------------------------
1 | uuid('id')->primary();
16 | $table->string('name');
17 | $table->string('email')->unique();
18 | $table->timestamp('email_verified_at')->nullable();
19 | $table->string('password');
20 | $table->rememberToken();
21 | $table->timestamps();
22 | });
23 | }
24 |
25 | /**
26 | * Reverse the migrations.
27 | */
28 | public function down(): void
29 | {
30 | Schema::dropIfExists('users');
31 | }
32 | };
33 |
--------------------------------------------------------------------------------
/database/migrations/2023_06_01_130614_create_tours_table.php:
--------------------------------------------------------------------------------
1 | uuid('id')->primary();
16 | $table->foreignUuid('travel_id')->constrained('travels');
17 | $table->string('name');
18 | $table->date('starting_date');
19 | $table->date('ending_date');
20 | $table->integer('price');
21 | $table->timestamps();
22 | });
23 | }
24 |
25 | /**
26 | * Reverse the migrations.
27 | */
28 | public function down(): void
29 | {
30 | Schema::dropIfExists('tours');
31 | }
32 | };
33 |
--------------------------------------------------------------------------------
/database/migrations/2019_08_19_000000_create_failed_jobs_table.php:
--------------------------------------------------------------------------------
1 | id();
16 | $table->string('uuid')->unique();
17 | $table->text('connection');
18 | $table->text('queue');
19 | $table->longText('payload');
20 | $table->longText('exception');
21 | $table->timestamp('failed_at')->useCurrent();
22 | });
23 | }
24 |
25 | /**
26 | * Reverse the migrations.
27 | */
28 | public function down(): void
29 | {
30 | Schema::dropIfExists('failed_jobs');
31 | }
32 | };
33 |
--------------------------------------------------------------------------------
/database/migrations/2023_06_01_125944_create_travels_table.php:
--------------------------------------------------------------------------------
1 | uuid('id')->primary();
16 | $table->boolean('is_public')->default(false);
17 | $table->string('slug')->unique();
18 | $table->string('name');
19 | $table->text('description');
20 | $table->unsignedInteger('number_of_days');
21 | $table->timestamps();
22 | });
23 | }
24 |
25 | /**
26 | * Reverse the migrations.
27 | */
28 | public function down(): void
29 | {
30 | Schema::dropIfExists('travel');
31 | }
32 | };
33 |
--------------------------------------------------------------------------------
/config/cors.php:
--------------------------------------------------------------------------------
1 | ['api/*', 'sanctum/csrf-cookie'],
19 |
20 | 'allowed_methods' => ['*'],
21 |
22 | 'allowed_origins' => ['*'],
23 |
24 | 'allowed_origins_patterns' => [],
25 |
26 | 'allowed_headers' => ['*'],
27 |
28 | 'exposed_headers' => [],
29 |
30 | 'max_age' => 0,
31 |
32 | 'supports_credentials' => false,
33 |
34 | ];
35 |
--------------------------------------------------------------------------------
/tests/Feature/LoginTest.php:
--------------------------------------------------------------------------------
1 | create();
16 |
17 | $response = $this->post('/api/v1/login', [
18 | 'email' => $user->email,
19 | 'password' => 'password',
20 | ]);
21 |
22 | $response->assertStatus(200);
23 | $response->assertJsonStructure(['access_token']);
24 | }
25 |
26 | public function test_login_returns_error_with_invalid_credentials(): void
27 | {
28 | $response = $this->post('/api/v1/login', [
29 | 'email' => 'nonexisting@user.com',
30 | 'password' => 'password',
31 | ]);
32 |
33 | $response->assertStatus(422);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/V1/Admin/TourController.php:
--------------------------------------------------------------------------------
1 | tours()->create($request->validated());
28 |
29 | return new TourResource($tour);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php:
--------------------------------------------------------------------------------
1 | id();
16 | $table->uuidMorphs('tokenable');
17 | $table->string('name');
18 | $table->string('token', 64)->unique();
19 | $table->text('abilities')->nullable();
20 | $table->timestamp('last_used_at')->nullable();
21 | $table->timestamp('expires_at')->nullable();
22 | $table->timestamps();
23 | });
24 | }
25 |
26 | /**
27 | * Reverse the migrations.
28 | */
29 | public function down(): void
30 | {
31 | Schema::dropIfExists('personal_access_tokens');
32 | }
33 | };
34 |
--------------------------------------------------------------------------------
/app/Providers/EventServiceProvider.php:
--------------------------------------------------------------------------------
1 | >
16 | */
17 | protected $listen = [
18 | Registered::class => [
19 | SendEmailVerificationNotification::class,
20 | ],
21 | ];
22 |
23 | /**
24 | * Register any events for your application.
25 | */
26 | public function boot(): void
27 | {
28 | //
29 | }
30 |
31 | /**
32 | * Determine if events and listeners should be automatically discovered.
33 | */
34 | public function shouldDiscoverEvents(): bool
35 | {
36 | return false;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/config/services.php:
--------------------------------------------------------------------------------
1 | [
18 | 'domain' => env('MAILGUN_DOMAIN'),
19 | 'secret' => env('MAILGUN_SECRET'),
20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
21 | 'scheme' => 'https',
22 | ],
23 |
24 | 'postmark' => [
25 | 'token' => env('POSTMARK_TOKEN'),
26 | ],
27 |
28 | 'ses' => [
29 | 'key' => env('AWS_ACCESS_KEY_ID'),
30 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
31 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
32 | ],
33 |
34 | ];
35 |
--------------------------------------------------------------------------------
/database/factories/UserFactory.php:
--------------------------------------------------------------------------------
1 |
10 | */
11 | class UserFactory extends Factory
12 | {
13 | /**
14 | * Define the model's default state.
15 | *
16 | * @return array
17 | */
18 | public function definition(): array
19 | {
20 | return [
21 | 'name' => fake()->name(),
22 | 'email' => fake()->unique()->safeEmail(),
23 | 'email_verified_at' => now(),
24 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
25 | 'remember_token' => Str::random(10),
26 | ];
27 | }
28 |
29 | /**
30 | * Indicate that the model's email address should be unverified.
31 | */
32 | public function unverified(): static
33 | {
34 | return $this->state(fn (array $attributes) => [
35 | 'email_verified_at' => null,
36 | ]);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/tests/Feature/TravelsListTest.php:
--------------------------------------------------------------------------------
1 | create(['is_public' => true]);
16 | $response = $this->get('/api/v1/travels');
17 |
18 | $response->assertStatus(200);
19 | $response->assertJsonCount(15, 'data');
20 | $response->assertJsonPath('meta.last_page', 2);
21 | }
22 |
23 | public function test_travels_list_shows_only_public_records()
24 | {
25 | $nonPublicTravel = Travel::factory()->create(['is_public' => false]);
26 | $publicTravel = Travel::factory()->create(['is_public' => true]);
27 | $response = $this->get('/api/v1/travels');
28 |
29 | $response->assertStatus(200);
30 | $response->assertJsonCount(1, 'data');
31 | $response->assertJsonFragment(['id' => $publicTravel->id]);
32 | $response->assertJsonMissing(['id' => $nonPublicTravel->id]);
33 |
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/config/view.php:
--------------------------------------------------------------------------------
1 | [
17 | resource_path('views'),
18 | ],
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Compiled View Path
23 | |--------------------------------------------------------------------------
24 | |
25 | | This option determines where all the compiled Blade templates will be
26 | | stored for your application. Typically, this is within the storage
27 | | directory. However, as usual, you are free to change this value.
28 | |
29 | */
30 |
31 | 'compiled' => env(
32 | 'VIEW_COMPILED_PATH',
33 | realpath(storage_path('framework/views'))
34 | ),
35 |
36 | ];
37 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 | ./tests/Unit
10 |
11 |
12 | ./tests/Feature
13 |
14 |
15 |
16 |
17 | ./app
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/Http/Requests/ToursListRequest.php:
--------------------------------------------------------------------------------
1 |
22 | */
23 | public function rules(): array
24 | {
25 | return [
26 | 'priceFrom' => 'numeric',
27 | 'priceTo' => 'numeric',
28 | 'dateFrom' => 'date',
29 | 'dateTo' => 'date',
30 | 'sortBy' => Rule::in(['price']),
31 | 'sortOrder' => Rule::in(['asc', 'desc']),
32 | ];
33 | }
34 |
35 | public function messages(): array
36 | {
37 | return [
38 | 'sortBy' => "The 'sortBy' parameter accepts only 'price' value",
39 | 'sortOrder' => "The 'sortOrder' parameter accepts only 'asc' and 'desc' values",
40 | ];
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/Providers/RouteServiceProvider.php:
--------------------------------------------------------------------------------
1 | by($request->user()?->id ?: $request->ip());
29 | });
30 |
31 | $this->routes(function () {
32 | Route::middleware('api')
33 | ->prefix('api/v1')
34 | ->group(base_path('routes/api.php'));
35 |
36 | Route::middleware('web')
37 | ->group(base_path('routes/web.php'));
38 | });
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/Models/Travel.php:
--------------------------------------------------------------------------------
1 | hasMany(Tour::class);
29 | }
30 |
31 | public function numberOfNights(): Attribute
32 | {
33 | return Attribute::make(
34 | get: fn ($value, $attributes) => $attributes['number_of_days'] - 1
35 | );
36 | }
37 |
38 | /**
39 | * Return the sluggable configuration array for this model.
40 | */
41 | public function sluggable(): array
42 | {
43 | return [
44 | 'slug' => [
45 | 'source' => 'name',
46 | ],
47 | ];
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | APP_NAME=Laravel
2 | APP_ENV=local
3 | APP_KEY=
4 | APP_DEBUG=true
5 | APP_URL=http://localhost
6 |
7 | LOG_CHANNEL=stack
8 | LOG_DEPRECATIONS_CHANNEL=null
9 | LOG_LEVEL=debug
10 |
11 | DB_CONNECTION=mysql
12 | DB_HOST=127.0.0.1
13 | DB_PORT=3306
14 | DB_DATABASE=travelapi
15 | DB_USERNAME=root
16 | DB_PASSWORD=
17 |
18 | BROADCAST_DRIVER=log
19 | CACHE_DRIVER=file
20 | FILESYSTEM_DISK=local
21 | QUEUE_CONNECTION=sync
22 | SESSION_DRIVER=file
23 | SESSION_LIFETIME=120
24 |
25 | MEMCACHED_HOST=127.0.0.1
26 |
27 | REDIS_HOST=127.0.0.1
28 | REDIS_PASSWORD=null
29 | REDIS_PORT=6379
30 |
31 | MAIL_MAILER=smtp
32 | MAIL_HOST=mailpit
33 | MAIL_PORT=1025
34 | MAIL_USERNAME=null
35 | MAIL_PASSWORD=null
36 | MAIL_ENCRYPTION=null
37 | MAIL_FROM_ADDRESS="hello@example.com"
38 | MAIL_FROM_NAME="${APP_NAME}"
39 |
40 | AWS_ACCESS_KEY_ID=
41 | AWS_SECRET_ACCESS_KEY=
42 | AWS_DEFAULT_REGION=us-east-1
43 | AWS_BUCKET=
44 | AWS_USE_PATH_STYLE_ENDPOINT=false
45 |
46 | PUSHER_APP_ID=
47 | PUSHER_APP_KEY=
48 | PUSHER_APP_SECRET=
49 | PUSHER_HOST=
50 | PUSHER_PORT=443
51 | PUSHER_SCHEME=https
52 | PUSHER_APP_CLUSTER=mt1
53 |
54 | VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
55 | VITE_PUSHER_HOST="${PUSHER_HOST}"
56 | VITE_PUSHER_PORT="${PUSHER_PORT}"
57 | VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
58 | VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
59 |
--------------------------------------------------------------------------------
/routes/api.php:
--------------------------------------------------------------------------------
1 | middleware(['auth:sanctum'])->group(function () {
25 | Route::middleware('role:admin')->group(function () {
26 | Route::post('travels', [Admin\TravelController::class, 'store']);
27 | Route::post('travels/{travel}/tours', [Admin\TourController::class, 'store']);
28 | });
29 |
30 | Route::put('travels/{travel}', [\App\Http\Controllers\Api\V1\Admin\TravelController::class, 'update']);
31 | });
32 |
33 | Route::post('login', LoginController::class);
34 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/V1/Auth/LoginController.php:
--------------------------------------------------------------------------------
1 | validate([
26 | 'email' => ['required', 'email'],
27 | 'password' => ['required'],
28 | ]);
29 |
30 | $user = User::where('email', $request->email)->first();
31 |
32 | if (! $user || ! Hash::check($request->password, $user->password)) {
33 | return response()->json([
34 | 'error' => 'The provided credentials are incorrect.',
35 | ], 422);
36 | }
37 |
38 | $device = substr($request->userAgent() ?? '', 0, 255);
39 |
40 | return response()->json([
41 | 'access_token' => $user->createToken($device)->plainTextToken,
42 | ]);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/resources/js/bootstrap.js:
--------------------------------------------------------------------------------
1 | /**
2 | * We'll load the axios HTTP library which allows us to easily issue requests
3 | * to our Laravel back-end. This library automatically handles sending the
4 | * CSRF token as a header based on the value of the "XSRF" token cookie.
5 | */
6 |
7 | import axios from 'axios';
8 | window.axios = axios;
9 |
10 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
11 |
12 | /**
13 | * Echo exposes an expressive API for subscribing to channels and listening
14 | * for events that are broadcast by Laravel. Echo and event broadcasting
15 | * allows your team to easily build robust real-time web applications.
16 | */
17 |
18 | // import Echo from 'laravel-echo';
19 |
20 | // import Pusher from 'pusher-js';
21 | // window.Pusher = Pusher;
22 |
23 | // window.Echo = new Echo({
24 | // broadcaster: 'pusher',
25 | // key: import.meta.env.VITE_PUSHER_APP_KEY,
26 | // cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? 'mt1',
27 | // wsHost: import.meta.env.VITE_PUSHER_HOST ? import.meta.env.VITE_PUSHER_HOST : `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`,
28 | // wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80,
29 | // wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443,
30 | // forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https',
31 | // enabledTransports: ['ws', 'wss'],
32 | // });
33 |
--------------------------------------------------------------------------------
/app/Models/User.php:
--------------------------------------------------------------------------------
1 |
21 | */
22 | protected $fillable = [
23 | 'name',
24 | 'email',
25 | 'password',
26 | ];
27 |
28 | /**
29 | * The attributes that should be hidden for serialization.
30 | *
31 | * @var array
32 | */
33 | protected $hidden = [
34 | 'password',
35 | 'remember_token',
36 | ];
37 |
38 | /**
39 | * The attributes that should be cast.
40 | *
41 | * @var array
42 | */
43 | protected $casts = [
44 | 'email_verified_at' => 'datetime',
45 | 'password' => 'hashed',
46 | ];
47 |
48 | public function roles(): BelongsToMany
49 | {
50 | return $this->belongsToMany(Role::class);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/V1/TravelController.php:
--------------------------------------------------------------------------------
1 | where('is_public', true)
27 | ->paginate(config('app.paginationPerPage.travels'));
28 |
29 | return TravelResource::collection($travels);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/.scribe/endpoints/02.yaml:
--------------------------------------------------------------------------------
1 | name: 'Auth endpoints'
2 | description: ''
3 | endpoints:
4 | -
5 | httpMethods:
6 | - POST
7 | uri: api/v1/login
8 | metadata:
9 | groupName: 'Auth endpoints'
10 | groupDescription: ''
11 | subgroup: ''
12 | subgroupDescription: ''
13 | title: 'POST Login'
14 | description: 'Login with the existing user.'
15 | authenticated: false
16 | custom: []
17 | headers:
18 | Content-Type: application/json
19 | Accept: application/json
20 | urlParameters: []
21 | cleanUrlParameters: []
22 | queryParameters: []
23 | cleanQueryParameters: []
24 | bodyParameters:
25 | email:
26 | name: email
27 | description: 'Must be a valid email address.'
28 | required: true
29 | example: damien.wilderman@example.com
30 | type: string
31 | custom: []
32 | password:
33 | name: password
34 | description: ''
35 | required: true
36 | example: iste
37 | type: string
38 | custom: []
39 | cleanBodyParameters:
40 | email: damien.wilderman@example.com
41 | password: iste
42 | fileParameters: []
43 | responses:
44 | -
45 | status: 200
46 | content: '{"access_token":"1|a9ZcYzIrLURVGx6Xe41HKj1CrNsxRxe4pLA2oISo"}'
47 | headers: []
48 | description: ''
49 | custom: []
50 | -
51 | status: 422
52 | content: '{"error": "The provided credentials are incorrect."}'
53 | headers: []
54 | description: ''
55 | custom: []
56 | responseFields: []
57 | auth: []
58 | controller: null
59 | method: null
60 | route: null
61 | custom: []
62 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/V1/Admin/TravelController.php:
--------------------------------------------------------------------------------
1 | validated());
28 |
29 | return new TravelResource($travel);
30 | }
31 |
32 | /**
33 | * PUT Travel
34 | *
35 | * Updates new Travel record.
36 | *
37 | * @authenticated
38 | *
39 | * @response {"data":{"id":"996a36ca-2693-4901-9c55-7136e68d81d5","name":"My new travel 234","slug":"my-new-travel-234","description":"The second best journey ever!","number_of_days":"4","number_of_nights":3}}
40 | * @response 422 {"message":"The name has already been taken.","errors":{"name":["The name has already been taken."]}}
41 | */
42 | public function update(Travel $travel, TravelRequest $request)
43 | {
44 | $travel->update($request->validated());
45 |
46 | return new TravelResource($travel);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/config/hashing.php:
--------------------------------------------------------------------------------
1 | 'bcrypt',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Bcrypt Options
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may specify the configuration options that should be used when
26 | | passwords are hashed using the Bcrypt algorithm. This will allow you
27 | | to control the amount of time it takes to hash the given password.
28 | |
29 | */
30 |
31 | 'bcrypt' => [
32 | 'rounds' => env('BCRYPT_ROUNDS', 10),
33 | ],
34 |
35 | /*
36 | |--------------------------------------------------------------------------
37 | | Argon Options
38 | |--------------------------------------------------------------------------
39 | |
40 | | Here you may specify the configuration options that should be used when
41 | | passwords are hashed using the Argon algorithm. These will allow you
42 | | to control the amount of time it takes to hash the given password.
43 | |
44 | */
45 |
46 | 'argon' => [
47 | 'memory' => 65536,
48 | 'threads' => 1,
49 | 'time' => 4,
50 | ],
51 |
52 | ];
53 |
--------------------------------------------------------------------------------
/.scribe/endpoints.cache/02.yaml:
--------------------------------------------------------------------------------
1 | ## Autogenerated by Scribe. DO NOT MODIFY.
2 |
3 | name: 'Auth endpoints'
4 | description: ''
5 | endpoints:
6 | -
7 | httpMethods:
8 | - POST
9 | uri: api/v1/login
10 | metadata:
11 | groupName: 'Auth endpoints'
12 | groupDescription: ''
13 | subgroup: ''
14 | subgroupDescription: ''
15 | title: 'POST Login'
16 | description: 'Login with the existing user.'
17 | authenticated: false
18 | custom: []
19 | headers:
20 | Content-Type: application/json
21 | Accept: application/json
22 | urlParameters: []
23 | cleanUrlParameters: []
24 | queryParameters: []
25 | cleanQueryParameters: []
26 | bodyParameters:
27 | email:
28 | name: email
29 | description: 'Must be a valid email address.'
30 | required: true
31 | example: damien.wilderman@example.com
32 | type: string
33 | custom: []
34 | password:
35 | name: password
36 | description: ''
37 | required: true
38 | example: iste
39 | type: string
40 | custom: []
41 | cleanBodyParameters:
42 | email: damien.wilderman@example.com
43 | password: iste
44 | fileParameters: []
45 | responses:
46 | -
47 | status: 200
48 | content: '{"access_token":"1|a9ZcYzIrLURVGx6Xe41HKj1CrNsxRxe4pLA2oISo"}'
49 | headers: []
50 | description: ''
51 | custom: []
52 | -
53 | status: 422
54 | content: '{"error": "The provided credentials are incorrect."}'
55 | headers: []
56 | description: ''
57 | custom: []
58 | responseFields: []
59 | auth: []
60 | controller: null
61 | method: null
62 | route: null
63 | custom: []
64 |
--------------------------------------------------------------------------------
/bootstrap/app.php:
--------------------------------------------------------------------------------
1 | singleton(
30 | Illuminate\Contracts\Http\Kernel::class,
31 | App\Http\Kernel::class
32 | );
33 |
34 | $app->singleton(
35 | Illuminate\Contracts\Console\Kernel::class,
36 | App\Console\Kernel::class
37 | );
38 |
39 | $app->singleton(
40 | Illuminate\Contracts\Debug\ExceptionHandler::class,
41 | App\Exceptions\Handler::class
42 | );
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Return The Application
47 | |--------------------------------------------------------------------------
48 | |
49 | | This script returns the application instance. The instance is given to
50 | | the calling script so we can separate the building of the instances
51 | | from the actual running of the application and sending responses.
52 | |
53 | */
54 |
55 | return $app;
56 |
--------------------------------------------------------------------------------
/artisan:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | make(Illuminate\Contracts\Console\Kernel::class);
34 |
35 | $status = $kernel->handle(
36 | $input = new Symfony\Component\Console\Input\ArgvInput,
37 | new Symfony\Component\Console\Output\ConsoleOutput
38 | );
39 |
40 | /*
41 | |--------------------------------------------------------------------------
42 | | Shutdown The Application
43 | |--------------------------------------------------------------------------
44 | |
45 | | Once Artisan has finished running, we will fire off the shutdown events
46 | | so that any final work may be done by the application before we shut
47 | | down the process. This is the last thing to happen to the request.
48 | |
49 | */
50 |
51 | $kernel->terminate($input, $status);
52 |
53 | exit($status);
54 |
--------------------------------------------------------------------------------
/public/index.php:
--------------------------------------------------------------------------------
1 | make(Kernel::class);
50 |
51 | $response = $kernel->handle(
52 | $request = Request::capture()
53 | )->send();
54 |
55 | $kernel->terminate($request, $response);
56 |
--------------------------------------------------------------------------------
/.scribe/endpoints/custom.0.yaml:
--------------------------------------------------------------------------------
1 | # To include an endpoint that isn't a part of your Laravel app (or belongs to a vendor package),
2 | # you can define it in a custom.*.yaml file, like this one.
3 | # Each custom file should contain an array of endpoints. Here's an example:
4 | # See https://scribe.knuckles.wtf/laravel/documenting/custom-endpoints#extra-sorting-groups-in-custom-endpoint-files for more options
5 |
6 | #- httpMethods:
7 | # - POST
8 | # uri: api/doSomething/{param}
9 | # metadata:
10 | # groupName: The group the endpoint belongs to. Can be a new group or an existing group.
11 | # groupDescription: A description for the group. You don't need to set this for every endpoint; once is enough.
12 | # subgroup: You can add a subgroup, too.
13 | # title: Do something
14 | # description: 'This endpoint allows you to do something.'
15 | # authenticated: false
16 | # headers:
17 | # Content-Type: application/json
18 | # Accept: application/json
19 | # urlParameters:
20 | # param:
21 | # name: param
22 | # description: A URL param for no reason.
23 | # required: true
24 | # example: 2
25 | # type: integer
26 | # queryParameters:
27 | # speed:
28 | # name: speed
29 | # description: How fast the thing should be done. Can be `slow` or `fast`.
30 | # required: false
31 | # example: fast
32 | # type: string
33 | # bodyParameters:
34 | # something:
35 | # name: something
36 | # description: The things we should do.
37 | # required: true
38 | # example:
39 | # - string 1
40 | # - string 2
41 | # type: 'string[]'
42 | # responses:
43 | # - status: 200
44 | # description: 'When the thing was done smoothly.'
45 | # content: # Your response content can be an object, an array, a string or empty.
46 | # {
47 | # "hey": "ho ho ho"
48 | # }
49 | # responseFields:
50 | # hey:
51 | # name: hey
52 | # description: Who knows?
53 | # type: string # This is optional
54 |
--------------------------------------------------------------------------------
/tests/Feature/AdminTourTest.php:
--------------------------------------------------------------------------------
1 | create();
19 | $response = $this->postJson('/api/v1/admin/travels/'.$travel->id.'/tours');
20 |
21 | $response->assertStatus(401);
22 | }
23 |
24 | public function test_non_admin_user_cannot_access_adding_tour(): void
25 | {
26 | $this->seed(RoleSeeder::class);
27 | $user = User::factory()->create();
28 | $user->roles()->attach(Role::where('name', 'editor')->value('id'));
29 | $travel = Travel::factory()->create();
30 | $response = $this->actingAs($user)->postJson('/api/v1/admin/travels/'.$travel->id.'/tours');
31 |
32 | $response->assertStatus(403);
33 | }
34 |
35 | public function test_saves_tour_successfully_with_valid_data(): void
36 | {
37 | $this->seed(RoleSeeder::class);
38 | $user = User::factory()->create();
39 | $user->roles()->attach(Role::where('name', 'admin')->value('id'));
40 | $travel = Travel::factory()->create();
41 |
42 | $response = $this->actingAs($user)->postJson('/api/v1/admin/travels/'.$travel->id.'/tours', [
43 | 'name' => 'Tour name',
44 | ]);
45 | $response->assertStatus(422);
46 |
47 | $response = $this->actingAs($user)->postJson('/api/v1/admin/travels/'.$travel->id.'/tours', [
48 | 'name' => 'Tour name',
49 | 'starting_date' => now()->toDateString(),
50 | 'ending_date' => now()->addDay()->toDateString(),
51 | 'price' => 123.45,
52 | ]);
53 |
54 | $response->assertStatus(201);
55 |
56 | $response = $this->get('/api/v1/travels/'.$travel->slug.'/tours');
57 | $response->assertJsonFragment(['name' => 'Tour name']);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/app/Console/Commands/CreateUserCommand.php:
--------------------------------------------------------------------------------
1 | ask('Name of the new user');
34 | $user['email'] = $this->ask('Email of the new user');
35 | $user['password'] = $this->secret('Password of the new user');
36 | $roleName = $this->choice('Role of the new user', ['admin', 'editor'], 1);
37 |
38 | $validator = Validator::make($user, [
39 | 'name' => ['required', 'string', 'max:255'],
40 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:'.User::class],
41 | 'password' => ['required', Password::defaults()],
42 | ]);
43 | if ($validator->fails()) {
44 | foreach ($validator->errors()->all() as $error) {
45 | $this->error($error);
46 | }
47 |
48 | return;
49 | }
50 |
51 | $role = Role::where('name', $roleName)->first();
52 | if (! $role) {
53 | $this->error('Role not found');
54 |
55 | return;
56 | }
57 |
58 | DB::transaction(function () use ($user, $role) {
59 | $newUser = User::create([
60 | 'name' => $user['name'],
61 | 'email' => $user['email'],
62 | 'password' => bcrypt($user['password']),
63 | ]);
64 | $newUser->roles()->attach($role->id);
65 | });
66 |
67 | $this->info('User '.$user['email'].' created successfully');
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "laravel/laravel",
3 | "type": "project",
4 | "description": "The Laravel Framework.",
5 | "keywords": ["framework", "laravel"],
6 | "license": "MIT",
7 | "require": {
8 | "php": "^8.1",
9 | "cviebrock/eloquent-sluggable": "^10.0",
10 | "guzzlehttp/guzzle": "^7.2",
11 | "laravel/framework": "^10.10",
12 | "laravel/sanctum": "^3.2",
13 | "laravel/tinker": "^2.8"
14 | },
15 | "require-dev": {
16 | "fakerphp/faker": "^1.9.1",
17 | "knuckleswtf/scribe": "^4.21",
18 | "laravel/pint": "^1.10",
19 | "laravel/sail": "^1.18",
20 | "mockery/mockery": "^1.4.4",
21 | "nunomaduro/collision": "^7.0",
22 | "nunomaduro/larastan": "^2.6",
23 | "phpunit/phpunit": "^10.1",
24 | "spatie/laravel-ignition": "^2.0"
25 | },
26 | "autoload": {
27 | "psr-4": {
28 | "App\\": "app/",
29 | "Database\\Factories\\": "database/factories/",
30 | "Database\\Seeders\\": "database/seeders/"
31 | }
32 | },
33 | "autoload-dev": {
34 | "psr-4": {
35 | "Tests\\": "tests/"
36 | }
37 | },
38 | "scripts": {
39 | "post-autoload-dump": [
40 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
41 | "@php artisan package:discover --ansi"
42 | ],
43 | "post-update-cmd": [
44 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
45 | ],
46 | "post-root-package-install": [
47 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
48 | ],
49 | "post-create-project-cmd": [
50 | "@php artisan key:generate --ansi"
51 | ]
52 | },
53 | "extra": {
54 | "laravel": {
55 | "dont-discover": []
56 | }
57 | },
58 | "config": {
59 | "optimize-autoloader": true,
60 | "preferred-install": "dist",
61 | "sort-packages": true,
62 | "allow-plugins": {
63 | "pestphp/pest-plugin": true,
64 | "php-http/discovery": true
65 | }
66 | },
67 | "minimum-stability": "stable",
68 | "prefer-stable": true
69 | }
70 |
--------------------------------------------------------------------------------
/config/broadcasting.php:
--------------------------------------------------------------------------------
1 | env('BROADCAST_DRIVER', 'null'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Broadcast Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the broadcast connections that will be used
26 | | to broadcast events to other systems or over websockets. Samples of
27 | | each available type of connection are provided inside this array.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'pusher' => [
34 | 'driver' => 'pusher',
35 | 'key' => env('PUSHER_APP_KEY'),
36 | 'secret' => env('PUSHER_APP_SECRET'),
37 | 'app_id' => env('PUSHER_APP_ID'),
38 | 'options' => [
39 | 'cluster' => env('PUSHER_APP_CLUSTER'),
40 | 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
41 | 'port' => env('PUSHER_PORT', 443),
42 | 'scheme' => env('PUSHER_SCHEME', 'https'),
43 | 'encrypted' => true,
44 | 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
45 | ],
46 | 'client_options' => [
47 | // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
48 | ],
49 | ],
50 |
51 | 'ably' => [
52 | 'driver' => 'ably',
53 | 'key' => env('ABLY_KEY'),
54 | ],
55 |
56 | 'redis' => [
57 | 'driver' => 'redis',
58 | 'connection' => 'default',
59 | ],
60 |
61 | 'log' => [
62 | 'driver' => 'log',
63 | ],
64 |
65 | 'null' => [
66 | 'driver' => 'null',
67 | ],
68 |
69 | ],
70 |
71 | ];
72 |
--------------------------------------------------------------------------------
/config/sanctum.php:
--------------------------------------------------------------------------------
1 | explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
19 | '%s%s',
20 | 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
21 | Sanctum::currentApplicationUrlWithPort()
22 | ))),
23 |
24 | /*
25 | |--------------------------------------------------------------------------
26 | | Sanctum Guards
27 | |--------------------------------------------------------------------------
28 | |
29 | | This array contains the authentication guards that will be checked when
30 | | Sanctum is trying to authenticate a request. If none of these guards
31 | | are able to authenticate the request, Sanctum will use the bearer
32 | | token that's present on an incoming request for authentication.
33 | |
34 | */
35 |
36 | 'guard' => ['web'],
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Expiration Minutes
41 | |--------------------------------------------------------------------------
42 | |
43 | | This value controls the number of minutes until an issued token will be
44 | | considered expired. If this value is null, personal access tokens do
45 | | not expire. This won't tweak the lifetime of first-party sessions.
46 | |
47 | */
48 |
49 | 'expiration' => null,
50 |
51 | /*
52 | |--------------------------------------------------------------------------
53 | | Sanctum Middleware
54 | |--------------------------------------------------------------------------
55 | |
56 | | When authenticating your first-party SPA with Sanctum you may need to
57 | | customize some of the middleware Sanctum uses while processing the
58 | | request. You may change the middleware listed below as required.
59 | |
60 | */
61 |
62 | 'middleware' => [
63 | 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,
64 | 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class,
65 | ],
66 |
67 | ];
68 |
--------------------------------------------------------------------------------
/config/filesystems.php:
--------------------------------------------------------------------------------
1 | env('FILESYSTEM_DISK', 'local'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Filesystem Disks
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may configure as many filesystem "disks" as you wish, and you
24 | | may even configure multiple disks of the same driver. Defaults have
25 | | been set up for each driver as an example of the required values.
26 | |
27 | | Supported Drivers: "local", "ftp", "sftp", "s3"
28 | |
29 | */
30 |
31 | 'disks' => [
32 |
33 | 'local' => [
34 | 'driver' => 'local',
35 | 'root' => storage_path('app'),
36 | 'throw' => false,
37 | ],
38 |
39 | 'public' => [
40 | 'driver' => 'local',
41 | 'root' => storage_path('app/public'),
42 | 'url' => env('APP_URL').'/storage',
43 | 'visibility' => 'public',
44 | 'throw' => false,
45 | ],
46 |
47 | 's3' => [
48 | 'driver' => 's3',
49 | 'key' => env('AWS_ACCESS_KEY_ID'),
50 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
51 | 'region' => env('AWS_DEFAULT_REGION'),
52 | 'bucket' => env('AWS_BUCKET'),
53 | 'url' => env('AWS_URL'),
54 | 'endpoint' => env('AWS_ENDPOINT'),
55 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
56 | 'throw' => false,
57 | ],
58 |
59 | ],
60 |
61 | /*
62 | |--------------------------------------------------------------------------
63 | | Symbolic Links
64 | |--------------------------------------------------------------------------
65 | |
66 | | Here you may configure the symbolic links that will be created when the
67 | | `storage:link` Artisan command is executed. The array keys should be
68 | | the locations of the links and the values should be their targets.
69 | |
70 | */
71 |
72 | 'links' => [
73 | public_path('storage') => storage_path('app/public'),
74 | ],
75 |
76 | ];
77 |
--------------------------------------------------------------------------------
/tests/Feature/AdminTravelTest.php:
--------------------------------------------------------------------------------
1 | postJson('/api/v1/admin/travels');
19 |
20 | $response->assertStatus(401);
21 | }
22 |
23 | public function test_non_admin_user_cannot_access_adding_travel(): void
24 | {
25 | $user = User::factory()->create();
26 | $user->roles()->attach(Role::where('name', 'editor')->value('id'));
27 | $response = $this->actingAs($user)->postJson('/api/v1/admin/travels');
28 |
29 | $response->assertStatus(403);
30 | }
31 |
32 | public function test_saves_travel_successfully_with_valid_data(): void
33 | {
34 | $this->seed(RoleSeeder::class);
35 | $user = User::factory()->create();
36 | $user->roles()->attach(Role::where('name', 'admin')->value('id'));
37 |
38 | $response = $this->actingAs($user)->postJson('/api/v1/admin/travels', [
39 | 'name' => 'Travel name',
40 | ]);
41 | $response->assertStatus(422);
42 |
43 | $response = $this->actingAs($user)->postJson('/api/v1/admin/travels', [
44 | 'name' => 'Travel name',
45 | 'is_public' => 1,
46 | 'description' => 'Some description',
47 | 'number_of_days' => 5,
48 | ]);
49 |
50 | $response->assertStatus(201);
51 |
52 | $response = $this->get('/api/v1/travels');
53 | $response->assertJsonFragment(['name' => 'Travel name']);
54 | }
55 |
56 | public function test_updates_travel_successfully_with_valid_data(): void
57 | {
58 | $this->seed(RoleSeeder::class);
59 | $user = User::factory()->create();
60 | $user->roles()->attach(Role::where('name', 'editor')->value('id'));
61 | $travel = Travel::factory()->create();
62 |
63 | $response = $this->actingAs($user)->putJson('/api/v1/admin/travels/'.$travel->id, [
64 | 'name' => 'Travel name',
65 | ]);
66 | $response->assertStatus(422);
67 |
68 | $response = $this->actingAs($user)->putJson('/api/v1/admin/travels/'.$travel->id, [
69 | 'name' => 'Travel name updated',
70 | 'is_public' => 1,
71 | 'description' => 'Some description',
72 | 'number_of_days' => 5,
73 | ]);
74 |
75 | $response->assertStatus(200);
76 |
77 | $response = $this->get('/api/v1/travels');
78 | $response->assertJsonFragment(['name' => 'Travel name updated']);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/app/Http/Kernel.php:
--------------------------------------------------------------------------------
1 |
16 | */
17 | protected $middleware = [
18 | // \App\Http\Middleware\TrustHosts::class,
19 | \App\Http\Middleware\TrustProxies::class,
20 | \Illuminate\Http\Middleware\HandleCors::class,
21 | \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
22 | \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
23 | \App\Http\Middleware\TrimStrings::class,
24 | \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
25 | ];
26 |
27 | /**
28 | * The application's route middleware groups.
29 | *
30 | * @var array>
31 | */
32 | protected $middlewareGroups = [
33 | 'web' => [
34 | \App\Http\Middleware\EncryptCookies::class,
35 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
36 | \Illuminate\Session\Middleware\StartSession::class,
37 | \Illuminate\View\Middleware\ShareErrorsFromSession::class,
38 | \App\Http\Middleware\VerifyCsrfToken::class,
39 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
40 | ],
41 |
42 | 'api' => [
43 | // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
44 | \Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
45 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
46 | ],
47 | ];
48 |
49 | /**
50 | * The application's middleware aliases.
51 | *
52 | * Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
53 | *
54 | * @var array
55 | */
56 | protected $middlewareAliases = [
57 | 'auth' => \App\Http\Middleware\Authenticate::class,
58 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
59 | 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
60 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
61 | 'can' => \Illuminate\Auth\Middleware\Authorize::class,
62 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
63 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
64 | 'signed' => \App\Http\Middleware\ValidateSignature::class,
65 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
66 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
67 | 'role' => RoleMiddleware::class,
68 | ];
69 | }
70 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/V1/TourController.php:
--------------------------------------------------------------------------------
1 | tours()
36 | ->when($request->priceFrom, function ($query) use ($request) {
37 | $query->where('price', '>=', $request->priceFrom * 100);
38 | })
39 | ->when($request->priceTo, function ($query) use ($request) {
40 | $query->where('price', '<=', $request->priceTo * 100);
41 | })
42 | ->when($request->dateFrom, function ($query) use ($request) {
43 | $query->where('starting_date', '>=', $request->dateFrom);
44 | })
45 | ->when($request->dateTo, function ($query) use ($request) {
46 | $query->where('starting_date', '<=', $request->dateTo);
47 | })
48 | ->when($request->sortBy, function ($query) use ($request) {
49 | if (! in_array($request->sortBy, ['price'])
50 | || (! in_array($request->sortOrder, ['asc', 'desc']))) {
51 | return;
52 | }
53 |
54 | $query->orderBy($request->sortBy, $request->sortOrder);
55 | })
56 | ->orderBy('starting_date')
57 | ->paginate();
58 |
59 | return TourResource::collection($tours);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/config/cache.php:
--------------------------------------------------------------------------------
1 | env('CACHE_DRIVER', 'file'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Cache Stores
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the cache "stores" for your application as
26 | | well as their drivers. You may even define multiple stores for the
27 | | same cache driver to group types of items stored in your caches.
28 | |
29 | | Supported drivers: "apc", "array", "database", "file",
30 | | "memcached", "redis", "dynamodb", "octane", "null"
31 | |
32 | */
33 |
34 | 'stores' => [
35 |
36 | 'apc' => [
37 | 'driver' => 'apc',
38 | ],
39 |
40 | 'array' => [
41 | 'driver' => 'array',
42 | 'serialize' => false,
43 | ],
44 |
45 | 'database' => [
46 | 'driver' => 'database',
47 | 'table' => 'cache',
48 | 'connection' => null,
49 | 'lock_connection' => null,
50 | ],
51 |
52 | 'file' => [
53 | 'driver' => 'file',
54 | 'path' => storage_path('framework/cache/data'),
55 | 'lock_path' => storage_path('framework/cache/data'),
56 | ],
57 |
58 | 'memcached' => [
59 | 'driver' => 'memcached',
60 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
61 | 'sasl' => [
62 | env('MEMCACHED_USERNAME'),
63 | env('MEMCACHED_PASSWORD'),
64 | ],
65 | 'options' => [
66 | // Memcached::OPT_CONNECT_TIMEOUT => 2000,
67 | ],
68 | 'servers' => [
69 | [
70 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
71 | 'port' => env('MEMCACHED_PORT', 11211),
72 | 'weight' => 100,
73 | ],
74 | ],
75 | ],
76 |
77 | 'redis' => [
78 | 'driver' => 'redis',
79 | 'connection' => 'cache',
80 | 'lock_connection' => 'default',
81 | ],
82 |
83 | 'dynamodb' => [
84 | 'driver' => 'dynamodb',
85 | 'key' => env('AWS_ACCESS_KEY_ID'),
86 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
87 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
88 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
89 | 'endpoint' => env('DYNAMODB_ENDPOINT'),
90 | ],
91 |
92 | 'octane' => [
93 | 'driver' => 'octane',
94 | ],
95 |
96 | ],
97 |
98 | /*
99 | |--------------------------------------------------------------------------
100 | | Cache Key Prefix
101 | |--------------------------------------------------------------------------
102 | |
103 | | When utilizing the APC, database, memcached, Redis, or DynamoDB cache
104 | | stores there might be other applications using the same cache. For
105 | | that reason, you may prefix every cache key to avoid collisions.
106 | |
107 | */
108 |
109 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
110 |
111 | ];
112 |
--------------------------------------------------------------------------------
/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_CONNECTION', 'sync'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Queue Connections
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may configure the connection information for each server that
24 | | is used by your application. A default configuration has been added
25 | | for each back-end shipped with Laravel. You are free to add more.
26 | |
27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'sync' => [
34 | 'driver' => 'sync',
35 | ],
36 |
37 | 'database' => [
38 | 'driver' => 'database',
39 | 'table' => 'jobs',
40 | 'queue' => 'default',
41 | 'retry_after' => 90,
42 | 'after_commit' => false,
43 | ],
44 |
45 | 'beanstalkd' => [
46 | 'driver' => 'beanstalkd',
47 | 'host' => 'localhost',
48 | 'queue' => 'default',
49 | 'retry_after' => 90,
50 | 'block_for' => 0,
51 | 'after_commit' => false,
52 | ],
53 |
54 | 'sqs' => [
55 | 'driver' => 'sqs',
56 | 'key' => env('AWS_ACCESS_KEY_ID'),
57 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
58 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
59 | 'queue' => env('SQS_QUEUE', 'default'),
60 | 'suffix' => env('SQS_SUFFIX'),
61 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
62 | 'after_commit' => false,
63 | ],
64 |
65 | 'redis' => [
66 | 'driver' => 'redis',
67 | 'connection' => 'default',
68 | 'queue' => env('REDIS_QUEUE', 'default'),
69 | 'retry_after' => 90,
70 | 'block_for' => null,
71 | 'after_commit' => false,
72 | ],
73 |
74 | ],
75 |
76 | /*
77 | |--------------------------------------------------------------------------
78 | | Job Batching
79 | |--------------------------------------------------------------------------
80 | |
81 | | The following options configure the database and table that store job
82 | | batching information. These options can be updated to any database
83 | | connection and table which has been defined by your application.
84 | |
85 | */
86 |
87 | 'batching' => [
88 | 'database' => env('DB_CONNECTION', 'mysql'),
89 | 'table' => 'job_batches',
90 | ],
91 |
92 | /*
93 | |--------------------------------------------------------------------------
94 | | Failed Queue Jobs
95 | |--------------------------------------------------------------------------
96 | |
97 | | These options configure the behavior of failed queue job logging so you
98 | | can control which database and table are used to store the jobs that
99 | | have failed. You may change them to any database / table you wish.
100 | |
101 | */
102 |
103 | 'failed' => [
104 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
105 | 'database' => env('DB_CONNECTION', 'mysql'),
106 | 'table' => 'failed_jobs',
107 | ],
108 |
109 | ];
110 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | ## About Laravel
11 |
12 | 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:
13 |
14 | - [Simple, fast routing engine](https://laravel.com/docs/routing).
15 | - [Powerful dependency injection container](https://laravel.com/docs/container).
16 | - Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
17 | - Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
18 | - Database agnostic [schema migrations](https://laravel.com/docs/migrations).
19 | - [Robust background job processing](https://laravel.com/docs/queues).
20 | - [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
21 |
22 | Laravel is accessible, powerful, and provides tools required for large, robust applications.
23 |
24 | ## Learning Laravel
25 |
26 | 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.
27 |
28 | You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
29 |
30 | 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.
31 |
32 | ## Laravel Sponsors
33 |
34 | 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).
35 |
36 | ### Premium Partners
37 |
38 | - **[Vehikl](https://vehikl.com/)**
39 | - **[Tighten Co.](https://tighten.co)**
40 | - **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
41 | - **[64 Robots](https://64robots.com)**
42 | - **[Cubet Techno Labs](https://cubettech.com)**
43 | - **[Cyber-Duck](https://cyber-duck.co.uk)**
44 | - **[Many](https://www.many.co.uk)**
45 | - **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
46 | - **[DevSquad](https://devsquad.com)**
47 | - **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
48 | - **[OP.GG](https://op.gg)**
49 | - **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
50 | - **[Lendio](https://lendio.com)**
51 |
52 | ## Contributing
53 |
54 | Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
55 |
56 | ## Code of Conduct
57 |
58 | 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).
59 |
60 | ## Security Vulnerabilities
61 |
62 | 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.
63 |
64 | ## License
65 |
66 | The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
67 |
--------------------------------------------------------------------------------
/config/mail.php:
--------------------------------------------------------------------------------
1 | env('MAIL_MAILER', 'smtp'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Mailer Configurations
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may configure all of the mailers used by your application plus
24 | | their respective settings. Several examples have been configured for
25 | | you and you are free to add your own as your application requires.
26 | |
27 | | Laravel supports a variety of mail "transport" drivers to be used while
28 | | sending an e-mail. You will specify which one you are using for your
29 | | mailers below. You are free to add additional mailers as required.
30 | |
31 | | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
32 | | "postmark", "log", "array", "failover"
33 | |
34 | */
35 |
36 | 'mailers' => [
37 | 'smtp' => [
38 | 'transport' => 'smtp',
39 | 'url' => env('MAIL_URL'),
40 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
41 | 'port' => env('MAIL_PORT', 587),
42 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
43 | 'username' => env('MAIL_USERNAME'),
44 | 'password' => env('MAIL_PASSWORD'),
45 | 'timeout' => null,
46 | 'local_domain' => env('MAIL_EHLO_DOMAIN'),
47 | ],
48 |
49 | 'ses' => [
50 | 'transport' => 'ses',
51 | ],
52 |
53 | 'mailgun' => [
54 | 'transport' => 'mailgun',
55 | // 'client' => [
56 | // 'timeout' => 5,
57 | // ],
58 | ],
59 |
60 | 'postmark' => [
61 | 'transport' => 'postmark',
62 | // 'client' => [
63 | // 'timeout' => 5,
64 | // ],
65 | ],
66 |
67 | 'sendmail' => [
68 | 'transport' => 'sendmail',
69 | 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
70 | ],
71 |
72 | 'log' => [
73 | 'transport' => 'log',
74 | 'channel' => env('MAIL_LOG_CHANNEL'),
75 | ],
76 |
77 | 'array' => [
78 | 'transport' => 'array',
79 | ],
80 |
81 | 'failover' => [
82 | 'transport' => 'failover',
83 | 'mailers' => [
84 | 'smtp',
85 | 'log',
86 | ],
87 | ],
88 | ],
89 |
90 | /*
91 | |--------------------------------------------------------------------------
92 | | Global "From" Address
93 | |--------------------------------------------------------------------------
94 | |
95 | | You may wish for all e-mails sent by your application to be sent from
96 | | the same address. Here, you may specify a name and address that is
97 | | used globally for all e-mails that are sent by your application.
98 | |
99 | */
100 |
101 | 'from' => [
102 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
103 | 'name' => env('MAIL_FROM_NAME', 'Example'),
104 | ],
105 |
106 | /*
107 | |--------------------------------------------------------------------------
108 | | Markdown Mail Settings
109 | |--------------------------------------------------------------------------
110 | |
111 | | If you are using Markdown based email rendering, you may configure your
112 | | theme and component paths here, allowing you to customize the design
113 | | of the emails. Or, you may simply stick with the Laravel defaults!
114 | |
115 | */
116 |
117 | 'markdown' => [
118 | 'theme' => 'default',
119 |
120 | 'paths' => [
121 | resource_path('views/vendor/mail'),
122 | ],
123 | ],
124 |
125 | ];
126 |
--------------------------------------------------------------------------------
/config/auth.php:
--------------------------------------------------------------------------------
1 | [
17 | 'guard' => 'web',
18 | 'passwords' => 'users',
19 | ],
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Authentication Guards
24 | |--------------------------------------------------------------------------
25 | |
26 | | Next, you may define every authentication guard for your application.
27 | | Of course, a great default configuration has been defined for you
28 | | here which uses session storage and the Eloquent user provider.
29 | |
30 | | All authentication drivers have a user provider. This defines how the
31 | | users are actually retrieved out of your database or other storage
32 | | mechanisms used by this application to persist your user's data.
33 | |
34 | | Supported: "session"
35 | |
36 | */
37 |
38 | 'guards' => [
39 | 'web' => [
40 | 'driver' => 'session',
41 | 'provider' => 'users',
42 | ],
43 | ],
44 |
45 | /*
46 | |--------------------------------------------------------------------------
47 | | User Providers
48 | |--------------------------------------------------------------------------
49 | |
50 | | All authentication drivers have a user provider. This defines how the
51 | | users are actually retrieved out of your database or other storage
52 | | mechanisms used by this application to persist your user's data.
53 | |
54 | | If you have multiple user tables or models you may configure multiple
55 | | sources which represent each model / table. These sources may then
56 | | be assigned to any extra authentication guards you have defined.
57 | |
58 | | Supported: "database", "eloquent"
59 | |
60 | */
61 |
62 | 'providers' => [
63 | 'users' => [
64 | 'driver' => 'eloquent',
65 | 'model' => App\Models\User::class,
66 | ],
67 |
68 | // 'users' => [
69 | // 'driver' => 'database',
70 | // 'table' => 'users',
71 | // ],
72 | ],
73 |
74 | /*
75 | |--------------------------------------------------------------------------
76 | | Resetting Passwords
77 | |--------------------------------------------------------------------------
78 | |
79 | | You may specify multiple password reset configurations if you have more
80 | | than one user table or model in the application and you want to have
81 | | separate password reset settings based on the specific user types.
82 | |
83 | | The expiry time is the number of minutes that each reset token will be
84 | | considered valid. This security feature keeps tokens short-lived so
85 | | they have less time to be guessed. You may change this as needed.
86 | |
87 | | The throttle setting is the number of seconds a user must wait before
88 | | generating more password reset tokens. This prevents the user from
89 | | quickly generating a very large amount of password reset tokens.
90 | |
91 | */
92 |
93 | 'passwords' => [
94 | 'users' => [
95 | 'provider' => 'users',
96 | 'table' => 'password_reset_tokens',
97 | 'expire' => 60,
98 | 'throttle' => 60,
99 | ],
100 | ],
101 |
102 | /*
103 | |--------------------------------------------------------------------------
104 | | Password Confirmation Timeout
105 | |--------------------------------------------------------------------------
106 | |
107 | | Here you may define the amount of seconds before a password confirmation
108 | | times out and the user is prompted to re-enter their password via the
109 | | confirmation screen. By default, the timeout lasts for three hours.
110 | |
111 | */
112 |
113 | 'password_timeout' => 10800,
114 |
115 | ];
116 |
--------------------------------------------------------------------------------
/config/logging.php:
--------------------------------------------------------------------------------
1 | env('LOG_CHANNEL', 'stack'),
22 |
23 | /*
24 | |--------------------------------------------------------------------------
25 | | Deprecations Log Channel
26 | |--------------------------------------------------------------------------
27 | |
28 | | This option controls the log channel that should be used to log warnings
29 | | regarding deprecated PHP and library features. This allows you to get
30 | | your application ready for upcoming major versions of dependencies.
31 | |
32 | */
33 |
34 | 'deprecations' => [
35 | 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
36 | 'trace' => false,
37 | ],
38 |
39 | /*
40 | |--------------------------------------------------------------------------
41 | | Log Channels
42 | |--------------------------------------------------------------------------
43 | |
44 | | Here you may configure the log channels for your application. Out of
45 | | the box, Laravel uses the Monolog PHP logging library. This gives
46 | | you a variety of powerful log handlers / formatters to utilize.
47 | |
48 | | Available Drivers: "single", "daily", "slack", "syslog",
49 | | "errorlog", "monolog",
50 | | "custom", "stack"
51 | |
52 | */
53 |
54 | 'channels' => [
55 | 'stack' => [
56 | 'driver' => 'stack',
57 | 'channels' => ['single'],
58 | 'ignore_exceptions' => false,
59 | ],
60 |
61 | 'single' => [
62 | 'driver' => 'single',
63 | 'path' => storage_path('logs/laravel.log'),
64 | 'level' => env('LOG_LEVEL', 'debug'),
65 | 'replace_placeholders' => true,
66 | ],
67 |
68 | 'daily' => [
69 | 'driver' => 'daily',
70 | 'path' => storage_path('logs/laravel.log'),
71 | 'level' => env('LOG_LEVEL', 'debug'),
72 | 'days' => 14,
73 | 'replace_placeholders' => true,
74 | ],
75 |
76 | 'slack' => [
77 | 'driver' => 'slack',
78 | 'url' => env('LOG_SLACK_WEBHOOK_URL'),
79 | 'username' => 'Laravel Log',
80 | 'emoji' => ':boom:',
81 | 'level' => env('LOG_LEVEL', 'critical'),
82 | 'replace_placeholders' => true,
83 | ],
84 |
85 | 'papertrail' => [
86 | 'driver' => 'monolog',
87 | 'level' => env('LOG_LEVEL', 'debug'),
88 | 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
89 | 'handler_with' => [
90 | 'host' => env('PAPERTRAIL_URL'),
91 | 'port' => env('PAPERTRAIL_PORT'),
92 | 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
93 | ],
94 | 'processors' => [PsrLogMessageProcessor::class],
95 | ],
96 |
97 | 'stderr' => [
98 | 'driver' => 'monolog',
99 | 'level' => env('LOG_LEVEL', 'debug'),
100 | 'handler' => StreamHandler::class,
101 | 'formatter' => env('LOG_STDERR_FORMATTER'),
102 | 'with' => [
103 | 'stream' => 'php://stderr',
104 | ],
105 | 'processors' => [PsrLogMessageProcessor::class],
106 | ],
107 |
108 | 'syslog' => [
109 | 'driver' => 'syslog',
110 | 'level' => env('LOG_LEVEL', 'debug'),
111 | 'facility' => LOG_USER,
112 | 'replace_placeholders' => true,
113 | ],
114 |
115 | 'errorlog' => [
116 | 'driver' => 'errorlog',
117 | 'level' => env('LOG_LEVEL', 'debug'),
118 | 'replace_placeholders' => true,
119 | ],
120 |
121 | 'null' => [
122 | 'driver' => 'monolog',
123 | 'handler' => NullHandler::class,
124 | ],
125 |
126 | 'emergency' => [
127 | 'path' => storage_path('logs/laravel.log'),
128 | ],
129 | ],
130 |
131 | ];
132 |
--------------------------------------------------------------------------------
/.scribe/endpoints/00.yaml:
--------------------------------------------------------------------------------
1 | name: 'Public endpoints'
2 | description: ''
3 | endpoints:
4 | -
5 | httpMethods:
6 | - GET
7 | uri: api/v1/travels
8 | metadata:
9 | groupName: 'Public endpoints'
10 | groupDescription: ''
11 | subgroup: ''
12 | subgroupDescription: ''
13 | title: 'GET Travels'
14 | description: 'Returns paginated list of travels.'
15 | authenticated: false
16 | custom: []
17 | headers:
18 | Content-Type: application/json
19 | Accept: application/json
20 | urlParameters: []
21 | cleanUrlParameters: []
22 | queryParameters:
23 | page:
24 | name: page
25 | description: 'Page number.'
26 | required: false
27 | example: 1
28 | type: integer
29 | custom: []
30 | cleanQueryParameters:
31 | page: 1
32 | bodyParameters: []
33 | cleanBodyParameters: []
34 | fileParameters: []
35 | responses:
36 | -
37 | status: 200
38 | content: '{"data":[{"id":"9958e389-5edf-48eb-8ecd-e058985cf3ce","name":"First travel","slug":"first-travel","description":"Great offer!","number_of_days":5,"number_of_nights":4},{"id":"99643482-4ea8-435e-b7da-e18cbde3d3c7","name":"New travel","slug":"new-travel","description":"The best journey ever!","number_of_days":3,"number_of_nights":2}],"links":{"first":"http://travel-api.test/api/v1/travels?page=1","last":"http://travel-api.test/api/v1/travels?page=1","prev":null,"next":null},"meta":{"current_page":1,"from":1,"last_page":1,"links":[{"url":null,"label":"« Previous","active":false},{"url":"http://travel-api.test/api/v1/travels?page=1","label":"1","active":true},{"url":null,"label":"Next »","active":false}],"path":"http://travel-api.test/api/v1/travels","per_page":15,"to":6,"total":6}}'
39 | headers: []
40 | description: ''
41 | custom: []
42 | responseFields: []
43 | auth: []
44 | controller: null
45 | method: null
46 | route: null
47 | custom: []
48 | -
49 | httpMethods:
50 | - GET
51 | uri: 'api/v1/travels/{travel_slug}/tours'
52 | metadata:
53 | groupName: 'Public endpoints'
54 | groupDescription: ''
55 | subgroup: ''
56 | subgroupDescription: ''
57 | title: 'GET Travel Tours'
58 | description: 'Returns paginated list of tours by travel slug.'
59 | authenticated: false
60 | custom: []
61 | headers:
62 | Content-Type: application/json
63 | Accept: application/json
64 | urlParameters:
65 | travel_slug:
66 | name: travel_slug
67 | description: 'Travel slug.'
68 | required: false
69 | example: '"first-travel"'
70 | type: string
71 | custom: []
72 | cleanUrlParameters:
73 | travel_slug: '"first-travel"'
74 | queryParameters: []
75 | cleanQueryParameters: []
76 | bodyParameters:
77 | priceFrom:
78 | name: priceFrom
79 | description: ''
80 | required: false
81 | example: '"123.45"'
82 | type: number.
83 | custom: []
84 | priceTo:
85 | name: priceTo
86 | description: ''
87 | required: false
88 | example: '"234.56"'
89 | type: number.
90 | custom: []
91 | dateFrom:
92 | name: dateFrom
93 | description: ''
94 | required: false
95 | example: '"2023-06-01"'
96 | type: date.
97 | custom: []
98 | dateTo:
99 | name: dateTo
100 | description: ''
101 | required: false
102 | example: '"2023-07-01"'
103 | type: date.
104 | custom: []
105 | sortBy:
106 | name: sortBy
107 | description: ''
108 | required: false
109 | example: '"price"'
110 | type: string.
111 | custom: []
112 | sortOrder:
113 | name: sortOrder
114 | description: ''
115 | required: false
116 | example: '"asc" or "desc"'
117 | type: string.
118 | custom: []
119 | cleanBodyParameters:
120 | priceFrom: '"123.45"'
121 | priceTo: '"234.56"'
122 | dateFrom: '"2023-06-01"'
123 | dateTo: '"2023-07-01"'
124 | sortBy: '"price"'
125 | sortOrder: '"asc" or "desc"'
126 | fileParameters: []
127 | responses:
128 | -
129 | status: 200
130 | content: '{"data":[{"id":"9958e389-5edf-48eb-8ecd-e058985cf3ce","name":"Tour on Sunday","starting_date":"2023-06-11","ending_date":"2023-06-16","price":"99.99"},{"id":"9958e389-5edf-48eb-8ecd-e058985cf3c2","name":"Tour on Tuesday","starting_date":"2023-06-14","ending_date":"2023-06-19","price":"119.99"},{"id":"9958e389-5edf-48eb-8ecd-e058985cf3c1","name":"Tour on Monday","starting_date":"2023-06-18","ending_date":"2023-06-23","price":"79.99"}],"links":{"first":"http://travel-api.test/api/v1/travels/first-travel/tours?page=1","last":"http://travel-api.test/api/v1/travels/first-travel/tours?page=1","prev":null,"next":null},"meta":{"current_page":1,"from":1,"last_page":1,"links":[{"url":null,"label":"« Previous","active":false},{"url":"http://travel-api.test/api/v1/travels/first-travel/tours?page=1","label":"1","active":true},{"url":null,"label":"Next »","active":false}],"path":"http://travel-api.test/api/v1/travels/first-travel/tours","per_page":15,"to":3,"total":3}}'
131 | headers: []
132 | description: ''
133 | custom: []
134 | responseFields: []
135 | auth: []
136 | controller: null
137 | method: null
138 | route: null
139 | custom: []
140 |
--------------------------------------------------------------------------------
/.scribe/endpoints.cache/00.yaml:
--------------------------------------------------------------------------------
1 | ## Autogenerated by Scribe. DO NOT MODIFY.
2 |
3 | name: 'Public endpoints'
4 | description: ''
5 | endpoints:
6 | -
7 | httpMethods:
8 | - GET
9 | uri: api/v1/travels
10 | metadata:
11 | groupName: 'Public endpoints'
12 | groupDescription: ''
13 | subgroup: ''
14 | subgroupDescription: ''
15 | title: 'GET Travels'
16 | description: 'Returns paginated list of travels.'
17 | authenticated: false
18 | custom: []
19 | headers:
20 | Content-Type: application/json
21 | Accept: application/json
22 | urlParameters: []
23 | cleanUrlParameters: []
24 | queryParameters:
25 | page:
26 | name: page
27 | description: 'Page number.'
28 | required: false
29 | example: 1
30 | type: integer
31 | custom: []
32 | cleanQueryParameters:
33 | page: 1
34 | bodyParameters: []
35 | cleanBodyParameters: []
36 | fileParameters: []
37 | responses:
38 | -
39 | status: 200
40 | content: '{"data":[{"id":"9958e389-5edf-48eb-8ecd-e058985cf3ce","name":"First travel","slug":"first-travel","description":"Great offer!","number_of_days":5,"number_of_nights":4},{"id":"99643482-4ea8-435e-b7da-e18cbde3d3c7","name":"New travel","slug":"new-travel","description":"The best journey ever!","number_of_days":3,"number_of_nights":2}],"links":{"first":"http://travel-api.test/api/v1/travels?page=1","last":"http://travel-api.test/api/v1/travels?page=1","prev":null,"next":null},"meta":{"current_page":1,"from":1,"last_page":1,"links":[{"url":null,"label":"« Previous","active":false},{"url":"http://travel-api.test/api/v1/travels?page=1","label":"1","active":true},{"url":null,"label":"Next »","active":false}],"path":"http://travel-api.test/api/v1/travels","per_page":15,"to":6,"total":6}}'
41 | headers: []
42 | description: ''
43 | custom: []
44 | responseFields: []
45 | auth: []
46 | controller: null
47 | method: null
48 | route: null
49 | custom: []
50 | -
51 | httpMethods:
52 | - GET
53 | uri: 'api/v1/travels/{travel_slug}/tours'
54 | metadata:
55 | groupName: 'Public endpoints'
56 | groupDescription: ''
57 | subgroup: ''
58 | subgroupDescription: ''
59 | title: 'GET Travel Tours'
60 | description: 'Returns paginated list of tours by travel slug.'
61 | authenticated: false
62 | custom: []
63 | headers:
64 | Content-Type: application/json
65 | Accept: application/json
66 | urlParameters:
67 | travel_slug:
68 | name: travel_slug
69 | description: 'Travel slug.'
70 | required: false
71 | example: '"first-travel"'
72 | type: string
73 | custom: []
74 | cleanUrlParameters:
75 | travel_slug: '"first-travel"'
76 | queryParameters: []
77 | cleanQueryParameters: []
78 | bodyParameters:
79 | priceFrom:
80 | name: priceFrom
81 | description: ''
82 | required: false
83 | example: '"123.45"'
84 | type: number.
85 | custom: []
86 | priceTo:
87 | name: priceTo
88 | description: ''
89 | required: false
90 | example: '"234.56"'
91 | type: number.
92 | custom: []
93 | dateFrom:
94 | name: dateFrom
95 | description: ''
96 | required: false
97 | example: '"2023-06-01"'
98 | type: date.
99 | custom: []
100 | dateTo:
101 | name: dateTo
102 | description: ''
103 | required: false
104 | example: '"2023-07-01"'
105 | type: date.
106 | custom: []
107 | sortBy:
108 | name: sortBy
109 | description: ''
110 | required: false
111 | example: '"price"'
112 | type: string.
113 | custom: []
114 | sortOrder:
115 | name: sortOrder
116 | description: ''
117 | required: false
118 | example: '"asc" or "desc"'
119 | type: string.
120 | custom: []
121 | cleanBodyParameters:
122 | priceFrom: '"123.45"'
123 | priceTo: '"234.56"'
124 | dateFrom: '"2023-06-01"'
125 | dateTo: '"2023-07-01"'
126 | sortBy: '"price"'
127 | sortOrder: '"asc" or "desc"'
128 | fileParameters: []
129 | responses:
130 | -
131 | status: 200
132 | content: '{"data":[{"id":"9958e389-5edf-48eb-8ecd-e058985cf3ce","name":"Tour on Sunday","starting_date":"2023-06-11","ending_date":"2023-06-16","price":"99.99"},{"id":"9958e389-5edf-48eb-8ecd-e058985cf3c2","name":"Tour on Tuesday","starting_date":"2023-06-14","ending_date":"2023-06-19","price":"119.99"},{"id":"9958e389-5edf-48eb-8ecd-e058985cf3c1","name":"Tour on Monday","starting_date":"2023-06-18","ending_date":"2023-06-23","price":"79.99"}],"links":{"first":"http://travel-api.test/api/v1/travels/first-travel/tours?page=1","last":"http://travel-api.test/api/v1/travels/first-travel/tours?page=1","prev":null,"next":null},"meta":{"current_page":1,"from":1,"last_page":1,"links":[{"url":null,"label":"« Previous","active":false},{"url":"http://travel-api.test/api/v1/travels/first-travel/tours?page=1","label":"1","active":true},{"url":null,"label":"Next »","active":false}],"path":"http://travel-api.test/api/v1/travels/first-travel/tours","per_page":15,"to":3,"total":3}}'
133 | headers: []
134 | description: ''
135 | custom: []
136 | responseFields: []
137 | auth: []
138 | controller: null
139 | method: null
140 | route: null
141 | custom: []
142 |
--------------------------------------------------------------------------------
/public/docs/js/theme-default-4.21.2.js:
--------------------------------------------------------------------------------
1 | document.addEventListener('DOMContentLoaded', function() {
2 | const updateHash = function (id) {
3 | window.location.hash = `#${id}`;
4 | };
5 |
6 | const navButton = document.getElementById('nav-button');
7 | const menuWrapper = document.querySelector('.tocify-wrapper');
8 | function toggleSidebar(event) {
9 | event.preventDefault();
10 | if (menuWrapper) {
11 | menuWrapper.classList.toggle('open');
12 | navButton.classList.toggle('open');
13 | }
14 | }
15 | function closeSidebar() {
16 | if (menuWrapper) {
17 | menuWrapper.classList.remove('open');
18 | navButton.classList.remove('open');
19 | }
20 | }
21 | navButton.addEventListener('click', toggleSidebar);
22 |
23 | window.hljs.highlightAll();
24 |
25 | const wrapper = document.getElementById('toc');
26 | // https://jets.js.org/
27 | window.jets = new window.Jets({
28 | // *OR - Selects elements whose values contains at least one part of search substring
29 | searchSelector: '*OR',
30 | searchTag: '#input-search',
31 | contentTag: '#toc li',
32 | didSearch: function(term) {
33 | wrapper.classList.toggle('jets-searching', String(term).length > 0)
34 | },
35 | // map these accent keys to plain values
36 | diacriticsMap: {
37 | a: 'ÀÁÂÃÄÅàáâãäåĀāąĄ',
38 | c: 'ÇçćĆčČ',
39 | d: 'đĐďĎ',
40 | e: 'ÈÉÊËèéêëěĚĒēęĘ',
41 | i: 'ÌÍÎÏìíîïĪī',
42 | l: 'łŁ',
43 | n: 'ÑñňŇńŃ',
44 | o: 'ÒÓÔÕÕÖØòóôõöøŌō',
45 | r: 'řŘ',
46 | s: 'ŠšśŚ',
47 | t: 'ťŤ',
48 | u: 'ÙÚÛÜùúûüůŮŪū',
49 | y: 'ŸÿýÝ',
50 | z: 'ŽžżŻźŹ'
51 | }
52 | });
53 |
54 | function hashChange() {
55 | const currentItems = document.querySelectorAll('.tocify-subheader.visible, .tocify-item.tocify-focus');
56 | Array.from(currentItems).forEach((elem) => {
57 | elem.classList.remove('visible', 'tocify-focus');
58 | });
59 |
60 | const currentTag = document.querySelector(`a[href="${window.location.hash}"]`);
61 | if (currentTag) {
62 | const parent = currentTag.closest('.tocify-subheader');
63 | if (parent) {
64 | parent.classList.add('visible');
65 | }
66 |
67 | const siblings = currentTag.closest('.tocify-header');
68 | if (siblings) {
69 | Array.from(siblings.querySelectorAll('.tocify-subheader')).forEach((elem) => {
70 | elem.classList.add('visible');
71 | });
72 | }
73 |
74 | currentTag.parentElement.classList.add('tocify-focus');
75 |
76 | // wait for dom changes to be done
77 | setTimeout(() => {
78 | currentTag.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'center' });
79 | // only close the sidebar on level-2 events
80 | if (currentTag.parentElement.classList.contains('level-2')) {
81 | closeSidebar();
82 | }
83 | }, 1500);
84 | }
85 | }
86 |
87 | let languages = JSON.parse(document.body.getAttribute('data-languages'));
88 | // Support a key => value object where the key is the name, or an array of strings where the value is the name
89 | if (!Array.isArray(languages)) {
90 | languages = Object.values(languages);
91 | }
92 | // if there is no language use the first one
93 | const currentLanguage = window.localStorage.getItem('language') || languages[0];
94 | const languageStyle = document.getElementById('language-style');
95 | const langSelector = document.querySelectorAll('.lang-selector button.lang-button');
96 |
97 | function setActiveLanguage(newLanguage) {
98 | window.localStorage.setItem('language', newLanguage);
99 | if (!languageStyle) {
100 | return;
101 | }
102 |
103 | const newStyle = languages.map((language) => {
104 | return language === newLanguage
105 | // the current one should be visible
106 | ? `body .content .${language}-example pre { display: block; }`
107 | // the inactive one should be hidden
108 | : `body .content .${language}-example pre { display: none; }`;
109 | }).join(`\n`);
110 |
111 | Array.from(langSelector).forEach((elem) => {
112 | elem.classList.toggle('active', elem.getAttribute('data-language-name') === newLanguage);
113 | });
114 |
115 | const activeHash = window.location.hash.slice(1);
116 |
117 | languageStyle.innerHTML = newStyle;
118 |
119 | setTimeout(() => {
120 | updateHash(activeHash);
121 | }, 200);
122 | }
123 |
124 | setActiveLanguage(currentLanguage);
125 |
126 | Array.from(langSelector).forEach((elem) => {
127 | elem.addEventListener('click', () => {
128 | const newLanguage = elem.getAttribute('data-language-name');
129 | setActiveLanguage(newLanguage);
130 | });
131 | });
132 |
133 | window.addEventListener('hashchange', hashChange, false);
134 |
135 | const divs = document.querySelectorAll('.content h1[id], .content h2[id]');
136 |
137 | document.addEventListener('scroll', () => {
138 | divs.forEach(item => {
139 | const rect = item.getBoundingClientRect();
140 | if (rect.top > 0 && rect.top < 150) {
141 | const location = window.location.toString().split('#')[0];
142 | history.replaceState(null, null, location + '#' + item.id);
143 | hashChange();
144 | }
145 | });
146 | });
147 |
148 | hashChange();
149 | });
150 |
--------------------------------------------------------------------------------
/config/database.php:
--------------------------------------------------------------------------------
1 | env('DB_CONNECTION', 'mysql'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Database Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here are each of the database connections setup for your application.
26 | | Of course, examples of configuring each database platform that is
27 | | supported by Laravel is shown below to make development simple.
28 | |
29 | |
30 | | All database work in Laravel is done through the PHP PDO facilities
31 | | so make sure you have the driver for your particular database of
32 | | choice installed on your machine before you begin development.
33 | |
34 | */
35 |
36 | 'connections' => [
37 |
38 | 'sqlite' => [
39 | 'driver' => 'sqlite',
40 | 'url' => env('DATABASE_URL'),
41 | 'database' => env('DB_DATABASE', database_path('database.sqlite')),
42 | 'prefix' => '',
43 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
44 | ],
45 |
46 | 'mysql' => [
47 | 'driver' => 'mysql',
48 | 'url' => env('DATABASE_URL'),
49 | 'host' => env('DB_HOST', '127.0.0.1'),
50 | 'port' => env('DB_PORT', '3306'),
51 | 'database' => env('DB_DATABASE', 'forge'),
52 | 'username' => env('DB_USERNAME', 'forge'),
53 | 'password' => env('DB_PASSWORD', ''),
54 | 'unix_socket' => env('DB_SOCKET', ''),
55 | 'charset' => 'utf8mb4',
56 | 'collation' => 'utf8mb4_unicode_ci',
57 | 'prefix' => '',
58 | 'prefix_indexes' => true,
59 | 'strict' => true,
60 | 'engine' => null,
61 | 'options' => extension_loaded('pdo_mysql') ? array_filter([
62 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
63 | ]) : [],
64 | ],
65 |
66 | 'pgsql' => [
67 | 'driver' => 'pgsql',
68 | 'url' => env('DATABASE_URL'),
69 | 'host' => env('DB_HOST', '127.0.0.1'),
70 | 'port' => env('DB_PORT', '5432'),
71 | 'database' => env('DB_DATABASE', 'forge'),
72 | 'username' => env('DB_USERNAME', 'forge'),
73 | 'password' => env('DB_PASSWORD', ''),
74 | 'charset' => 'utf8',
75 | 'prefix' => '',
76 | 'prefix_indexes' => true,
77 | 'search_path' => 'public',
78 | 'sslmode' => 'prefer',
79 | ],
80 |
81 | 'sqlsrv' => [
82 | 'driver' => 'sqlsrv',
83 | 'url' => env('DATABASE_URL'),
84 | 'host' => env('DB_HOST', 'localhost'),
85 | 'port' => env('DB_PORT', '1433'),
86 | 'database' => env('DB_DATABASE', 'forge'),
87 | 'username' => env('DB_USERNAME', 'forge'),
88 | 'password' => env('DB_PASSWORD', ''),
89 | 'charset' => 'utf8',
90 | 'prefix' => '',
91 | 'prefix_indexes' => true,
92 | // 'encrypt' => env('DB_ENCRYPT', 'yes'),
93 | // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
94 | ],
95 |
96 | ],
97 |
98 | /*
99 | |--------------------------------------------------------------------------
100 | | Migration Repository Table
101 | |--------------------------------------------------------------------------
102 | |
103 | | This table keeps track of all the migrations that have already run for
104 | | your application. Using this information, we can determine which of
105 | | the migrations on disk haven't actually been run in the database.
106 | |
107 | */
108 |
109 | 'migrations' => 'migrations',
110 |
111 | /*
112 | |--------------------------------------------------------------------------
113 | | Redis Databases
114 | |--------------------------------------------------------------------------
115 | |
116 | | Redis is an open source, fast, and advanced key-value store that also
117 | | provides a richer body of commands than a typical key-value system
118 | | such as APC or Memcached. Laravel makes it easy to dig right in.
119 | |
120 | */
121 |
122 | 'redis' => [
123 |
124 | 'client' => env('REDIS_CLIENT', 'phpredis'),
125 |
126 | 'options' => [
127 | 'cluster' => env('REDIS_CLUSTER', 'redis'),
128 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
129 | ],
130 |
131 | 'default' => [
132 | 'url' => env('REDIS_URL'),
133 | 'host' => env('REDIS_HOST', '127.0.0.1'),
134 | 'username' => env('REDIS_USERNAME'),
135 | 'password' => env('REDIS_PASSWORD'),
136 | 'port' => env('REDIS_PORT', '6379'),
137 | 'database' => env('REDIS_DB', '0'),
138 | ],
139 |
140 | 'cache' => [
141 | 'url' => env('REDIS_URL'),
142 | 'host' => env('REDIS_HOST', '127.0.0.1'),
143 | 'username' => env('REDIS_USERNAME'),
144 | 'password' => env('REDIS_PASSWORD'),
145 | 'port' => env('REDIS_PORT', '6379'),
146 | 'database' => env('REDIS_CACHE_DB', '1'),
147 | ],
148 |
149 | ],
150 |
151 | ];
152 |
--------------------------------------------------------------------------------
/config/app.php:
--------------------------------------------------------------------------------
1 | env('APP_NAME', 'Laravel'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Application Environment
24 | |--------------------------------------------------------------------------
25 | |
26 | | This value determines the "environment" your application is currently
27 | | running in. This may determine how you prefer to configure various
28 | | services the application utilizes. Set this in your ".env" file.
29 | |
30 | */
31 |
32 | 'env' => env('APP_ENV', 'production'),
33 |
34 | /*
35 | |--------------------------------------------------------------------------
36 | | Application Debug Mode
37 | |--------------------------------------------------------------------------
38 | |
39 | | When your application is in debug mode, detailed error messages with
40 | | stack traces will be shown on every error that occurs within your
41 | | application. If disabled, a simple generic error page is shown.
42 | |
43 | */
44 |
45 | 'debug' => (bool) env('APP_DEBUG', false),
46 |
47 | /*
48 | |--------------------------------------------------------------------------
49 | | Application URL
50 | |--------------------------------------------------------------------------
51 | |
52 | | This URL is used by the console to properly generate URLs when using
53 | | the Artisan command line tool. You should set this to the root of
54 | | your application so that it is used when running Artisan tasks.
55 | |
56 | */
57 |
58 | 'url' => env('APP_URL', 'http://localhost'),
59 |
60 | 'asset_url' => env('ASSET_URL'),
61 |
62 | /*
63 | |--------------------------------------------------------------------------
64 | | Application Timezone
65 | |--------------------------------------------------------------------------
66 | |
67 | | Here you may specify the default timezone for your application, which
68 | | will be used by the PHP date and date-time functions. We have gone
69 | | ahead and set this to a sensible default for you out of the box.
70 | |
71 | */
72 |
73 | 'timezone' => 'UTC',
74 |
75 | /*
76 | |--------------------------------------------------------------------------
77 | | Application Locale Configuration
78 | |--------------------------------------------------------------------------
79 | |
80 | | The application locale determines the default locale that will be used
81 | | by the translation service provider. You are free to set this value
82 | | to any of the locales which will be supported by the application.
83 | |
84 | */
85 |
86 | 'locale' => 'en',
87 |
88 | /*
89 | |--------------------------------------------------------------------------
90 | | Application Fallback Locale
91 | |--------------------------------------------------------------------------
92 | |
93 | | The fallback locale determines the locale to use when the current one
94 | | is not available. You may change the value to correspond to any of
95 | | the language folders that are provided through your application.
96 | |
97 | */
98 |
99 | 'fallback_locale' => 'en',
100 |
101 | /*
102 | |--------------------------------------------------------------------------
103 | | Faker Locale
104 | |--------------------------------------------------------------------------
105 | |
106 | | This locale will be used by the Faker PHP library when generating fake
107 | | data for your database seeds. For example, this will be used to get
108 | | localized telephone numbers, street address information and more.
109 | |
110 | */
111 |
112 | 'faker_locale' => 'en_US',
113 |
114 | /*
115 | |--------------------------------------------------------------------------
116 | | Encryption Key
117 | |--------------------------------------------------------------------------
118 | |
119 | | This key is used by the Illuminate encrypter service and should be set
120 | | to a random, 32 character string, otherwise these encrypted strings
121 | | will not be safe. Please do this before deploying an application!
122 | |
123 | */
124 |
125 | 'key' => env('APP_KEY'),
126 |
127 | 'cipher' => 'AES-256-CBC',
128 |
129 | /*
130 | |--------------------------------------------------------------------------
131 | | Maintenance Mode Driver
132 | |--------------------------------------------------------------------------
133 | |
134 | | These configuration options determine the driver used to determine and
135 | | manage Laravel's "maintenance mode" status. The "cache" driver will
136 | | allow maintenance mode to be controlled across multiple machines.
137 | |
138 | | Supported drivers: "file", "cache"
139 | |
140 | */
141 |
142 | 'maintenance' => [
143 | 'driver' => 'file',
144 | // 'store' => 'redis',
145 | ],
146 |
147 | /*
148 | |--------------------------------------------------------------------------
149 | | Autoloaded Service Providers
150 | |--------------------------------------------------------------------------
151 | |
152 | | The service providers listed here will be automatically loaded on the
153 | | request to your application. Feel free to add your own services to
154 | | this array to grant expanded functionality to your applications.
155 | |
156 | */
157 |
158 | 'providers' => ServiceProvider::defaultProviders()->merge([
159 | /*
160 | * Package Service Providers...
161 | */
162 |
163 | /*
164 | * Application Service Providers...
165 | */
166 | App\Providers\AppServiceProvider::class,
167 | App\Providers\AuthServiceProvider::class,
168 | // App\Providers\BroadcastServiceProvider::class,
169 | App\Providers\EventServiceProvider::class,
170 | App\Providers\RouteServiceProvider::class,
171 | ])->toArray(),
172 |
173 | /*
174 | |--------------------------------------------------------------------------
175 | | Class Aliases
176 | |--------------------------------------------------------------------------
177 | |
178 | | This array of class aliases will be registered when this application
179 | | is started. However, feel free to register as many as you wish as
180 | | the aliases are "lazy" loaded so they don't hinder performance.
181 | |
182 | */
183 |
184 | 'aliases' => Facade::defaultAliases()->merge([
185 | // 'Example' => App\Facades\Example::class,
186 | ])->toArray(),
187 |
188 | ];
189 |
--------------------------------------------------------------------------------
/public/docs/css/theme-default.print.css:
--------------------------------------------------------------------------------
1 | /* Copied from https://github.com/slatedocs/slate/blob/c4b4c0b8f83e891ca9fab6bbe9a1a88d5fe41292/stylesheets/print.css and unminified */
2 | /*! normalize.css v3.0.2 | MIT License | git.io/normalize */
3 |
4 | html {
5 | font-family: sans-serif;
6 | -ms-text-size-adjust: 100%;
7 | -webkit-text-size-adjust: 100%
8 | }
9 |
10 | body {
11 | margin: 0
12 | }
13 |
14 | article,
15 | aside,
16 | details,
17 | figcaption,
18 | figure,
19 | footer,
20 | header,
21 | hgroup,
22 | main,
23 | menu,
24 | nav,
25 | section,
26 | summary {
27 | display: block
28 | }
29 |
30 | audio,
31 | canvas,
32 | progress,
33 | video {
34 | display: inline-block;
35 | vertical-align: baseline
36 | }
37 |
38 | audio:not([controls]) {
39 | display: none;
40 | height: 0
41 | }
42 |
43 | [hidden],
44 | template {
45 | display: none
46 | }
47 |
48 | a {
49 | background-color: transparent
50 | }
51 |
52 | a:active,
53 | a:hover {
54 | outline: 0
55 | }
56 |
57 | abbr[title] {
58 | border-bottom: 1px dotted
59 | }
60 |
61 | b,
62 | strong {
63 | font-weight: bold
64 | }
65 |
66 | dfn {
67 | font-style: italic
68 | }
69 |
70 | h1 {
71 | font-size: 2em;
72 | margin: 0.67em 0
73 | }
74 |
75 | mark {
76 | background: #ff0;
77 | color: #000
78 | }
79 |
80 | small {
81 | font-size: 80%
82 | }
83 |
84 | sub,
85 | sup {
86 | font-size: 75%;
87 | line-height: 0;
88 | position: relative;
89 | vertical-align: baseline
90 | }
91 |
92 | sup {
93 | top: -0.5em
94 | }
95 |
96 | sub {
97 | bottom: -0.25em
98 | }
99 |
100 | img {
101 | border: 0
102 | }
103 |
104 | svg:not(:root) {
105 | overflow: hidden
106 | }
107 |
108 | figure {
109 | margin: 1em 40px
110 | }
111 |
112 | hr {
113 | box-sizing: content-box;
114 | height: 0
115 | }
116 |
117 | pre {
118 | overflow: auto
119 | }
120 |
121 | code,
122 | kbd,
123 | pre,
124 | samp {
125 | font-family: monospace, monospace;
126 | font-size: 1em
127 | }
128 |
129 | button,
130 | input,
131 | optgroup,
132 | select,
133 | textarea {
134 | color: inherit;
135 | font: inherit;
136 | margin: 0
137 | }
138 |
139 | button {
140 | overflow: visible
141 | }
142 |
143 | button,
144 | select {
145 | text-transform: none
146 | }
147 |
148 | button,
149 | html input[type="button"],
150 | input[type="reset"],
151 | input[type="submit"] {
152 | -webkit-appearance: button;
153 | cursor: pointer
154 | }
155 |
156 | button[disabled],
157 | html input[disabled] {
158 | cursor: default
159 | }
160 |
161 | button::-moz-focus-inner,
162 | input::-moz-focus-inner {
163 | border: 0;
164 | padding: 0
165 | }
166 |
167 | input {
168 | line-height: normal
169 | }
170 |
171 | input[type="checkbox"],
172 | input[type="radio"] {
173 | box-sizing: border-box;
174 | padding: 0
175 | }
176 |
177 | input[type="number"]::-webkit-inner-spin-button,
178 | input[type="number"]::-webkit-outer-spin-button {
179 | height: auto
180 | }
181 |
182 | input[type="search"] {
183 | -webkit-appearance: textfield;
184 | box-sizing: content-box
185 | }
186 |
187 | input[type="search"]::-webkit-search-cancel-button,
188 | input[type="search"]::-webkit-search-decoration {
189 | -webkit-appearance: none
190 | }
191 |
192 | fieldset {
193 | border: 1px solid #c0c0c0;
194 | margin: 0 2px;
195 | padding: 0.35em 0.625em 0.75em
196 | }
197 |
198 | legend {
199 | border: 0;
200 | padding: 0
201 | }
202 |
203 | textarea {
204 | overflow: auto
205 | }
206 |
207 | optgroup {
208 | font-weight: bold
209 | }
210 |
211 | table {
212 | border-collapse: collapse;
213 | border-spacing: 0
214 | }
215 |
216 | td,
217 | th {
218 | padding: 0
219 | }
220 |
221 | .content h1,
222 | .content h2,
223 | .content h3,
224 | .content h4,
225 | body {
226 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
227 | font-size: 14px
228 | }
229 |
230 | .content h1,
231 | .content h2,
232 | .content h3,
233 | .content h4 {
234 | font-weight: bold
235 | }
236 |
237 | .content pre,
238 | .content code {
239 | font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, serif;
240 | font-size: 12px;
241 | line-height: 1.5
242 | }
243 |
244 | .content pre,
245 | .content code {
246 | word-break: break-all;
247 | -webkit-hyphens: auto;
248 | -ms-hyphens: auto;
249 | hyphens: auto
250 | }
251 |
252 | @font-face {
253 | font-family: 'slate';
254 | src: url(../fonts/slate.eot?-syv14m);
255 | src: url(../fonts/slate.eot?#iefix-syv14m) format("embedded-opentype"), url(../fonts/slate.woff2?-syv14m) format("woff2"), url(../fonts/slate.woff?-syv14m) format("woff"), url(../fonts/slate.ttf?-syv14m) format("truetype"), url(../fonts/slate.svg?-syv14m#slate) format("svg");
256 | font-weight: normal;
257 | font-style: normal
258 | }
259 |
260 | .content aside.warning:before,
261 | .content aside.notice:before,
262 | .content aside.success:before {
263 | font-family: 'slate';
264 | speak: none;
265 | font-style: normal;
266 | font-weight: normal;
267 | font-variant: normal;
268 | text-transform: none;
269 | line-height: 1
270 | }
271 |
272 | .content aside.warning:before {
273 | content: "\e600"
274 | }
275 |
276 | .content aside.notice:before {
277 | content: "\e602"
278 | }
279 |
280 | .content aside.success:before {
281 | content: "\e606"
282 | }
283 |
284 | .tocify,
285 | .toc-footer,
286 | .lang-selector,
287 | .search,
288 | #nav-button {
289 | display: none
290 | }
291 |
292 | .tocify-wrapper>img {
293 | margin: 0 auto;
294 | display: block
295 | }
296 |
297 | .content {
298 | font-size: 12px
299 | }
300 |
301 | .content pre,
302 | .content code {
303 | border: 1px solid #999;
304 | border-radius: 5px;
305 | font-size: 0.8em
306 | }
307 |
308 | .content pre code {
309 | border: 0
310 | }
311 |
312 | .content pre {
313 | padding: 1.3em
314 | }
315 |
316 | .content code {
317 | padding: 0.2em
318 | }
319 |
320 | .content table {
321 | border: 1px solid #999
322 | }
323 |
324 | .content table tr {
325 | border-bottom: 1px solid #999
326 | }
327 |
328 | .content table td,
329 | .content table th {
330 | padding: 0.7em
331 | }
332 |
333 | .content p {
334 | line-height: 1.5
335 | }
336 |
337 | .content a {
338 | text-decoration: none;
339 | color: #000
340 | }
341 |
342 | .content h1 {
343 | font-size: 2.5em;
344 | padding-top: 0.5em;
345 | padding-bottom: 0.5em;
346 | margin-top: 1em;
347 | margin-bottom: 21px;
348 | border: 2px solid #ccc;
349 | border-width: 2px 0;
350 | text-align: center
351 | }
352 |
353 | .content h2 {
354 | font-size: 1.8em;
355 | margin-top: 2em;
356 | border-top: 2px solid #ccc;
357 | padding-top: 0.8em
358 | }
359 |
360 | .content h1+h2,
361 | .content h1+div+h2 {
362 | border-top: none;
363 | padding-top: 0;
364 | margin-top: 0
365 | }
366 |
367 | .content h3,
368 | .content h4 {
369 | font-size: 0.8em;
370 | margin-top: 1.5em;
371 | margin-bottom: 0.8em;
372 | text-transform: uppercase
373 | }
374 |
375 | .content h5,
376 | .content h6 {
377 | text-transform: uppercase
378 | }
379 |
380 | .content aside {
381 | padding: 1em;
382 | border: 1px solid #ccc;
383 | border-radius: 5px;
384 | margin-top: 1.5em;
385 | margin-bottom: 1.5em;
386 | line-height: 1.6
387 | }
388 |
389 | .content aside:before {
390 | vertical-align: middle;
391 | padding-right: 0.5em;
392 | font-size: 14px
393 | }
394 |
--------------------------------------------------------------------------------
/config/session.php:
--------------------------------------------------------------------------------
1 | env('SESSION_DRIVER', 'file'),
22 |
23 | /*
24 | |--------------------------------------------------------------------------
25 | | Session Lifetime
26 | |--------------------------------------------------------------------------
27 | |
28 | | Here you may specify the number of minutes that you wish the session
29 | | to be allowed to remain idle before it expires. If you want them
30 | | to immediately expire on the browser closing, set that option.
31 | |
32 | */
33 |
34 | 'lifetime' => env('SESSION_LIFETIME', 120),
35 |
36 | 'expire_on_close' => false,
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Session Encryption
41 | |--------------------------------------------------------------------------
42 | |
43 | | This option allows you to easily specify that all of your session data
44 | | should be encrypted before it is stored. All encryption will be run
45 | | automatically by Laravel and you can use the Session like normal.
46 | |
47 | */
48 |
49 | 'encrypt' => false,
50 |
51 | /*
52 | |--------------------------------------------------------------------------
53 | | Session File Location
54 | |--------------------------------------------------------------------------
55 | |
56 | | When using the native session driver, we need a location where session
57 | | files may be stored. A default has been set for you but a different
58 | | location may be specified. This is only needed for file sessions.
59 | |
60 | */
61 |
62 | 'files' => storage_path('framework/sessions'),
63 |
64 | /*
65 | |--------------------------------------------------------------------------
66 | | Session Database Connection
67 | |--------------------------------------------------------------------------
68 | |
69 | | When using the "database" or "redis" session drivers, you may specify a
70 | | connection that should be used to manage these sessions. This should
71 | | correspond to a connection in your database configuration options.
72 | |
73 | */
74 |
75 | 'connection' => env('SESSION_CONNECTION'),
76 |
77 | /*
78 | |--------------------------------------------------------------------------
79 | | Session Database Table
80 | |--------------------------------------------------------------------------
81 | |
82 | | When using the "database" session driver, you may specify the table we
83 | | should use to manage the sessions. Of course, a sensible default is
84 | | provided for you; however, you are free to change this as needed.
85 | |
86 | */
87 |
88 | 'table' => 'sessions',
89 |
90 | /*
91 | |--------------------------------------------------------------------------
92 | | Session Cache Store
93 | |--------------------------------------------------------------------------
94 | |
95 | | While using one of the framework's cache driven session backends you may
96 | | list a cache store that should be used for these sessions. This value
97 | | must match with one of the application's configured cache "stores".
98 | |
99 | | Affects: "apc", "dynamodb", "memcached", "redis"
100 | |
101 | */
102 |
103 | 'store' => env('SESSION_STORE'),
104 |
105 | /*
106 | |--------------------------------------------------------------------------
107 | | Session Sweeping Lottery
108 | |--------------------------------------------------------------------------
109 | |
110 | | Some session drivers must manually sweep their storage location to get
111 | | rid of old sessions from storage. Here are the chances that it will
112 | | happen on a given request. By default, the odds are 2 out of 100.
113 | |
114 | */
115 |
116 | 'lottery' => [2, 100],
117 |
118 | /*
119 | |--------------------------------------------------------------------------
120 | | Session Cookie Name
121 | |--------------------------------------------------------------------------
122 | |
123 | | Here you may change the name of the cookie used to identify a session
124 | | instance by ID. The name specified here will get used every time a
125 | | new session cookie is created by the framework for every driver.
126 | |
127 | */
128 |
129 | 'cookie' => env(
130 | 'SESSION_COOKIE',
131 | Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
132 | ),
133 |
134 | /*
135 | |--------------------------------------------------------------------------
136 | | Session Cookie Path
137 | |--------------------------------------------------------------------------
138 | |
139 | | The session cookie path determines the path for which the cookie will
140 | | be regarded as available. Typically, this will be the root path of
141 | | your application but you are free to change this when necessary.
142 | |
143 | */
144 |
145 | 'path' => '/',
146 |
147 | /*
148 | |--------------------------------------------------------------------------
149 | | Session Cookie Domain
150 | |--------------------------------------------------------------------------
151 | |
152 | | Here you may change the domain of the cookie used to identify a session
153 | | in your application. This will determine which domains the cookie is
154 | | available to in your application. A sensible default has been set.
155 | |
156 | */
157 |
158 | 'domain' => env('SESSION_DOMAIN'),
159 |
160 | /*
161 | |--------------------------------------------------------------------------
162 | | HTTPS Only Cookies
163 | |--------------------------------------------------------------------------
164 | |
165 | | By setting this option to true, session cookies will only be sent back
166 | | to the server if the browser has a HTTPS connection. This will keep
167 | | the cookie from being sent to you when it can't be done securely.
168 | |
169 | */
170 |
171 | 'secure' => env('SESSION_SECURE_COOKIE'),
172 |
173 | /*
174 | |--------------------------------------------------------------------------
175 | | HTTP Access Only
176 | |--------------------------------------------------------------------------
177 | |
178 | | Setting this value to true will prevent JavaScript from accessing the
179 | | value of the cookie and the cookie will only be accessible through
180 | | the HTTP protocol. You are free to modify this option if needed.
181 | |
182 | */
183 |
184 | 'http_only' => true,
185 |
186 | /*
187 | |--------------------------------------------------------------------------
188 | | Same-Site Cookies
189 | |--------------------------------------------------------------------------
190 | |
191 | | This option determines how your cookies behave when cross-site requests
192 | | take place, and can be used to mitigate CSRF attacks. By default, we
193 | | will set this value to "lax" since this is a secure default value.
194 | |
195 | | Supported: "lax", "strict", "none", null
196 | |
197 | */
198 |
199 | 'same_site' => 'lax',
200 |
201 | ];
202 |
--------------------------------------------------------------------------------
/.scribe/endpoints/01.yaml:
--------------------------------------------------------------------------------
1 | name: 'Admin endpoints'
2 | description: ''
3 | endpoints:
4 | -
5 | httpMethods:
6 | - POST
7 | uri: api/v1/admin/travels
8 | metadata:
9 | groupName: 'Admin endpoints'
10 | groupDescription: ''
11 | subgroup: ''
12 | subgroupDescription: ''
13 | title: 'POST Travel'
14 | description: 'Creates a new Travel record.'
15 | authenticated: true
16 | custom: []
17 | headers:
18 | Authorization: 'Bearer {YOUR_AUTH_KEY}'
19 | Content-Type: application/json
20 | Accept: application/json
21 | urlParameters: []
22 | cleanUrlParameters: []
23 | queryParameters: []
24 | cleanQueryParameters: []
25 | bodyParameters:
26 | is_public:
27 | name: is_public
28 | description: ''
29 | required: false
30 | example: false
31 | type: boolean
32 | custom: []
33 | name:
34 | name: name
35 | description: ''
36 | required: true
37 | example: rerum
38 | type: string
39 | custom: []
40 | description:
41 | name: description
42 | description: ''
43 | required: true
44 | example: autem
45 | type: string
46 | custom: []
47 | number_of_days:
48 | name: number_of_days
49 | description: ''
50 | required: true
51 | example: 1
52 | type: integer
53 | custom: []
54 | cleanBodyParameters:
55 | is_public: false
56 | name: rerum
57 | description: autem
58 | number_of_days: 1
59 | fileParameters: []
60 | responses:
61 | -
62 | status: 200
63 | content: '{"data":{"id":"996a36ca-2693-4901-9c55-7136e68d81d5","name":"My new travel 234","slug":"my-new-travel-234","description":"The second best journey ever!","number_of_days":"4","number_of_nights":3}}'
64 | headers: []
65 | description: ''
66 | custom: []
67 | -
68 | status: 422
69 | content: '{"message":"The name has already been taken.","errors":{"name":["The name has already been taken."]}}'
70 | headers: []
71 | description: ''
72 | custom: []
73 | responseFields: []
74 | auth:
75 | - headers
76 | - Authorization
77 | - 'Bearer e61bP56cfhg8V3DvaEkZd4a'
78 | controller: null
79 | method: null
80 | route: null
81 | custom: []
82 | -
83 | httpMethods:
84 | - POST
85 | uri: 'api/v1/admin/travels/{travel_id}/tours'
86 | metadata:
87 | groupName: 'Admin endpoints'
88 | groupDescription: ''
89 | subgroup: ''
90 | subgroupDescription: ''
91 | title: 'POST Tour'
92 | description: 'Creates a new Tour record.'
93 | authenticated: true
94 | custom: []
95 | headers:
96 | Authorization: 'Bearer {YOUR_AUTH_KEY}'
97 | Content-Type: application/json
98 | Accept: application/json
99 | urlParameters:
100 | travel_id:
101 | name: travel_id
102 | description: 'The ID of the travel.'
103 | required: true
104 | example: 9958e389-5edf-48eb-8ecd-e058985cf3ce
105 | type: string
106 | custom: []
107 | cleanUrlParameters:
108 | travel_id: 9958e389-5edf-48eb-8ecd-e058985cf3ce
109 | queryParameters: []
110 | cleanQueryParameters: []
111 | bodyParameters:
112 | name:
113 | name: name
114 | description: ''
115 | required: true
116 | example: dolores
117 | type: string
118 | custom: []
119 | starting_date:
120 | name: starting_date
121 | description: 'Must be a valid date.'
122 | required: true
123 | example: '2023-06-15T08:01:10'
124 | type: string
125 | custom: []
126 | ending_date:
127 | name: ending_date
128 | description: 'Must be a valid date. Must be a date after starting_date.'
129 | required: true
130 | example: '2071-08-28'
131 | type: string
132 | custom: []
133 | price:
134 | name: price
135 | description: ''
136 | required: true
137 | example: 475.0
138 | type: number
139 | custom: []
140 | cleanBodyParameters:
141 | name: dolores
142 | starting_date: '2023-06-15T08:01:10'
143 | ending_date: '2071-08-28'
144 | price: 475.0
145 | fileParameters: []
146 | responses:
147 | -
148 | status: 200
149 | content: '{"data":{"id":"996a381e-64ca-46ba-8b51-f8279d5529ad","name":"Tour 1","starting_date":"2023-06-15","ending_date":"2023-06-20","price":"99.99"}}'
150 | headers: []
151 | description: ''
152 | custom: []
153 | -
154 | status: 422
155 | content: '{"message":"The name has already been taken.","errors":{"name":["The name has already been taken."]}}'
156 | headers: []
157 | description: ''
158 | custom: []
159 | responseFields: []
160 | auth:
161 | - headers
162 | - Authorization
163 | - 'Bearer P8gbZa6E6e5ck3vhd1afVD4'
164 | controller: null
165 | method: null
166 | route: null
167 | custom: []
168 | -
169 | httpMethods:
170 | - PUT
171 | uri: 'api/v1/admin/travels/{travel_id}'
172 | metadata:
173 | groupName: 'Admin endpoints'
174 | groupDescription: ''
175 | subgroup: ''
176 | subgroupDescription: ''
177 | title: 'PUT Travel'
178 | description: 'Updates new Travel record.'
179 | authenticated: true
180 | custom: []
181 | headers:
182 | Authorization: 'Bearer {YOUR_AUTH_KEY}'
183 | Content-Type: application/json
184 | Accept: application/json
185 | urlParameters:
186 | travel_id:
187 | name: travel_id
188 | description: 'The ID of the travel.'
189 | required: true
190 | example: 9958e389-5edf-48eb-8ecd-e058985cf3ce
191 | type: string
192 | custom: []
193 | cleanUrlParameters:
194 | travel_id: 9958e389-5edf-48eb-8ecd-e058985cf3ce
195 | queryParameters: []
196 | cleanQueryParameters: []
197 | bodyParameters:
198 | is_public:
199 | name: is_public
200 | description: ''
201 | required: false
202 | example: false
203 | type: boolean
204 | custom: []
205 | name:
206 | name: name
207 | description: ''
208 | required: true
209 | example: iure
210 | type: string
211 | custom: []
212 | description:
213 | name: description
214 | description: ''
215 | required: true
216 | example: quaerat
217 | type: string
218 | custom: []
219 | number_of_days:
220 | name: number_of_days
221 | description: ''
222 | required: true
223 | example: 16
224 | type: integer
225 | custom: []
226 | cleanBodyParameters:
227 | is_public: false
228 | name: iure
229 | description: quaerat
230 | number_of_days: 16
231 | fileParameters: []
232 | responses:
233 | -
234 | status: 200
235 | content: '{"data":{"id":"996a36ca-2693-4901-9c55-7136e68d81d5","name":"My new travel 234","slug":"my-new-travel-234","description":"The second best journey ever!","number_of_days":"4","number_of_nights":3}}'
236 | headers: []
237 | description: ''
238 | custom: []
239 | -
240 | status: 422
241 | content: '{"message":"The name has already been taken.","errors":{"name":["The name has already been taken."]}}'
242 | headers: []
243 | description: ''
244 | custom: []
245 | responseFields: []
246 | auth:
247 | - headers
248 | - Authorization
249 | - 'Bearer 6v3h8EkaZgbaP4cDfde156V'
250 | controller: null
251 | method: null
252 | route: null
253 | custom: []
254 |
--------------------------------------------------------------------------------
/.scribe/endpoints.cache/01.yaml:
--------------------------------------------------------------------------------
1 | ## Autogenerated by Scribe. DO NOT MODIFY.
2 |
3 | name: 'Admin endpoints'
4 | description: ''
5 | endpoints:
6 | -
7 | httpMethods:
8 | - POST
9 | uri: api/v1/admin/travels
10 | metadata:
11 | groupName: 'Admin endpoints'
12 | groupDescription: ''
13 | subgroup: ''
14 | subgroupDescription: ''
15 | title: 'POST Travel'
16 | description: 'Creates a new Travel record.'
17 | authenticated: true
18 | custom: []
19 | headers:
20 | Authorization: 'Bearer {YOUR_AUTH_KEY}'
21 | Content-Type: application/json
22 | Accept: application/json
23 | urlParameters: []
24 | cleanUrlParameters: []
25 | queryParameters: []
26 | cleanQueryParameters: []
27 | bodyParameters:
28 | is_public:
29 | name: is_public
30 | description: ''
31 | required: false
32 | example: false
33 | type: boolean
34 | custom: []
35 | name:
36 | name: name
37 | description: ''
38 | required: true
39 | example: rerum
40 | type: string
41 | custom: []
42 | description:
43 | name: description
44 | description: ''
45 | required: true
46 | example: autem
47 | type: string
48 | custom: []
49 | number_of_days:
50 | name: number_of_days
51 | description: ''
52 | required: true
53 | example: 1
54 | type: integer
55 | custom: []
56 | cleanBodyParameters:
57 | is_public: false
58 | name: rerum
59 | description: autem
60 | number_of_days: 1
61 | fileParameters: []
62 | responses:
63 | -
64 | status: 200
65 | content: '{"data":{"id":"996a36ca-2693-4901-9c55-7136e68d81d5","name":"My new travel 234","slug":"my-new-travel-234","description":"The second best journey ever!","number_of_days":"4","number_of_nights":3}}'
66 | headers: []
67 | description: ''
68 | custom: []
69 | -
70 | status: 422
71 | content: '{"message":"The name has already been taken.","errors":{"name":["The name has already been taken."]}}'
72 | headers: []
73 | description: ''
74 | custom: []
75 | responseFields: []
76 | auth:
77 | - headers
78 | - Authorization
79 | - 'Bearer e61bP56cfhg8V3DvaEkZd4a'
80 | controller: null
81 | method: null
82 | route: null
83 | custom: []
84 | -
85 | httpMethods:
86 | - POST
87 | uri: 'api/v1/admin/travels/{travel_id}/tours'
88 | metadata:
89 | groupName: 'Admin endpoints'
90 | groupDescription: ''
91 | subgroup: ''
92 | subgroupDescription: ''
93 | title: 'POST Tour'
94 | description: 'Creates a new Tour record.'
95 | authenticated: true
96 | custom: []
97 | headers:
98 | Authorization: 'Bearer {YOUR_AUTH_KEY}'
99 | Content-Type: application/json
100 | Accept: application/json
101 | urlParameters:
102 | travel_id:
103 | name: travel_id
104 | description: 'The ID of the travel.'
105 | required: true
106 | example: 9958e389-5edf-48eb-8ecd-e058985cf3ce
107 | type: string
108 | custom: []
109 | cleanUrlParameters:
110 | travel_id: 9958e389-5edf-48eb-8ecd-e058985cf3ce
111 | queryParameters: []
112 | cleanQueryParameters: []
113 | bodyParameters:
114 | name:
115 | name: name
116 | description: ''
117 | required: true
118 | example: dolores
119 | type: string
120 | custom: []
121 | starting_date:
122 | name: starting_date
123 | description: 'Must be a valid date.'
124 | required: true
125 | example: '2023-06-15T08:01:10'
126 | type: string
127 | custom: []
128 | ending_date:
129 | name: ending_date
130 | description: 'Must be a valid date. Must be a date after starting_date.'
131 | required: true
132 | example: '2071-08-28'
133 | type: string
134 | custom: []
135 | price:
136 | name: price
137 | description: ''
138 | required: true
139 | example: 475.0
140 | type: number
141 | custom: []
142 | cleanBodyParameters:
143 | name: dolores
144 | starting_date: '2023-06-15T08:01:10'
145 | ending_date: '2071-08-28'
146 | price: 475.0
147 | fileParameters: []
148 | responses:
149 | -
150 | status: 200
151 | content: '{"data":{"id":"996a381e-64ca-46ba-8b51-f8279d5529ad","name":"Tour 1","starting_date":"2023-06-15","ending_date":"2023-06-20","price":"99.99"}}'
152 | headers: []
153 | description: ''
154 | custom: []
155 | -
156 | status: 422
157 | content: '{"message":"The name has already been taken.","errors":{"name":["The name has already been taken."]}}'
158 | headers: []
159 | description: ''
160 | custom: []
161 | responseFields: []
162 | auth:
163 | - headers
164 | - Authorization
165 | - 'Bearer P8gbZa6E6e5ck3vhd1afVD4'
166 | controller: null
167 | method: null
168 | route: null
169 | custom: []
170 | -
171 | httpMethods:
172 | - PUT
173 | uri: 'api/v1/admin/travels/{travel_id}'
174 | metadata:
175 | groupName: 'Admin endpoints'
176 | groupDescription: ''
177 | subgroup: ''
178 | subgroupDescription: ''
179 | title: 'PUT Travel'
180 | description: 'Updates new Travel record.'
181 | authenticated: true
182 | custom: []
183 | headers:
184 | Authorization: 'Bearer {YOUR_AUTH_KEY}'
185 | Content-Type: application/json
186 | Accept: application/json
187 | urlParameters:
188 | travel_id:
189 | name: travel_id
190 | description: 'The ID of the travel.'
191 | required: true
192 | example: 9958e389-5edf-48eb-8ecd-e058985cf3ce
193 | type: string
194 | custom: []
195 | cleanUrlParameters:
196 | travel_id: 9958e389-5edf-48eb-8ecd-e058985cf3ce
197 | queryParameters: []
198 | cleanQueryParameters: []
199 | bodyParameters:
200 | is_public:
201 | name: is_public
202 | description: ''
203 | required: false
204 | example: false
205 | type: boolean
206 | custom: []
207 | name:
208 | name: name
209 | description: ''
210 | required: true
211 | example: iure
212 | type: string
213 | custom: []
214 | description:
215 | name: description
216 | description: ''
217 | required: true
218 | example: quaerat
219 | type: string
220 | custom: []
221 | number_of_days:
222 | name: number_of_days
223 | description: ''
224 | required: true
225 | example: 16
226 | type: integer
227 | custom: []
228 | cleanBodyParameters:
229 | is_public: false
230 | name: iure
231 | description: quaerat
232 | number_of_days: 16
233 | fileParameters: []
234 | responses:
235 | -
236 | status: 200
237 | content: '{"data":{"id":"996a36ca-2693-4901-9c55-7136e68d81d5","name":"My new travel 234","slug":"my-new-travel-234","description":"The second best journey ever!","number_of_days":"4","number_of_nights":3}}'
238 | headers: []
239 | description: ''
240 | custom: []
241 | -
242 | status: 422
243 | content: '{"message":"The name has already been taken.","errors":{"name":["The name has already been taken."]}}'
244 | headers: []
245 | description: ''
246 | custom: []
247 | responseFields: []
248 | auth:
249 | - headers
250 | - Authorization
251 | - 'Bearer 6v3h8EkaZgbaP4cDfde156V'
252 | controller: null
253 | method: null
254 | route: null
255 | custom: []
256 |
--------------------------------------------------------------------------------
/tests/Feature/ToursListTest.php:
--------------------------------------------------------------------------------
1 | create();
17 | $tour = Tour::factory()->create(['travel_id' => $travel->id]);
18 |
19 | $response = $this->get('/api/v1/travels/'.$travel->slug.'/tours');
20 |
21 | $response->assertStatus(200);
22 | $response->assertJsonCount(1, 'data');
23 | $response->assertJsonFragment(['id' => $tour->id]);
24 | }
25 |
26 | public function test_tour_price_is_shown_correctly(): void
27 | {
28 | $travel = Travel::factory()->create();
29 | Tour::factory()->create([
30 | 'travel_id' => $travel->id,
31 | 'price' => 123.45,
32 | ]);
33 |
34 | $response = $this->get('/api/v1/travels/'.$travel->slug.'/tours');
35 |
36 | $response->assertStatus(200);
37 | $response->assertJsonCount(1, 'data');
38 | $response->assertJsonFragment(['price' => '123.45']);
39 | }
40 |
41 | public function test_tours_list_returns_pagination(): void
42 | {
43 | $travel = Travel::factory()->create();
44 | Tour::factory(16)->create(['travel_id' => $travel->id]);
45 |
46 | $response = $this->get('/api/v1/travels/'.$travel->slug.'/tours');
47 |
48 | $response->assertStatus(200);
49 | $response->assertJsonCount(15, 'data');
50 | $response->assertJsonPath('meta.last_page', 2);
51 | }
52 |
53 | public function test_tours_list_sorts_by_starting_date_correctly(): void
54 | {
55 | $travel = Travel::factory()->create();
56 | $laterTour = Tour::factory()->create([
57 | 'travel_id' => $travel->id,
58 | 'starting_date' => now()->addDays(2),
59 | 'ending_date' => now()->addDays(3),
60 | ]);
61 | $earlierTour = Tour::factory()->create([
62 | 'travel_id' => $travel->id,
63 | 'starting_date' => now(),
64 | 'ending_date' => now()->addDays(1),
65 | ]);
66 |
67 | $response = $this->get('/api/v1/travels/'.$travel->slug.'/tours');
68 |
69 | $response->assertStatus(200);
70 | $response->assertJsonPath('data.0.id', $earlierTour->id);
71 | $response->assertJsonPath('data.1.id', $laterTour->id);
72 | }
73 |
74 | public function test_tours_list_sorts_by_price_correctly(): void
75 | {
76 | $travel = Travel::factory()->create();
77 | $expensiveTour = Tour::factory()->create([
78 | 'travel_id' => $travel->id,
79 | 'price' => 200,
80 | ]);
81 | $cheapLaterTour = Tour::factory()->create([
82 | 'travel_id' => $travel->id,
83 | 'price' => 100,
84 | 'starting_date' => now()->addDays(2),
85 | 'ending_date' => now()->addDays(3),
86 | ]);
87 | $cheapEarlierTour = Tour::factory()->create([
88 | 'travel_id' => $travel->id,
89 | 'price' => 100,
90 | 'starting_date' => now(),
91 | 'ending_date' => now()->addDays(1),
92 | ]);
93 |
94 | $response = $this->get('/api/v1/travels/'.$travel->slug.'/tours?sortBy=price&sortOrder=asc');
95 |
96 | $response->assertStatus(200);
97 | $response->assertJsonPath('data.0.id', $cheapEarlierTour->id);
98 | $response->assertJsonPath('data.1.id', $cheapLaterTour->id);
99 | $response->assertJsonPath('data.2.id', $expensiveTour->id);
100 | }
101 |
102 | public function test_tours_list_filters_by_price_correctly(): void
103 | {
104 | $travel = Travel::factory()->create();
105 | $expensiveTour = Tour::factory()->create([
106 | 'travel_id' => $travel->id,
107 | 'price' => 200,
108 | ]);
109 | $cheapTour = Tour::factory()->create([
110 | 'travel_id' => $travel->id,
111 | 'price' => 100,
112 | ]);
113 |
114 | $endpoint = '/api/v1/travels/'.$travel->slug.'/tours';
115 |
116 | $response = $this->get($endpoint.'?priceFrom=100');
117 | $response->assertJsonCount(2, 'data');
118 | $response->assertJsonFragment(['id' => $cheapTour->id]);
119 | $response->assertJsonFragment(['id' => $expensiveTour->id]);
120 |
121 | $response = $this->get($endpoint.'?priceFrom=150');
122 | $response->assertJsonCount(1, 'data');
123 | $response->assertJsonMissing(['id' => $cheapTour->id]);
124 | $response->assertJsonFragment(['id' => $expensiveTour->id]);
125 |
126 | $response = $this->get($endpoint.'?priceFrom=250');
127 | $response->assertJsonCount(0, 'data');
128 |
129 | $response = $this->get($endpoint.'?priceTo=200');
130 | $response->assertJsonCount(2, 'data');
131 | $response->assertJsonFragment(['id' => $cheapTour->id]);
132 | $response->assertJsonFragment(['id' => $expensiveTour->id]);
133 |
134 | $response = $this->get($endpoint.'?priceTo=150');
135 | $response->assertJsonCount(1, 'data');
136 | $response->assertJsonMissing(['id' => $expensiveTour->id]);
137 | $response->assertJsonFragment(['id' => $cheapTour->id]);
138 |
139 | $response = $this->get($endpoint.'?priceTo=50');
140 | $response->assertJsonCount(0, 'data');
141 |
142 | $response = $this->get($endpoint.'?priceFrom=150&priceTo=250');
143 | $response->assertJsonCount(1, 'data');
144 | $response->assertJsonMissing(['id' => $cheapTour->id]);
145 | $response->assertJsonFragment(['id' => $expensiveTour->id]);
146 | }
147 |
148 | public function test_tours_list_filters_by_starting_date_correctly(): void
149 | {
150 | $travel = Travel::factory()->create();
151 | $laterTour = Tour::factory()->create([
152 | 'travel_id' => $travel->id,
153 | 'starting_date' => now()->addDays(2),
154 | 'ending_date' => now()->addDays(3),
155 | ]);
156 | $earlierTour = Tour::factory()->create([
157 | 'travel_id' => $travel->id,
158 | 'starting_date' => now(),
159 | 'ending_date' => now()->addDays(1),
160 | ]);
161 |
162 | $endpoint = '/api/v1/travels/'.$travel->slug.'/tours';
163 |
164 | $response = $this->get($endpoint.'?dateFrom='.now());
165 | $response->assertJsonCount(2, 'data');
166 | $response->assertJsonFragment(['id' => $earlierTour->id]);
167 | $response->assertJsonFragment(['id' => $laterTour->id]);
168 |
169 | $response = $this->get($endpoint.'?dateFrom='.now()->addDay());
170 | $response->assertJsonCount(1, 'data');
171 | $response->assertJsonMissing(['id' => $earlierTour->id]);
172 | $response->assertJsonFragment(['id' => $laterTour->id]);
173 |
174 | $response = $this->get($endpoint.'?dateFrom='.now()->addDays(5));
175 | $response->assertJsonCount(0, 'data');
176 |
177 | $response = $this->get($endpoint.'?dateTo='.now()->addDays(5));
178 | $response->assertJsonCount(2, 'data');
179 | $response->assertJsonFragment(['id' => $earlierTour->id]);
180 | $response->assertJsonFragment(['id' => $laterTour->id]);
181 |
182 | $response = $this->get($endpoint.'?dateTo='.now()->addDay());
183 | $response->assertJsonCount(1, 'data');
184 | $response->assertJsonMissing(['id' => $laterTour->id]);
185 | $response->assertJsonFragment(['id' => $earlierTour->id]);
186 |
187 | $response = $this->get($endpoint.'?dateTo='.now()->subDay());
188 | $response->assertJsonCount(0, 'data');
189 |
190 | $response = $this->get($endpoint.'?dateFrom='.now()->addDay().'&dateTo='.now()->addDays(5));
191 | $response->assertJsonCount(1, 'data');
192 | $response->assertJsonMissing(['id' => $earlierTour->id]);
193 | $response->assertJsonFragment(['id' => $laterTour->id]);
194 | }
195 |
196 | public function test_tour_list_returns_validation_errors(): void
197 | {
198 | $travel = Travel::factory()->create();
199 |
200 | $response = $this->getJson('/api/v1/travels/'.$travel->slug.'/tours?dateFrom=abcde');
201 | $response->assertStatus(422);
202 |
203 | $response = $this->getJson('/api/v1/travels/'.$travel->slug.'/tours?priceFrom=abcde');
204 | $response->assertStatus(422);
205 | }
206 | }
207 |
--------------------------------------------------------------------------------
/public/docs/collection.json:
--------------------------------------------------------------------------------
1 | {
2 | "variable": [
3 | {
4 | "id": "baseUrl",
5 | "key": "baseUrl",
6 | "type": "string",
7 | "name": "string",
8 | "value": "http:\/\/travelapi.test"
9 | }
10 | ],
11 | "info": {
12 | "name": "Travel API Documentation",
13 | "_postman_id": "9a9c4b7b-06dd-4281-8fb4-4c04c3244872",
14 | "description": "Example project for Travel Agency API",
15 | "schema": "https:\/\/schema.getpostman.com\/json\/collection\/v2.1.0\/collection.json"
16 | },
17 | "item": [
18 | {
19 | "name": "Admin endpoints",
20 | "description": "",
21 | "item": [
22 | {
23 | "name": "POST Travel",
24 | "request": {
25 | "url": {
26 | "host": "{{baseUrl}}",
27 | "path": "api\/v1\/admin\/travels",
28 | "query": [],
29 | "raw": "{{baseUrl}}\/api\/v1\/admin\/travels"
30 | },
31 | "method": "POST",
32 | "header": [
33 | {
34 | "key": "Content-Type",
35 | "value": "application\/json"
36 | },
37 | {
38 | "key": "Accept",
39 | "value": "application\/json"
40 | }
41 | ],
42 | "body": {
43 | "mode": "raw",
44 | "raw": "{\"is_public\":false,\"name\":\"rerum\",\"description\":\"autem\",\"number_of_days\":1}"
45 | },
46 | "description": "Creates a new Travel record."
47 | },
48 | "response": [
49 | {
50 | "header": [],
51 | "code": 200,
52 | "body": "{\"data\":{\"id\":\"996a36ca-2693-4901-9c55-7136e68d81d5\",\"name\":\"My new travel 234\",\"slug\":\"my-new-travel-234\",\"description\":\"The second best journey ever!\",\"number_of_days\":\"4\",\"number_of_nights\":3}}",
53 | "name": ""
54 | },
55 | {
56 | "header": [],
57 | "code": 422,
58 | "body": "{\"message\":\"The name has already been taken.\",\"errors\":{\"name\":[\"The name has already been taken.\"]}}",
59 | "name": ""
60 | }
61 | ]
62 | },
63 | {
64 | "name": "POST Tour",
65 | "request": {
66 | "url": {
67 | "host": "{{baseUrl}}",
68 | "path": "api\/v1\/admin\/travels\/:travel_id\/tours",
69 | "query": [],
70 | "raw": "{{baseUrl}}\/api\/v1\/admin\/travels\/:travel_id\/tours",
71 | "variable": [
72 | {
73 | "id": "travel_id",
74 | "key": "travel_id",
75 | "value": "9958e389-5edf-48eb-8ecd-e058985cf3ce",
76 | "description": "The ID of the travel."
77 | }
78 | ]
79 | },
80 | "method": "POST",
81 | "header": [
82 | {
83 | "key": "Content-Type",
84 | "value": "application\/json"
85 | },
86 | {
87 | "key": "Accept",
88 | "value": "application\/json"
89 | }
90 | ],
91 | "body": {
92 | "mode": "raw",
93 | "raw": "{\"name\":\"dolores\",\"starting_date\":\"2023-06-15T08:01:10\",\"ending_date\":\"2071-08-28\",\"price\":475}"
94 | },
95 | "description": "Creates a new Tour record."
96 | },
97 | "response": [
98 | {
99 | "header": [],
100 | "code": 200,
101 | "body": "{\"data\":{\"id\":\"996a381e-64ca-46ba-8b51-f8279d5529ad\",\"name\":\"Tour 1\",\"starting_date\":\"2023-06-15\",\"ending_date\":\"2023-06-20\",\"price\":\"99.99\"}}",
102 | "name": ""
103 | },
104 | {
105 | "header": [],
106 | "code": 422,
107 | "body": "{\"message\":\"The name has already been taken.\",\"errors\":{\"name\":[\"The name has already been taken.\"]}}",
108 | "name": ""
109 | }
110 | ]
111 | },
112 | {
113 | "name": "PUT Travel",
114 | "request": {
115 | "url": {
116 | "host": "{{baseUrl}}",
117 | "path": "api\/v1\/admin\/travels\/:travel_id",
118 | "query": [],
119 | "raw": "{{baseUrl}}\/api\/v1\/admin\/travels\/:travel_id",
120 | "variable": [
121 | {
122 | "id": "travel_id",
123 | "key": "travel_id",
124 | "value": "9958e389-5edf-48eb-8ecd-e058985cf3ce",
125 | "description": "The ID of the travel."
126 | }
127 | ]
128 | },
129 | "method": "PUT",
130 | "header": [
131 | {
132 | "key": "Content-Type",
133 | "value": "application\/json"
134 | },
135 | {
136 | "key": "Accept",
137 | "value": "application\/json"
138 | }
139 | ],
140 | "body": {
141 | "mode": "raw",
142 | "raw": "{\"is_public\":false,\"name\":\"iure\",\"description\":\"quaerat\",\"number_of_days\":16}"
143 | },
144 | "description": "Updates new Travel record."
145 | },
146 | "response": [
147 | {
148 | "header": [],
149 | "code": 200,
150 | "body": "{\"data\":{\"id\":\"996a36ca-2693-4901-9c55-7136e68d81d5\",\"name\":\"My new travel 234\",\"slug\":\"my-new-travel-234\",\"description\":\"The second best journey ever!\",\"number_of_days\":\"4\",\"number_of_nights\":3}}",
151 | "name": ""
152 | },
153 | {
154 | "header": [],
155 | "code": 422,
156 | "body": "{\"message\":\"The name has already been taken.\",\"errors\":{\"name\":[\"The name has already been taken.\"]}}",
157 | "name": ""
158 | }
159 | ]
160 | }
161 | ]
162 | },
163 | {
164 | "name": "Auth endpoints",
165 | "description": "",
166 | "item": [
167 | {
168 | "name": "POST Login",
169 | "request": {
170 | "url": {
171 | "host": "{{baseUrl}}",
172 | "path": "api\/v1\/login",
173 | "query": [],
174 | "raw": "{{baseUrl}}\/api\/v1\/login"
175 | },
176 | "method": "POST",
177 | "header": [
178 | {
179 | "key": "Content-Type",
180 | "value": "application\/json"
181 | },
182 | {
183 | "key": "Accept",
184 | "value": "application\/json"
185 | }
186 | ],
187 | "body": {
188 | "mode": "raw",
189 | "raw": "{\"email\":\"damien.wilderman@example.com\",\"password\":\"iste\"}"
190 | },
191 | "description": "Login with the existing user.",
192 | "auth": {
193 | "type": "noauth"
194 | }
195 | },
196 | "response": [
197 | {
198 | "header": [],
199 | "code": 200,
200 | "body": "{\"access_token\":\"1|a9ZcYzIrLURVGx6Xe41HKj1CrNsxRxe4pLA2oISo\"}",
201 | "name": ""
202 | },
203 | {
204 | "header": [],
205 | "code": 422,
206 | "body": "{\"error\": \"The provided credentials are incorrect.\"}",
207 | "name": ""
208 | }
209 | ]
210 | }
211 | ]
212 | },
213 | {
214 | "name": "Public endpoints",
215 | "description": "",
216 | "item": [
217 | {
218 | "name": "GET Travels",
219 | "request": {
220 | "url": {
221 | "host": "{{baseUrl}}",
222 | "path": "api\/v1\/travels",
223 | "query": [
224 | {
225 | "key": "page",
226 | "value": "1",
227 | "description": "Page number.",
228 | "disabled": false
229 | }
230 | ],
231 | "raw": "{{baseUrl}}\/api\/v1\/travels?page=1"
232 | },
233 | "method": "GET",
234 | "header": [
235 | {
236 | "key": "Content-Type",
237 | "value": "application\/json"
238 | },
239 | {
240 | "key": "Accept",
241 | "value": "application\/json"
242 | }
243 | ],
244 | "body": null,
245 | "description": "Returns paginated list of travels.",
246 | "auth": {
247 | "type": "noauth"
248 | }
249 | },
250 | "response": [
251 | {
252 | "header": [],
253 | "code": 200,
254 | "body": "{\"data\":[{\"id\":\"9958e389-5edf-48eb-8ecd-e058985cf3ce\",\"name\":\"First travel\",\"slug\":\"first-travel\",\"description\":\"Great offer!\",\"number_of_days\":5,\"number_of_nights\":4},{\"id\":\"99643482-4ea8-435e-b7da-e18cbde3d3c7\",\"name\":\"New travel\",\"slug\":\"new-travel\",\"description\":\"The best journey ever!\",\"number_of_days\":3,\"number_of_nights\":2}],\"links\":{\"first\":\"http:\/\/travel-api.test\/api\/v1\/travels?page=1\",\"last\":\"http:\/\/travel-api.test\/api\/v1\/travels?page=1\",\"prev\":null,\"next\":null},\"meta\":{\"current_page\":1,\"from\":1,\"last_page\":1,\"links\":[{\"url\":null,\"label\":\"« Previous\",\"active\":false},{\"url\":\"http:\/\/travel-api.test\/api\/v1\/travels?page=1\",\"label\":\"1\",\"active\":true},{\"url\":null,\"label\":\"Next »\",\"active\":false}],\"path\":\"http:\/\/travel-api.test\/api\/v1\/travels\",\"per_page\":15,\"to\":6,\"total\":6}}",
255 | "name": ""
256 | }
257 | ]
258 | },
259 | {
260 | "name": "GET Travel Tours",
261 | "request": {
262 | "url": {
263 | "host": "{{baseUrl}}",
264 | "path": "api\/v1\/travels\/:travel_slug\/tours",
265 | "query": [],
266 | "raw": "{{baseUrl}}\/api\/v1\/travels\/:travel_slug\/tours",
267 | "variable": [
268 | {
269 | "id": "travel_slug",
270 | "key": "travel_slug",
271 | "value": "%22first-travel%22",
272 | "description": "Travel slug."
273 | }
274 | ]
275 | },
276 | "method": "GET",
277 | "header": [
278 | {
279 | "key": "Content-Type",
280 | "value": "application\/json"
281 | },
282 | {
283 | "key": "Accept",
284 | "value": "application\/json"
285 | }
286 | ],
287 | "body": {
288 | "mode": "raw",
289 | "raw": "{\"priceFrom\":\"\\\"123.45\\\"\",\"priceTo\":\"\\\"234.56\\\"\",\"dateFrom\":\"\\\"2023-06-01\\\"\",\"dateTo\":\"\\\"2023-07-01\\\"\",\"sortBy\":\"\\\"price\\\"\",\"sortOrder\":\"\\\"asc\\\" or \\\"desc\\\"\"}"
290 | },
291 | "description": "Returns paginated list of tours by travel slug.",
292 | "auth": {
293 | "type": "noauth"
294 | }
295 | },
296 | "response": [
297 | {
298 | "header": [],
299 | "code": 200,
300 | "body": "{\"data\":[{\"id\":\"9958e389-5edf-48eb-8ecd-e058985cf3ce\",\"name\":\"Tour on Sunday\",\"starting_date\":\"2023-06-11\",\"ending_date\":\"2023-06-16\",\"price\":\"99.99\"},{\"id\":\"9958e389-5edf-48eb-8ecd-e058985cf3c2\",\"name\":\"Tour on Tuesday\",\"starting_date\":\"2023-06-14\",\"ending_date\":\"2023-06-19\",\"price\":\"119.99\"},{\"id\":\"9958e389-5edf-48eb-8ecd-e058985cf3c1\",\"name\":\"Tour on Monday\",\"starting_date\":\"2023-06-18\",\"ending_date\":\"2023-06-23\",\"price\":\"79.99\"}],\"links\":{\"first\":\"http:\/\/travel-api.test\/api\/v1\/travels\/first-travel\/tours?page=1\",\"last\":\"http:\/\/travel-api.test\/api\/v1\/travels\/first-travel\/tours?page=1\",\"prev\":null,\"next\":null},\"meta\":{\"current_page\":1,\"from\":1,\"last_page\":1,\"links\":[{\"url\":null,\"label\":\"« Previous\",\"active\":false},{\"url\":\"http:\/\/travel-api.test\/api\/v1\/travels\/first-travel\/tours?page=1\",\"label\":\"1\",\"active\":true},{\"url\":null,\"label\":\"Next »\",\"active\":false}],\"path\":\"http:\/\/travel-api.test\/api\/v1\/travels\/first-travel\/tours\",\"per_page\":15,\"to\":3,\"total\":3}}",
301 | "name": ""
302 | }
303 | ]
304 | }
305 | ]
306 | }
307 | ],
308 | "auth": {
309 | "type": "bearer",
310 | "bearer": [
311 | {
312 | "key": "key",
313 | "value": null,
314 | "type": "string"
315 | }
316 | ]
317 | }
318 | }
--------------------------------------------------------------------------------