├── public ├── favicon.ico ├── robots.txt ├── .htaccess ├── web.config └── index.php ├── database ├── .gitignore ├── seeds │ └── DatabaseSeeder.php ├── migrations │ ├── 2017_11_20_132505_create_customer_seqs_table.php │ ├── 2017_11_08_095841_create_reservation_seqs_table.php │ ├── 2017_12_09_171400_add_name_column_to_reservations.php │ ├── 2017_12_09_154156_delete_customer_seqs_table.php │ ├── 2017_12_09_171810_add_email_column_to_reservations.php │ ├── 2017_11_09_033739_create_customers_table.php │ ├── 2017_11_20_160540_fix_id_column_on_customers_table.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ ├── 2017_12_09_171321_drop_customer_id_from_reservations.php │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2017_12_09_153858_delete_customers_table.php │ ├── 2017_11_20_160604_add_foreign_to_reservations_table.php │ ├── 2017_11_20_160511_drom_foreign_from_reservations_table.php │ ├── 2017_12_09_152000_delete_foreign_from_reservations_table.php │ ├── 2017_11_04_164605_create_options_table.php │ ├── 2017_11_09_040609_fix_foreign_key_in_reservations_table.php │ └── 2017_11_04_152511_create_reservations_table.php └── factories │ └── UserFactory.php ├── resources ├── views │ ├── emails │ │ ├── manager.blade.php │ │ ├── customer_r_wq.blade.php │ │ └── customer_r_nq.blade.php │ └── welcome.blade.php ├── assets │ ├── sass │ │ ├── app.scss │ │ └── _variables.scss │ └── js │ │ ├── components │ │ └── Example.vue │ │ ├── app.js │ │ └── bootstrap.js └── lang │ └── en │ ├── pagination.php │ ├── auth.php │ ├── passwords.php │ └── validation.php ├── bootstrap ├── cache │ └── .gitignore └── app.php ├── storage ├── logs │ └── .gitignore ├── app │ ├── public │ │ └── .gitignore │ └── .gitignore ├── framework │ ├── cache │ │ └── .gitignore │ ├── testing │ │ └── .gitignore │ ├── views │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ └── .gitignore └── json │ └── google_api_secret_key.json ├── packages └── Asobiba │ ├── .DS_Store │ ├── ClassDiagram.png │ ├── Domain │ └── Models │ │ ├── User │ │ ├── Manager.php │ │ └── Customer.php │ │ ├── Calendar │ │ └── CalendarInterface.php │ │ ├── Reservation │ │ ├── ReservationId.php │ │ ├── Question.php │ │ ├── NotificationRule.php │ │ ├── PriceOfPlan.php │ │ ├── Number.php │ │ ├── Purpose.php │ │ ├── Capacity.php │ │ ├── AcceptableTime.php │ │ ├── PriceOfOptions.php │ │ ├── Status.php │ │ ├── Plan.php │ │ ├── DateOfUse.php │ │ ├── Options.php │ │ └── Reservation.php │ │ ├── Notification │ │ └── ReservationNotificationInterface.php │ │ ├── Repositories │ │ └── Reservation │ │ │ ├── ReservationRepositoryInterface.php │ │ │ └── CustomerRepositoryInterface.php │ │ ├── Factory │ │ ├── CustomerFactory.php │ │ └── ReservationFactory.php │ │ ├── Enum.php │ │ └── Availability │ │ └── Availability.php │ ├── Infrastructure │ ├── Notification │ │ └── MailReservationNotification.php │ ├── Repositories │ │ ├── EloquentCustomerRepository.php │ │ └── EloquentReservationRepository.php │ └── Calendar │ │ └── GoogleCalendar.php │ └── Application │ └── Services │ └── AcceptanceReservationService.php ├── .gitattributes ├── tests ├── TestCase.php ├── Unit │ ├── ExampleTest.php │ └── CalendarTest.php ├── CreatesApplication.php ├── Feature │ └── Reservation │ │ ├── ReservationIdTest.php │ │ ├── InstantiationTest.php │ │ ├── PurposeTest.php │ │ ├── PriceTest.php │ │ ├── QuestionTest.php │ │ ├── RepositoryTest.php │ │ ├── NotifyTest.php │ │ ├── ServiceTest.php │ │ ├── CapacityTest.php │ │ ├── GetValueTest.php │ │ └── UseDateTimeTest.php └── utilities │ └── functions.php ├── .gitignore ├── app ├── Http │ ├── Middleware │ │ ├── EncryptCookies.php │ │ ├── VerifyCsrfToken.php │ │ ├── TrimStrings.php │ │ ├── RedirectIfAuthenticated.php │ │ └── TrustProxies.php │ ├── Controllers │ │ ├── Controller.php │ │ ├── Auth │ │ │ ├── ForgotPasswordController.php │ │ │ ├── LoginController.php │ │ │ ├── ResetPasswordController.php │ │ │ └── RegisterController.php │ │ └── ReservationController.php │ └── Kernel.php ├── Eloquents │ ├── User │ │ ├── EloquentCustomer.php │ │ └── EloquentManager.php │ └── Reservation │ │ ├── EloquentOption.php │ │ └── EloquentReservation.php ├── Providers │ ├── BroadcastServiceProvider.php │ ├── AuthServiceProvider.php │ ├── EventServiceProvider.php │ ├── EloquentServiceProvider.php │ ├── RouteServiceProvider.php │ └── AppServiceProvider.php ├── Mail │ ├── ToCustomerNotAvailable.php │ ├── ToCustomerOnApplyPreview.php │ ├── ToCustomerWithQuestion.php │ └── ToCustomerNotQuestion.php ├── Console │ └── Kernel.php └── Exceptions │ └── Handler.php ├── routes ├── web.php ├── channels.php ├── api.php └── console.php ├── webpack.mix.js ├── server.php ├── .env.example ├── config ├── view.php ├── services.php ├── broadcasting.php ├── filesystems.php ├── queue.php ├── cache.php ├── auth.php ├── database.php ├── mail.php ├── session.php └── app.php ├── phpunit.xml ├── package.json ├── composer.json ├── artisan └── readme.md /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /resources/views/emails/manager.blade.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /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/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /packages/Asobiba/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yorinton/asobiba101/HEAD/packages/Asobiba/.DS_Store -------------------------------------------------------------------------------- /packages/Asobiba/ClassDiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yorinton/asobiba101/HEAD/packages/Asobiba/ClassDiagram.png -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | schedule-* 4 | compiled.php 5 | services.json 6 | events.scanned.php 7 | routes.scanned.php 8 | down 9 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | call(UsersTableSeeder::class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/User/Manager.php: -------------------------------------------------------------------------------- 1 | email; 18 | } 19 | } 20 | 21 | 22 | ?> -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Calendar/CalendarInterface.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Reservation/ReservationId.php: -------------------------------------------------------------------------------- 1 | id = $id; 14 | } 15 | 16 | public function getId(): int 17 | { 18 | return $this->id; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | hasOne(EloquentReservation::class,'customer_id'); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Notification/ReservationNotificationInterface.php: -------------------------------------------------------------------------------- 1 | belongsTo(EloquentReservation::class); 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Repositories/Reservation/CustomerRepositoryInterface.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | question = $question; 14 | } 15 | 16 | public function isQuestion(): bool 17 | { 18 | return isset($this->question); 19 | // return $this->question !== ''; 20 | } 21 | 22 | public function getQuestion(): String 23 | { 24 | return $this->question ? $this->question : ''; 25 | } 26 | 27 | } 28 | 29 | ?> -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Factory/CustomerFactory.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 16 | }); 17 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 17 | return $request->user(); 18 | }); 19 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Reservation/NotificationRule.php: -------------------------------------------------------------------------------- 1 | hasQuestion()) { 13 | $this->method = 'ToCustomerNotQuestion'; 14 | } elseif ($reservation->hasQuestion()) { 15 | $this->method = 'ToCustomerWithQuestion'; 16 | } 17 | } 18 | 19 | public function getNotifyMethod() 20 | { 21 | return $this->method; 22 | } 23 | } -------------------------------------------------------------------------------- /webpack.mix.js: -------------------------------------------------------------------------------- 1 | let mix = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel application. By default, we are compiling the Sass 10 | | file for the application as well as bundling up all the JS files. 11 | | 12 | */ 13 | 14 | mix.js('resources/assets/js/app.js', 'public/js') 15 | .sass('resources/assets/sass/app.scss', 'public/css'); 16 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 18 | })->describe('Display an inspiring quote'); 19 | -------------------------------------------------------------------------------- /app/Eloquents/Reservation/EloquentReservation.php: -------------------------------------------------------------------------------- 1 | belongsTo(EloquentCustomer::class); 21 | } 22 | 23 | public function options() 24 | { 25 | return $this->hasMany(EloquentOption::class,'reservation_id'); 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_LOG_LEVEL=debug 6 | APP_URL=http://localhost 7 | 8 | DB_CONNECTION=mysql 9 | DB_HOST=127.0.0.1 10 | DB_PORT=3306 11 | DB_DATABASE=homestead 12 | DB_USERNAME=homestead 13 | DB_PASSWORD=secret 14 | 15 | BROADCAST_DRIVER=log 16 | CACHE_DRIVER=file 17 | SESSION_DRIVER=file 18 | QUEUE_DRIVER=sync 19 | 20 | REDIS_HOST=127.0.0.1 21 | REDIS_PASSWORD=null 22 | REDIS_PORT=6379 23 | 24 | MAIL_DRIVER=smtp 25 | MAIL_HOST=smtp.mailtrap.io 26 | MAIL_PORT=2525 27 | MAIL_USERNAME=null 28 | MAIL_PASSWORD=null 29 | MAIL_ENCRYPTION=null 30 | 31 | PUSHER_APP_ID= 32 | PUSHER_APP_KEY= 33 | PUSHER_APP_SECRET= 34 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/home'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Redirect Trailing Slashes If Not A Folder... 9 | RewriteCond %{REQUEST_FILENAME} !-d 10 | RewriteCond %{REQUEST_URI} (.+)/$ 11 | RewriteRule ^ %1 [L,R=301] 12 | 13 | # Handle Front Controller... 14 | RewriteCond %{REQUEST_FILENAME} !-d 15 | RewriteCond %{REQUEST_FILENAME} !-f 16 | RewriteRule ^ index.php [L] 17 | 18 | # Handle Authorization Header 19 | RewriteCond %{HTTP:Authorization} . 20 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 21 | 22 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Reservation/PriceOfPlan.php: -------------------------------------------------------------------------------- 1 | 19500, 10 | '【非商用】基本プラン(休日)' => 20500, 11 | '【非商用】お昼5時間パック' => 17000, 12 | '【非商用】夜5時間パック' => 18000, 13 | '【商用】基本1日プラン' => 28500, 14 | '【商用】お昼5時間パック' => 24000, 15 | '【商用】夜5時間パック' => 25000, 16 | '【商用】3時間パック' => 20000, 17 | '【商用】2時間パック' => 17000, 18 | ]; 19 | 20 | public static function getPrice(Plan $plan): int 21 | { 22 | return self::PriceOfPlanSet[$plan->getPlan()]; 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /resources/assets/js/components/Example.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 24 | -------------------------------------------------------------------------------- /resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/assets/js/app.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * First we will load all of this project's JavaScript dependencies which 4 | * includes Vue and other libraries. It is a great starting point when 5 | * building robust, powerful web applications using Vue and Laravel. 6 | */ 7 | 8 | require('./bootstrap'); 9 | 10 | window.Vue = require('vue'); 11 | 12 | /** 13 | * Next, we will create a fresh Vue application instance and attach it to 14 | * the page. Then, you may begin adding components to this application 15 | * or customize the JavaScript scaffolding to fit your unique needs. 16 | */ 17 | 18 | Vue.component('example', require('./components/Example.vue')); 19 | 20 | const app = new Vue({ 21 | el: '#app' 22 | }); 23 | -------------------------------------------------------------------------------- /app/Eloquents/User/EloquentManager.php: -------------------------------------------------------------------------------- 1 | view('view.name'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Mail/ToCustomerOnApplyPreview.php: -------------------------------------------------------------------------------- 1 | view('view.name'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | * 22 | * @return void 23 | */ 24 | public function boot() 25 | { 26 | $this->registerPolicies(); 27 | 28 | // 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/User/Customer.php: -------------------------------------------------------------------------------- 1 | isEmail($email)){ 14 | throw new \InvalidArgumentException('not format of email is given'); 15 | } 16 | $this->name = $name; 17 | $this->email = $email; 18 | } 19 | 20 | public function getName(): string 21 | { 22 | return $this->name; 23 | } 24 | 25 | public function getEmail(): string 26 | { 27 | return $this->email; 28 | } 29 | 30 | public function isEmail($email): bool 31 | { 32 | return strpos($email,'@'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'App\Listeners\EventListener', 18 | ], 19 | ]; 20 | 21 | /** 22 | * Register any events for your application. 23 | * 24 | * @return void 25 | */ 26 | public function boot() 27 | { 28 | parent::boot(); 29 | 30 | // 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2017_11_20_132505_create_customer_seqs_table.php: -------------------------------------------------------------------------------- 1 | integer('nextval')->unsigned(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::dropIfExists('customer_seqs'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /database/migrations/2017_11_08_095841_create_reservation_seqs_table.php: -------------------------------------------------------------------------------- 1 | integer('nextval')->unsigned(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::dropIfExists('reservation_seqs'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustProxies.php: -------------------------------------------------------------------------------- 1 | 'FORWARDED', 24 | Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR', 25 | Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST', 26 | Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT', 27 | Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO', 28 | ]; 29 | } 30 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Reservation/Number.php: -------------------------------------------------------------------------------- 1 | isAcceptableNumber($number, $capacity)) { 13 | throw new \InvalidArgumentException('適切な利用人数を設定して下さい'); 14 | } 15 | $this->number = $number; 16 | } 17 | 18 | public function isAcceptableNumber(int $number, Capacity $capacity): bool 19 | { 20 | if ($number > $capacity->getCapacity()) { 21 | return false; 22 | } 23 | return true; 24 | } 25 | 26 | /** 27 | * @return Int 28 | */ 29 | public function getNumber(): int 30 | { 31 | return $this->number; 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | define(App\User::class, function (Faker $faker) { 17 | static $password; 18 | 19 | return [ 20 | 'name' => $faker->name, 21 | 'email' => $faker->unique()->safeEmail, 22 | 'password' => $password ?: $password = bcrypt('secret'), 23 | 'remember_token' => str_random(10), 24 | ]; 25 | }); 26 | -------------------------------------------------------------------------------- /database/migrations/2017_12_09_171400_add_name_column_to_reservations.php: -------------------------------------------------------------------------------- 1 | string('name')->after('id'); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('reservations', function (Blueprint $table) { 29 | $table->dropColumn('name'); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2017_12_09_154156_delete_customer_seqs_table.php: -------------------------------------------------------------------------------- 1 | integer('nextval')->unsigned(); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2017_12_09_171810_add_email_column_to_reservations.php: -------------------------------------------------------------------------------- 1 | string('email')->after('name'); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('reservations', function (Blueprint $table) { 29 | $table->dropColumn('email'); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Reservation/Purpose.php: -------------------------------------------------------------------------------- 1 | isAdultPurpose($purpose)){ 12 | throw new \InvalidArgumentException('アダルト関連の目的ではご利用頂けません'); 13 | } 14 | $this->purpose = $purpose; 15 | } 16 | 17 | private function isAdultPurpose(string $purpose) 18 | { 19 | $ngWords = ['アダルト','エロ','AV']; 20 | foreach($ngWords as $ngWord) { 21 | if(strpos($purpose, $ngWord) !== false){//strposの比較の場合は比較演算子 === を使う 22 | return true; 23 | } 24 | } 25 | return false; 26 | } 27 | 28 | public function getPurpose() 29 | { 30 | return $this->purpose; 31 | } 32 | } -------------------------------------------------------------------------------- /database/migrations/2017_11_09_033739_create_customers_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name',25); 19 | $table->string('email',100); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::dropIfExists('customers'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /database/migrations/2017_11_20_160540_fix_id_column_on_customers_table.php: -------------------------------------------------------------------------------- 1 | integer('id')->unsigned()->change(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('customers', function (Blueprint $table) { 29 | $table->increments('id')->change(); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2017_12_09_171321_drop_customer_id_from_reservations.php: -------------------------------------------------------------------------------- 1 | dropColumn('customer_id'); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('reservations', function (Blueprint $table) { 29 | $table->integer('customer_id')->unsigned(); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Passwords must be at least six characters and match the confirmation.', 17 | 'reset' => 'Your password has been reset!', 18 | 'sent' => 'We have e-mailed your password reset link!', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that e-mail address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /tests/Feature/Reservation/ReservationIdTest.php: -------------------------------------------------------------------------------- 1 | insert(["nextval" => 0]); 22 | 23 | $repository = new EloquentReservationRepository; 24 | $reservationId = $repository->nextIdentity(); 25 | $this->assertInstanceOf(ReservationId::class,$reservationId); 26 | $this->assertEquals(1,$reservationId->getId()); 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->string('password'); 21 | $table->rememberToken(); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('users'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /database/migrations/2017_12_09_153858_delete_customers_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 30 | $table->string('name',25); 31 | $table->string('email',100); 32 | $table->timestamps(); 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Enum.php: -------------------------------------------------------------------------------- 1 | value = static::ENUM[$key]; 18 | } 19 | 20 | public static function isValidValue($key) 21 | { 22 | return array_key_exists($key, static::ENUM); 23 | } 24 | 25 | public function __toString() 26 | { 27 | return $this->value; 28 | } 29 | 30 | public static function __callStatic($method, array $args) 31 | { 32 | return new self($method); 33 | } 34 | 35 | public function __set($key, $value) 36 | { 37 | throw new \BadMethodCallException('All setter is forbbiden'); 38 | } 39 | } 40 | 41 | 42 | 43 | 44 | 45 | ?> -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Reservation/Capacity.php: -------------------------------------------------------------------------------- 1 | 11, 15 | '【非商用】基本プラン(休日)' => 11, 16 | '【非商用】お昼5時間パック' => 11, 17 | '【非商用】夜5時間パック' => 11, 18 | '【商用】基本1日プラン' => 15, 19 | '【商用】お昼5時間パック' => 15, 20 | '【商用】夜5時間パック' => 15, 21 | '【商用】3時間パック' => 15, 22 | '【商用】2時間パック' => 15, 23 | ]; 24 | 25 | public function __construct(Plan $plan, Options $options) 26 | { 27 | $this->plan = $plan; 28 | $this->options = $options; 29 | } 30 | 31 | public function getCapacity():int 32 | { 33 | if ($this->options->hasLargeGroupOption()) { 34 | return 15; 35 | } 36 | return self::capacityOfPlanSet[$this->plan->getPlan()]; 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /public/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ForgotPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2017_11_20_160604_add_foreign_to_reservations_table.php: -------------------------------------------------------------------------------- 1 | foreign('customer_id') 18 | ->references('id') 19 | ->on('customers') 20 | ->onDelete('cascade') 21 | ->onUpdate('cascade'); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::table('reservations', function (Blueprint $table) { 33 | $table->dropForeign(['customer_id']); 34 | }); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /database/migrations/2017_11_20_160511_drom_foreign_from_reservations_table.php: -------------------------------------------------------------------------------- 1 | dropForeign(['customer_id']); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('reservations', function (Blueprint $table) { 29 | $table->foreign('customer_id') 30 | ->references('id') 31 | ->on('customers') 32 | ->onDelete('cascade') 33 | ->onUpdate('cascade'); 34 | }); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire') 28 | // ->hourly(); 29 | } 30 | 31 | /** 32 | * Register the commands for the application. 33 | * 34 | * @return void 35 | */ 36 | protected function commands() 37 | { 38 | $this->load(__DIR__.'/Commands'); 39 | 40 | require base_path('routes/console.php'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /database/migrations/2017_12_09_152000_delete_foreign_from_reservations_table.php: -------------------------------------------------------------------------------- 1 | dropForeign(['customer_id']); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('reservations', function (Blueprint $table) { 29 | $table->foreign('customer_id') 30 | ->references('id') 31 | ->on('customers') 32 | ->onDelete('cascade') 33 | ->onUpdate('cascade'); 34 | }); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /resources/assets/sass/_variables.scss: -------------------------------------------------------------------------------- 1 | 2 | // Body 3 | $body-bg: #f5f8fa; 4 | 5 | // Borders 6 | $laravel-border-color: darken($body-bg, 10%); 7 | $list-group-border: $laravel-border-color; 8 | $navbar-default-border: $laravel-border-color; 9 | $panel-default-border: $laravel-border-color; 10 | $panel-inner-border: $laravel-border-color; 11 | 12 | // Brands 13 | $brand-primary: #3097D1; 14 | $brand-info: #8eb4cb; 15 | $brand-success: #2ab27b; 16 | $brand-warning: #cbb956; 17 | $brand-danger: #bf5329; 18 | 19 | // Typography 20 | $icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/"; 21 | $font-family-sans-serif: "Raleway", sans-serif; 22 | $font-size-base: 14px; 23 | $line-height-base: 1.6; 24 | $text-color: #636b6f; 25 | 26 | // Navbar 27 | $navbar-default-bg: #fff; 28 | 29 | // Buttons 30 | $btn-default-color: $text-color; 31 | 32 | // Inputs 33 | $input-border: lighten($text-color, 40%); 34 | $input-border-focus: lighten($brand-primary, 25%); 35 | $input-color-placeholder: lighten($text-color, 30%); 36 | 37 | // Panels 38 | $panel-default-heading-bg: #fff; 39 | -------------------------------------------------------------------------------- /resources/views/emails/customer_r_wq.blade.php: -------------------------------------------------------------------------------- 1 | 2 |

この度は「ASOBIBA101」にお問い合わせ頂き誠にありがとうございます

3 |

担当からご連絡させて頂きますので少々お待ち下さい

4 | 5 |
6 | 20 |
21 | 22 |
23 |

================

24 |

遊べるハウススタジオ「ASOBIBA101」

25 |

================

26 |
27 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/LoginController.php: -------------------------------------------------------------------------------- 1 | middleware('guest')->except('logout'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /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' => realpath(storage_path('framework/views')), 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /database/migrations/2017_11_04_164605_create_options_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->integer('reservation_id')->unsigned(); 19 | $table->string('option'); 20 | $table->integer('price'); 21 | $table->timestamps(); 22 | 23 | $table->foreign('reservation_id') 24 | ->references('id') 25 | ->on('reservations') 26 | ->onDelete('cascade') 27 | ->onUpdate('cascade'); 28 | }); 29 | } 30 | 31 | /** 32 | * Reverse the migrations. 33 | * 34 | * @return void 35 | */ 36 | public function down() 37 | { 38 | Schema::dropIfExists('options'); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | ], 21 | 22 | 'ses' => [ 23 | 'key' => env('SES_KEY'), 24 | 'secret' => env('SES_SECRET'), 25 | 'region' => 'us-east-1', 26 | ], 27 | 28 | 'sparkpost' => [ 29 | 'secret' => env('SPARKPOST_SECRET'), 30 | ], 31 | 32 | 'stripe' => [ 33 | 'model' => App\User::class, 34 | 'key' => env('STRIPE_KEY'), 35 | 'secret' => env('STRIPE_SECRET'), 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/Asobiba/Infrastructure/Notification/MailReservationNotification.php: -------------------------------------------------------------------------------- 1 | getNotifyMethod(); 18 | 19 | $mailable = 'App\Mail\\'.$notifyMethod; 20 | 21 | Mail::to($reservation->getCustomer()->getEmail()) 22 | ->send(new $mailable($reservation->getCustomer(),$reservation)); 23 | 24 | return true; 25 | } 26 | 27 | 28 | public function notifyToManager(Reservation $reservation): bool 29 | { 30 | // TODO: Implement notifyToManager() method. 31 | // メール送信 32 | 33 | 34 | // メール送信成否のフラグを返す 35 | return true; 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/Feature 14 | 15 | 16 | 17 | ./tests/Unit 18 | 19 | 20 | 21 | 22 | ./app 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /app/Providers/EloquentServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->bind(EloquentCustomer::class,function($app){ 38 | return new EloquentCustomer; 39 | }); 40 | $this->app->bind(EloquentReservation::class,function($app){ 41 | return new EloquentReservation; 42 | }); 43 | $this->app->bind(EloquentOption::class,function($app){ 44 | return new EloquentOption; 45 | }); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "npm run development", 5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 6 | "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 7 | "watch-poll": "npm run watch -- --watch-poll", 8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", 9 | "prod": "npm run production", 10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" 11 | }, 12 | "devDependencies": { 13 | "axios": "^0.16.2", 14 | "bootstrap-sass": "^3.3.7", 15 | "cross-env": "^5.0.1", 16 | "jquery": "^3.1.1", 17 | "laravel-mix": "^1.0", 18 | "lodash": "^4.17.4", 19 | "vue": "^2.1.10" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Reservation/AcceptableTime.php: -------------------------------------------------------------------------------- 1 | 11, 10 | '【非商用】基本プラン(休日)' => 11, 11 | '【非商用】お昼5時間パック' => 11, 12 | '【非商用】夜5時間パック' => 17, 13 | '【商用】基本1日プラン' => 11, 14 | '【商用】お昼5時間パック' => 11, 15 | '【商用】夜5時間パック' => 17, 16 | '【商用】3時間パック' => 11, 17 | '【商用】2時間パック' => 11, 18 | ]; 19 | 20 | private const endTimeOfPlanSet = [ 21 | 22 | '【非商用】基本プラン(平日)' => 22, 23 | '【非商用】基本プラン(休日)' => 22, 24 | '【非商用】お昼5時間パック' => 16, 25 | '【非商用】夜5時間パック' => 22, 26 | '【商用】基本1日プラン' => 22, 27 | '【商用】お昼5時間パック' => 16, 28 | '【商用】夜5時間パック' => 22, 29 | '【商用】3時間パック' => 22, 30 | '【商用】2時間パック' => 22, 31 | ]; 32 | 33 | 34 | public static function acceptableStartTime(Plan $plan): int 35 | { 36 | return self::startTimeOfPlanSet[$plan->getPlan()]; 37 | } 38 | 39 | public static function acceptableEndTime(Plan $plan): int 40 | { 41 | return self::endTimeOfPlanSet[$plan->getPlan()]; 42 | } 43 | } -------------------------------------------------------------------------------- /app/Http/Controllers/ReservationController.php: -------------------------------------------------------------------------------- 1 | service = $service; 15 | } 16 | 17 | public function acceptReservation(Request $req) 18 | { 19 | try { 20 | $this->service->reserve($this->reqToArray($req)); 21 | } 22 | catch(\InvalidArgumentException $e){ 23 | return $e->getMessage(); 24 | } 25 | } 26 | 27 | //別クラスorトレイトに移動 28 | private function reqToArray(Request $req): array 29 | { 30 | $exception = [ 31 | 'attributes', 32 | 'request', 33 | 'query', 34 | 'server', 35 | 'files', 36 | 'cookies', 37 | 'headers' 38 | ]; 39 | 40 | foreach($req as $key => $value){ 41 | if(in_array($key,$exception)){ 42 | continue; 43 | } 44 | $array[$key] = $value; 45 | } 46 | return $array; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Reservation/PriceOfOptions.php: -------------------------------------------------------------------------------- 1 | 1500, 10 | 'コタツ(布団付き)' => 3000, 11 | '電気グリル鍋' => 2000, 12 | '大きな鍋' => 1000, 13 | 'カセットコンロ' => 1500, 14 | 'たこ焼き器' => 1500, 15 | '大人数レイアウト' => 4000, 16 | '寿司桶' => 500, 17 | 'プロジェクター' => 1500, 18 | '深夜利用' => 5000, 19 | '宿泊(1〜3名様)' => 6000, 20 | '宿泊(4〜5名様)' => 8000, 21 | 'コテ' => 1000, 22 | '撮影用ミニライト' => 1000, 23 | '姿見鏡' => 1000, 24 | 'サプライズ装飾' => 4000, 25 | '炊飯器' => 1500, 26 | 'トースター' => 1500, 27 | 'ミキサー' => 1000, 28 | '付けない' => 0, 29 | ]; 30 | 31 | public static function getTotalPrice(array $options): int 32 | { 33 | $totalPrice = 0; 34 | foreach ($options as $option) { 35 | $totalPrice += self::priceOptionsSet[$option]; 36 | } 37 | return (int)$totalPrice; 38 | } 39 | 40 | public static function getOptionAndPriceSet(array $options): array 41 | { 42 | return array_intersect_key(self::priceOptionsSet, array_flip($options)); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | dropForeign(['user_id']); 19 | $table->renameColumn('user_id','customer_id'); 20 | $table->foreign('customer_id') 21 | ->references('id') 22 | ->on('customers') 23 | ->onDelete('cascade') 24 | ->onUpdate('cascade'); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::table('reservations', function (Blueprint $table) { 36 | $table->dropForeign(['customer_id']); 37 | $table->renameColumn('customer_id','user_id'); 38 | $table->foreign('user_id') 39 | ->references('id') 40 | ->on('users') 41 | ->onDelete('cascade') 42 | ->onUpdate('cascade'); 43 | }); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /database/migrations/2017_11_04_152511_create_reservations_table.php: -------------------------------------------------------------------------------- 1 | integer('id')->unsigned()->primary(); 18 | $table->integer('user_id')->unsigned(); 19 | $table->string('plan'); 20 | $table->integer('price'); 21 | $table->integer('number'); 22 | $table->string('date'); 23 | $table->integer('start_time'); 24 | $table->integer('end_time'); 25 | $table->string('question'); 26 | $table->string('status'); 27 | $table->timestamps(); 28 | 29 | $table->foreign('user_id') 30 | ->references('id') 31 | ->on('users') 32 | ->onDelete('cascade') 33 | ->onUpdate('cascade'); 34 | }); 35 | } 36 | 37 | /** 38 | * Reverse the migrations. 39 | * 40 | * @return void 41 | */ 42 | public function down() 43 | { 44 | Schema::dropIfExists('reservations'); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/Mail/ToCustomerWithQuestion.php: -------------------------------------------------------------------------------- 1 | customer = $customer; 30 | $this->reservation = $reservation; 31 | $dateArr = explode('-',$reservation->getDate()->getDate()); 32 | $this->date = $dateArr[0].'年'.$dateArr[1].'月'.$dateArr[2].'日'; 33 | $this->start = $reservation->getStartTime().'時'; 34 | $this->end = $reservation->getEndTime() === 9 ? '翌午前'.$reservation->getEndTime().'時' : $reservation->getEndTime().'時'; 35 | } 36 | 37 | /** 38 | * Build the message. 39 | * 40 | * @return $this 41 | */ 42 | public function build() 43 | { 44 | return $this->view('emails.customer_r_wq') 45 | ->subject('ASOBIBA101お問い合わせ'); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/Mail/ToCustomerNotQuestion.php: -------------------------------------------------------------------------------- 1 | customer = $customer; 31 | $this->reservation = $reservation; 32 | $dateArr = explode('-',$reservation->getDate()->getDate()); 33 | $this->date = $dateArr[0].'年'.$dateArr[1].'月'.$dateArr[2].'日'; 34 | $this->start = $reservation->getStartTime().'時'; 35 | $this->end = $reservation->getEndTime() === 9 ? '翌午前'.$reservation->getEndTime().'時' : $reservation->getEndTime().'時'; 36 | $expireArr = explode('-',date("Y-m-d",strtotime("+3 day"))); 37 | $this->pymentExpire = $expireArr[1].'月'.$expireArr[2].'日'; 38 | } 39 | 40 | /** 41 | * Build the message. 42 | * 43 | * @return $this 44 | */ 45 | public function build() 46 | { 47 | return $this->view('emails.customer_r_nq') 48 | ->subject('ASOBIBA101ご予約確認・今後手続き'); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /tests/Feature/Reservation/InstantiationTest.php: -------------------------------------------------------------------------------- 1 | insert(["nextval" => 0]); 19 | } 20 | 21 | public function repository() 22 | { 23 | return new EloquentReservationRepository; 24 | } 25 | 26 | /** 27 | * Make Reservation instance test. 28 | * 29 | * @return void 30 | */ 31 | public function testMakeReservation() 32 | { 33 | $this->prepare(); 34 | 35 | $request = makeCorrectRequest(); 36 | 37 | $id = $this->repository()->nextIdentity(); 38 | $reservation = createReservation($id,$request); 39 | 40 | $this->assertTrue(true); 41 | } 42 | 43 | /** 44 | * 45 | * Check if the id is unique 46 | * 47 | */ 48 | public function testUniqueId() 49 | { 50 | $this->prepare(); 51 | 52 | $request = makeCorrectRequest(); 53 | 54 | $id = $this->repository()->nextIdentity(); 55 | $reservation = createReservation($id,$request); 56 | 57 | $id2 = $this->repository()->nextIdentity(); 58 | $reservation2 = createReservation($id2,$request); 59 | 60 | $this->assertTrue($reservation->getId() !== $reservation2->getId()); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /tests/Feature/Reservation/PurposeTest.php: -------------------------------------------------------------------------------- 1 | insert(["nextval" => 0]); 18 | return new EloquentReservationRepository; 19 | } 20 | /** 21 | * A basic test example. 22 | * 23 | * @return void 24 | */ 25 | public function testNotAdultPurpose() 26 | { 27 | $request = makeOtherRequestWithPurpose(); 28 | 29 | try{ 30 | $id = $this->repository()->nextIdentity(); 31 | $reservation = createReservation($id,$request); 32 | $this->assertTrue(true); 33 | }catch(\InvalidArgumentException $e){ 34 | $this->fail($e->getMessage()); 35 | } 36 | $this->assertTrue(true); 37 | } 38 | 39 | public function testHasAdultPurpose() 40 | { 41 | $request = makeOtherRequestWithPurpose(); 42 | $request->purpose = 'AV撮影'; 43 | 44 | try{ 45 | $id = $this->repository()->nextIdentity(); 46 | $reservation = createReservation($id,$request); 47 | $this->fail('例外発生無し'); 48 | }catch(\InvalidArgumentException $e){ 49 | $this->assertEquals('アダルト関連の目的ではご利用頂けません',$e->getMessage()); 50 | 51 | } 52 | $this->assertTrue(true); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /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 | // 40 | ], 41 | ], 42 | 43 | 'redis' => [ 44 | 'driver' => 'redis', 45 | 'connection' => 'default', 46 | ], 47 | 48 | 'log' => [ 49 | 'driver' => 'log', 50 | ], 51 | 52 | 'null' => [ 53 | 'driver' => 'null', 54 | ], 55 | 56 | ], 57 | 58 | ]; 59 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "description": "The Laravel Framework.", 4 | "keywords": ["framework", "laravel"], 5 | "license": "MIT", 6 | "type": "project", 7 | "require": { 8 | "php": ">=7.0.0", 9 | "doctrine/dbal": "^2.6", 10 | "fideloper/proxy": "~3.3", 11 | "google/apiclient": "^2.0", 12 | "laravel/framework": "5.5.*", 13 | "laravel/tinker": "~1.0" 14 | }, 15 | "require-dev": { 16 | "filp/whoops": "~2.0", 17 | "fzaninotto/faker": "~1.4", 18 | "mockery/mockery": "0.9.*", 19 | "nunomaduro/collision": "^1.1", 20 | "phpunit/phpunit": "~6.0" 21 | }, 22 | "autoload": { 23 | "classmap": [ 24 | "database/seeds", 25 | "database/factories", 26 | "packages" 27 | ], 28 | "psr-4": { 29 | "App\\": "app/" 30 | } 31 | }, 32 | "autoload-dev": { 33 | "psr-4": { 34 | "Tests\\": "tests/" 35 | }, 36 | "files": ["tests/utilities/functions.php"] 37 | }, 38 | "extra": { 39 | "laravel": { 40 | "dont-discover": [ 41 | ] 42 | } 43 | }, 44 | "scripts": { 45 | "post-root-package-install": [ 46 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 47 | ], 48 | "post-create-project-cmd": [ 49 | "@php artisan key:generate" 50 | ], 51 | "post-autoload-dump": [ 52 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 53 | "@php artisan package:discover" 54 | ] 55 | }, 56 | "config": { 57 | "preferred-install": "dist", 58 | "sort-packages": true, 59 | "optimize-autoloader": true 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /resources/assets/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | 2 | window._ = require('lodash'); 3 | 4 | /** 5 | * We'll load jQuery and the Bootstrap jQuery plugin which provides support 6 | * for JavaScript based Bootstrap features such as modals and tabs. This 7 | * code may be modified to fit the specific needs of your application. 8 | */ 9 | 10 | try { 11 | window.$ = window.jQuery = require('jquery'); 12 | 13 | require('bootstrap-sass'); 14 | } catch (e) {} 15 | 16 | /** 17 | * We'll load the axios HTTP library which allows us to easily issue requests 18 | * to our Laravel back-end. This library automatically handles sending the 19 | * CSRF token as a header based on the value of the "XSRF" token cookie. 20 | */ 21 | 22 | window.axios = require('axios'); 23 | 24 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 25 | 26 | /** 27 | * Next we will register the CSRF Token as a common header with Axios so that 28 | * all outgoing HTTP requests automatically have it attached. This is just 29 | * a simple convenience so we don't have to attach every token manually. 30 | */ 31 | 32 | let token = document.head.querySelector('meta[name="csrf-token"]'); 33 | 34 | if (token) { 35 | window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; 36 | } else { 37 | console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); 38 | } 39 | 40 | /** 41 | * Echo exposes an expressive API for subscribing to channels and listening 42 | * for events that are broadcast by Laravel. Echo and event broadcasting 43 | * allows your team to easily build robust real-time web applications. 44 | */ 45 | 46 | // import Echo from 'laravel-echo' 47 | 48 | // window.Pusher = require('pusher-js'); 49 | 50 | // window.Echo = new Echo({ 51 | // broadcaster: 'pusher', 52 | // key: 'your-pusher-key' 53 | // }); 54 | -------------------------------------------------------------------------------- /tests/Feature/Reservation/PriceTest.php: -------------------------------------------------------------------------------- 1 | insert(["nextval" => 0]); 17 | return new EloquentReservationRepository; 18 | } 19 | /** 20 | * Total price test. 21 | * 22 | * @return void 23 | */ 24 | public function testGetTotalPrice() 25 | { 26 | $request = makeCorrectRequest(); 27 | 28 | $id = $this->repository()->nextIdentity(); 29 | $reservation = createReservation($id,$request); 30 | $this->assertEquals($reservation->getTotalPrice(),28500); 31 | } 32 | 33 | /** 34 | * Get option and Price set. 35 | * 36 | * @return void 37 | */ 38 | public function testGetOptionAndPriceSet() 39 | { 40 | 41 | $request = makeCorrectRequest(); 42 | 43 | $id = $this->repository()->nextIdentity(); 44 | $reservation = createReservation($id,$request); 45 | 46 | $options = $reservation->getOptionAndPriceSet(); 47 | 48 | $this->assertEquals($options,['ゴミ処理' => 1500,'カセットコンロ' => 1500,'宿泊(1〜3名様)' => 6000]); 49 | 50 | } 51 | 52 | /** 53 | * Get base price of plan. 54 | * 55 | * @return void 56 | */ 57 | public function testGetPriceOfPlan() 58 | { 59 | $request = makeCorrectRequest(); 60 | 61 | $id = $this->repository()->nextIdentity(); 62 | $reservation = createReservation($id,$request); 63 | 64 | $this->assertEquals(19500,$reservation->getPriceOfPlan()); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | mapApiRoutes(); 39 | 40 | $this->mapWebRoutes(); 41 | 42 | // 43 | } 44 | 45 | /** 46 | * Define the "web" routes for the application. 47 | * 48 | * These routes all receive session state, CSRF protection, etc. 49 | * 50 | * @return void 51 | */ 52 | protected function mapWebRoutes() 53 | { 54 | Route::middleware('web') 55 | ->namespace($this->namespace) 56 | ->group(base_path('routes/web.php')); 57 | } 58 | 59 | /** 60 | * Define the "api" routes for the application. 61 | * 62 | * These routes are typically stateless. 63 | * 64 | * @return void 65 | */ 66 | protected function mapApiRoutes() 67 | { 68 | Route::prefix('api') 69 | ->middleware('api') 70 | ->namespace($this->namespace) 71 | ->group(base_path('routes/api.php')); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Reservation/Status.php: -------------------------------------------------------------------------------- 1 | 'Contact', 11 | 'Confirmation' => 'Confirmation', 12 | 'BeforePayment' => 'BeforePayment', 13 | 'AfterPayment' => 'AfterPayment', 14 | 'BeforeUse' => 'BeforeUse', 15 | 'Used' => 'Used', 16 | 'Canceled' => 'Canceled', 17 | ]; 18 | 19 | 20 | public function toConfirmation() 21 | { 22 | if($this->value !== 'Contact'){ 23 | throw new \InvalidArgumentException('このステータスには変更出来ません'); 24 | } 25 | return new self('Confirmation'); 26 | } 27 | 28 | public function toBeforePayment() 29 | { 30 | if($this->value !== 'Confirmation'){ 31 | throw new \InvalidArgumentException('このステータスには変更出来ません'); 32 | } 33 | return new self('BeforePayment'); 34 | } 35 | 36 | public function toAfterPayment() 37 | { 38 | if($this->value !== 'BeforePayment'){ 39 | throw new \InvalidArgumentException('このステータスには変更出来ません'); 40 | } 41 | return new self('AfterPayment'); 42 | } 43 | 44 | public function toBeforeUse() 45 | { 46 | if($this->value !== 'AfterPayment'){ 47 | throw new \InvalidArgumentException('このステータスには変更出来ません'); 48 | } 49 | return new self('BeforeUse'); 50 | } 51 | 52 | public function toUsed() 53 | { 54 | if($this->value !== 'BeforeUse'){ 55 | throw new \InvalidArgumentException('このステータスには変更出来ません'); 56 | } 57 | return new self('Used'); 58 | } 59 | 60 | public function toCanceled() 61 | { 62 | return new self('Canceled'); 63 | } 64 | 65 | } 66 | 67 | 68 | ?> -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/Feature/Reservation/QuestionTest.php: -------------------------------------------------------------------------------- 1 | insert(["nextval" => 0]); 17 | return new EloquentReservationRepository; 18 | } 19 | /** 20 | * Question test. 21 | * 22 | * @return void 23 | */ 24 | public function testGetQuestion() 25 | { 26 | $request = makeCorrectRequest(); 27 | 28 | $id = $this->repository()->nextIdentity(); 29 | $reservation = createReservation($id,$request); 30 | 31 | $this->assertEquals('途中退出ありですか?',$reservation->getQuestion()); 32 | } 33 | 34 | public function testGetNoQuestion() 35 | { 36 | $request = makeCorrectRequest(); 37 | $request->question = null; 38 | 39 | $id = $this->repository()->nextIdentity(); 40 | $reservation = createReservation($id,$request); 41 | 42 | $this->assertEquals('',$reservation->getQuestion()); 43 | } 44 | 45 | public function testCheckHasQuestion() 46 | { 47 | $request = makeCorrectRequest(); 48 | 49 | $id = $this->repository()->nextIdentity(); 50 | $reservation = createReservation($id,$request); 51 | 52 | $this->assertTrue($reservation->hasQuestion()); 53 | } 54 | 55 | public function testCheckNotHasQuestion() 56 | { 57 | $request = makeCorrectRequest(); 58 | unset($request->question); 59 | 60 | $id = $this->repository()->nextIdentity(); 61 | $reservation = createReservation($id,$request); 62 | 63 | $this->assertTrue(!$reservation->hasQuestion()); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Reservation/Plan.php: -------------------------------------------------------------------------------- 1 | '【非商用】基本プラン(平日)', 15 | '【非商用】基本プラン(休日)' => '【非商用】基本プラン(休日)', 16 | '【非商用】お昼5時間パック' => '【非商用】お昼5時間パック', 17 | '【非商用】夜5時間パック' => '【非商用】夜5時間パック', 18 | '【商用】基本1日プラン' => '【商用】基本1日プラン', 19 | '【商用】お昼5時間パック' => '【商用】お昼5時間パック', 20 | '【商用】夜5時間パック' => '【商用】夜5時間パック', 21 | '【商用】3時間パック' => '【商用】3時間パック', 22 | '【商用】2時間パック' => '【商用】2時間パック', 23 | ]; 24 | //ここではプランコード(アスキー)だけ持たせて、表示するプラン名はViewに近いところで変換する 25 | //DBに登録するときもプランコード 26 | 27 | private const PriceOfPlanSet = [ 28 | 29 | '【非商用】基本プラン(平日)' => 19500, 30 | '【非商用】基本プラン(休日)' => 20500, 31 | '【非商用】お昼5時間パック' => 17000, 32 | '【非商用】夜5時間パック' => 18000, 33 | '【商用】基本1日プラン' => 28500, 34 | '【商用】お昼5時間パック' => 24000, 35 | '【商用】夜5時間パック' => 25000, 36 | '【商用】3時間パック' => 20000, 37 | '【商用】2時間パック' => 17000, 38 | ]; 39 | 40 | 41 | /** 42 | * @return String 43 | */ 44 | public function getPlan(): String 45 | { 46 | return $this->value; 47 | } 48 | 49 | public function getPrice(): int 50 | { 51 | return $this::PriceOfPlanSet[$this->value]; 52 | } 53 | 54 | public function hasShortTimePlan(): bool 55 | { 56 | return strpos($this->value, '2時間') || strpos($this->value, '3時間'); 57 | } 58 | 59 | public function hasTwoHourPlan() 60 | { 61 | return strpos($this->value, '2時間'); 62 | } 63 | 64 | public function hasThreeHourPlan() 65 | { 66 | return strpos($this->value, '3時間'); 67 | } 68 | 69 | public function hasDayTimePlan() 70 | { 71 | return strpos($this->value, '昼'); 72 | } 73 | 74 | 75 | } -------------------------------------------------------------------------------- /resources/views/emails/customer_r_nq.blade.php: -------------------------------------------------------------------------------- 1 | 2 |

{{ $reservation->getCustomer()->getName() }}様

3 | 4 |

この度はお問い合わせ頂きありがとうございます!

5 |

ASOBIBA101を運営しております香月(カツキ)と申します。

6 | 7 |

{{ $date }}/{{ $start }}〜{{ $end }}、{{ $reservation->getNumber()->getNumber() }}名様でご予約ご希望の旨承知致しました。

8 |

こちらのメールにてご予約受け付けさせて頂きます^^

9 |

以下に今後の手続きについてご案内させて頂きますので、 ご確認の上ご対応頂けますと幸いです。

10 | 11 |

[今後の手続き]

12 | 41 |

また、ゴミ・片づけ・注意事項・規約について下記ページに記載いたしますので予めご確認をお願いいたします。

42 |

※特に注意事項に反した場合、別途費用請求が発生してしまうケースもあるため、参加者全員への共有をお願いいたします。

43 |

(きになる点がございましたら出来るだけご希望に添えるように出来ればと思いますのでまずはご相談下さい^^)

44 | 45 |

46 | 規約(PC):http://asobiba101.com/rules.php 47 |

48 |

49 | 規約(スマホ):http://asoberu-house101.sakura.ne.jp/wp2/kiyaku 50 |

51 | 52 |

ご質問ございましたらお気軽にご連絡下さい^^

53 |

引き続き宜しくお願い致します。

54 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | define('LARAVEL_START', microtime(true)); 11 | 12 | /* 13 | |-------------------------------------------------------------------------- 14 | | Register The Auto Loader 15 | |-------------------------------------------------------------------------- 16 | | 17 | | Composer provides a convenient, automatically generated class loader for 18 | | our application. We just need to utilize it! We'll simply require it 19 | | into the script here so that we don't have to worry about manual 20 | | loading any of our classes later on. It feels great to relax. 21 | | 22 | */ 23 | 24 | require __DIR__.'/../vendor/autoload.php'; 25 | 26 | /* 27 | |-------------------------------------------------------------------------- 28 | | Turn On The Lights 29 | |-------------------------------------------------------------------------- 30 | | 31 | | We need to illuminate PHP development, so let us turn on the lights. 32 | | This bootstraps the framework and gets it ready for use, then it 33 | | will load up this application so that we can run it and send 34 | | the responses back to the browser and delight our users. 35 | | 36 | */ 37 | 38 | $app = require_once __DIR__.'/../bootstrap/app.php'; 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Run The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once we have the application, we can handle the incoming request 46 | | through the kernel, and send the associated response back to 47 | | the client's browser allowing them to enjoy the creative 48 | | and wonderful application we have prepared for them. 49 | | 50 | */ 51 | 52 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); 53 | 54 | $response = $kernel->handle( 55 | $request = Illuminate\Http\Request::capture() 56 | ); 57 | 58 | $response->send(); 59 | 60 | $kernel->terminate($request, $response); 61 | -------------------------------------------------------------------------------- /packages/Asobiba/Infrastructure/Repositories/EloquentCustomerRepository.php: -------------------------------------------------------------------------------- 1 | factory = $factory; 24 | } 25 | 26 | 27 | public function nextIdentity(): CustomerId 28 | { 29 | DB::table($this->sequence_table_name)->update(["nextval" => DB::raw("LAST_INSERT_ID(nextval + 1)")]); 30 | $customerId = DB::table($this->sequence_table_name)->selectRaw("LAST_INSERT_ID() as id")->first()->id; 31 | 32 | return new CustomerId($customerId); 33 | } 34 | 35 | public function new(array $req): Customer 36 | { 37 | $customerId = $this->nextIdentity(); 38 | return $this->factory->createFromRequest($customerId,$req); 39 | } 40 | /** 41 | * @param Reservation $reservation 42 | */ 43 | public function persist(Customer $customer) 44 | { 45 | DB::beginTransaction(); 46 | try { 47 | //Customerの永続化 48 | $eloquentCustomer = new EloquentCustomer(); 49 | $eloquentCustomer->id = $customer->getId()->getId(); 50 | $eloquentCustomer->name = $customer->getName()->getName(); 51 | $eloquentCustomer->email = $customer->getEmail()->getEmail(); 52 | $eloquentCustomer->save(); 53 | 54 | DB::commit(); 55 | 56 | } catch (\Exception $e) { 57 | 58 | DB::rollback(); 59 | dd($e->getMessage()); 60 | } 61 | } 62 | 63 | 64 | } 65 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/RegisterController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 40 | } 41 | 42 | /** 43 | * Get a validator for an incoming registration request. 44 | * 45 | * @param array $data 46 | * @return \Illuminate\Contracts\Validation\Validator 47 | */ 48 | protected function validator(array $data) 49 | { 50 | return Validator::make($data, [ 51 | 'name' => 'required|string|max:255', 52 | 'email' => 'required|string|email|max:255|unique:users', 53 | 'password' => 'required|string|min:6|confirmed', 54 | ]); 55 | } 56 | 57 | /** 58 | * Create a new user instance after a valid registration. 59 | * 60 | * @param array $data 61 | * @return \App\User 62 | */ 63 | protected function create(array $data) 64 | { 65 | return User::create([ 66 | 'name' => $data['name'], 67 | 'email' => $data['email'], 68 | 'password' => bcrypt($data['password']), 69 | ]); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /packages/Asobiba/Application/Services/AcceptanceReservationService.php: -------------------------------------------------------------------------------- 1 | customerRepo = $customerRepo; 29 | $this->reservationRepo = $reservationRepo; 30 | $this->notification = $notification; 31 | $this->availability = $availability; 32 | } 33 | 34 | //カスタマーからのリクエストを受け取ってDBに保存 + 自動返信メール送信 35 | public function reserve(array $req)//Requestに依存すると独自のリクエストクラスを定義した時にここにも変更を加えないといけない 36 | { 37 | 38 | //Reservationエンティティ生成 39 | $reservation = $this->reservationRepo->new($req); 40 | 41 | //空き状況チェック 42 | $this->isAvailable($reservation); 43 | //日程確保 44 | $this->keepDate($reservation); 45 | 46 | //Reservation永続化 47 | $this->reservationRepo->persist($reservation); 48 | //空き状況の永続化? 49 | 50 | //自動メール送信 51 | $this->notification->notifyToCustomer($reservation); 52 | $this->notification->notifyToManager($reservation); 53 | 54 | } 55 | 56 | 57 | private function isAvailable(Reservation $reservation): bool 58 | { 59 | return $this->availability->isAvailable($reservation); 60 | } 61 | 62 | private function keepDate(Reservation $reservation) 63 | { 64 | $this->availability->keepDate($reservation); 65 | } 66 | 67 | } 68 | 69 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Availability/Availability.php: -------------------------------------------------------------------------------- 1 | calendar = $calendar; 16 | date_default_timezone_set('Asia/Tokyo'); 17 | } 18 | 19 | 20 | /** 21 | * 空き状況チェック 22 | * @return bool 23 | */ 24 | public function isAvailable(Reservation $reservation): bool 25 | { 26 | //$reservationから日程、時間を抽出 27 | $startDateTime = $this->toDatetimeFormat($reservation->getdate()->getDate(),$reservation->getdate()->getStartTime()); 28 | $endDateTime = $this->toDatetimeFormat($reservation->getdate()->getDate(),$reservation->getDate()->getEndTime()); 29 | 30 | if($this->calendar->isBusy($startDateTime,$endDateTime)){ 31 | //独自例外に変更 32 | throw new \InvalidArgumentException('ご希望の時間帯は別の方が予約済みです'); 33 | } 34 | return true; 35 | } 36 | 37 | //予約追加の成否をbooleanで返す 38 | public function keepDate(Reservation $reservation): bool 39 | { 40 | 41 | $startDateTime = $this->toDatetimeFormat($reservation->getdate()->getDate(),$reservation->getdate()->getStartTime()); 42 | $endDateTime = $this->toDatetimeFormat($reservation->getdate()->getDate(),$reservation->getDate()->getEndTime()); 43 | $summary = '仮押さえ(自)'; 44 | 45 | if(!$this->calendar->createEvent($startDateTime,$endDateTime,$summary)){ 46 | //独自例外に変更 47 | throw new \UnexpectedValueException('日程の確保に失敗しました'); 48 | } 49 | return true; 50 | } 51 | 52 | //Reservationから抽出した日程をフォーマット 53 | private function toDatetimeFormat(string $date,int $hour) 54 | { 55 | 56 | $date = $hour === 9 ? date('Y-m-d',strtotime($date.'+ 1 day')) : $date; 57 | 58 | $dateArr = explode('-',$date); 59 | $year = $dateArr[0]; 60 | $month = $dateArr[1]; 61 | $day = $dateArr[2]; 62 | 63 | $datetime = date('c',mktime($hour,0,0,$month,$day,$year)); 64 | 65 | return $datetime; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | [ 31 | \App\Http\Middleware\EncryptCookies::class, 32 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 33 | \Illuminate\Session\Middleware\StartSession::class, 34 | // \Illuminate\Session\Middleware\AuthenticateSession::class, 35 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 36 | \App\Http\Middleware\VerifyCsrfToken::class, 37 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 38 | ], 39 | 40 | 'api' => [ 41 | 'throttle:60,1', 42 | 'bindings', 43 | ], 44 | ]; 45 | 46 | /** 47 | * The application's route middleware. 48 | * 49 | * These middleware may be assigned to groups or used individually. 50 | * 51 | * @var array 52 | */ 53 | protected $routeMiddleware = [ 54 | 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, 55 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 56 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 57 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 58 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 59 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 60 | ]; 61 | } 62 | -------------------------------------------------------------------------------- /tests/Feature/Reservation/RepositoryTest.php: -------------------------------------------------------------------------------- 1 | insert(["nextval" => 0]); 21 | return new EloquentReservationRepository; 22 | } 23 | 24 | public function finish() 25 | { 26 | //要修正 27 | DB::delete('delete from customers'); 28 | DB::statement("alter table customers auto_increment = 1"); 29 | DB::statement("alter table options auto_increment = 1"); 30 | 31 | } 32 | 33 | /** 34 | * A basic test example. 35 | * 36 | * @return void 37 | */ 38 | public function testAddReservationToDB() 39 | { 40 | 41 | $request = makeCorrectRequest(); 42 | 43 | 44 | $customer = new Customer($request->name, $request->email); 45 | $id = $this->repository()->nextIdentity(); 46 | $reservation = createReservation($id, $request); 47 | $this->repository()->add($customer, $reservation);//DBに保存 48 | 49 | $this->assertDatabaseHas('reservations', [ 50 | 'plan' => '【非商用】基本プラン(平日)', 51 | 'id' => 1, 52 | 'customer_id' => 1, 53 | 'status' => 'Contact', 54 | 'price' => 19500, 55 | 'date' => '2017-11-26', 56 | 'number' => 10 57 | ]); 58 | 59 | $this->assertDatabaseHas('customers', [ 60 | 'name' => 'テストユーザー', 61 | 'email' => 'sansan106700@gmail.com' 62 | ]); 63 | 64 | $options = ['ゴミ処理' => 1500, 'カセットコンロ' => 1500, '宿泊(1〜3名様)' => 6000]; 65 | foreach ($options as $option => $price) { 66 | $this->assertDatabaseHas('options', [ 67 | 'option' => $option, 68 | 'price' => $price 69 | ]); 70 | } 71 | $this->finish(); 72 | 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /storage/json/google_api_secret_key.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "service_account", 3 | "project_id": "asobiba101", 4 | "private_key_id": "5fb165260f3f1f8f7887fa5a5b47507f97025e60", 5 | "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCWJaXi6CkBr1ob\nmOYQuPGUUZ40xCUGVDNJHGY6xVkYIUkTy3msviaRQvCve7EWaEGjdb07DAdQpuVS\nJ+yNuRyb7Duuwi98LkXTAe/Ejw9FwempNasfVCWCUFy/Li3CNBWO/CX4sABDpo0a\nglCKjGFsG1ZkMfulCMEUc0xqVnBF+lohr2gJJm925M7D8j1Io+lGRN442jiCdgWO\npyfo6Xx2/ul/eIWHSEZJeUZhTTr37bF5F1qmiKTa4ShmSuYXAvU5tX8XsOHW0o1p\nX7w2mgXKLBsMvanUUTjmXkCLQtZZxFjHfTcsfjyk3mA9sQdG2ln+EYrHN7echVTx\nn+LLezZrAgMBAAECggEABYskTHQNN4kK3E6mh+LcKywMREnNotCEXY7/3exKtXpd\nIVmiMhTfMFPMC8lBqOB2iUYf6MiGk0gQ2sSrQNxJyHP4ts4SmhTMnSrKzcizuVFH\nLZPUBUHCahpKIlYzzaIbUv56RGvzG+GlVLTlAQiH0Z78xJGX3JMDK0cf1iPqMfCA\nMnku8Asa2LkYjeUPPEIORgyhXLwBQEG6gdnY7GGkWydo2Qk9wtAniOsCJIrvjzEQ\nTROAQavQ8X/iF81erDapwiz/1e3U9wjeNMT1yruOGZ1IEcZr1ZOW2BFPzLoJ5sl0\n5mkk/gRZGs/klADZIkhqi4ShP7l+95k8GgfP76FOAQKBgQDIG0Hn4oUUWM7uOaLj\nsGOvuMqeyw0JtFhroipwLIa8D5aMQUfx4eEfEj34mjAheTssTBAm90Ieyfv/JyGP\nALMDyhcY3o08Hna3mYpTcdrqdaLkGAygW3ny6RdA2jsAo2Df2kxN/11IiyQO4lfj\n0ItBKIzidYmIvQAT7CznC3ETAQKBgQDAFgK0iHSLND0rhJo1BmSQTBp9osSvZQX/\nZRi5wdPYDdr6+nfxRej3xkkxQmWz4OJTJzHf34MwDX4evD0BAqId/qZ5YWnf0Xx3\ncQ4F8ui0KFeFszhcYkvI72aupRejZ8/hMENrHdKB/wgBB9O+8EXpIBamhKrmkRD6\nAGpGrhlFawKBgQDEh/DMu+8UMrzZwAW5Ng5SEV3/Y1GkzFljLNwdW73gijbD/YGZ\nkM03ZQU0WssWtShmszXR71ojPyGeUWJmPruS5zKUHE/+UbUrUUNH/TSSvYKEHxKX\nlABLkJ5j9XGpiMymTpJOsJV/oBiD/c1wU+vQzPDBocq4X1fqOTVInjYqAQKBgQCC\nCCRqrBkhBwsFw61UifBX0nz4YdB934iQ3JJBZZoQH0kHL7k0ZpwP53Yy13zbqTft\nDJJxt/Ap/mhLTCiL34l5fqKZdr1iW4DDpo/UrRykoM6m3q0ftRcSfiXnwjDfWG5c\nRfzNrZGMmOWFNRQ9pI/fAe7zaMn8bWWtp8xJ7p+C4wKBgE2bNjtjyGLT6BA00ciJ\npf7GYOYkcg6tzFvNFL3Auc4Pl4pNKjGm+RCT+d1/bdwsdPerxRYmvYDoRE29JdkE\noAc2dV1Tha1I0w+rauJmzSBnaMi5hxELSJuBhZP1IRsK66bA/CS1gkT8gCGHdCmY\nX/yh+6Z4lYPEUueWbN8VPSOl\n-----END PRIVATE KEY-----\n", 6 | "client_email": "admin-769@asobiba101.iam.gserviceaccount.com", 7 | "client_id": "105756618453169201783", 8 | "auth_uri": "https://accounts.google.com/o/oauth2/auth", 9 | "token_uri": "https://accounts.google.com/o/oauth2/token", 10 | "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", 11 | "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/admin-769%40asobiba101.iam.gserviceaccount.com" 12 | } 13 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DRIVER', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default Cloud Filesystem Disk 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Many applications store files both locally and in the cloud. For this 24 | | reason, you may specify a default "cloud" driver here. This driver 25 | | will be bound as the Cloud disk implementation in the container. 26 | | 27 | */ 28 | 29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Filesystem Disks 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here you may configure as many filesystem "disks" as you wish, and you 37 | | may even configure multiple disks of the same driver. Defaults have 38 | | been setup for each driver as an example of the required options. 39 | | 40 | | Supported Drivers: "local", "ftp", "s3", "rackspace" 41 | | 42 | */ 43 | 44 | 'disks' => [ 45 | 46 | 'local' => [ 47 | 'driver' => 'local', 48 | 'root' => storage_path('app'), 49 | ], 50 | 51 | 'public' => [ 52 | 'driver' => 'local', 53 | 'root' => storage_path('app/public'), 54 | 'url' => env('APP_URL').'/storage', 55 | 'visibility' => 'public', 56 | ], 57 | 58 | 's3' => [ 59 | 'driver' => 's3', 60 | 'key' => env('AWS_KEY'), 61 | 'secret' => env('AWS_SECRET'), 62 | 'region' => env('AWS_REGION'), 63 | 'bucket' => env('AWS_BUCKET'), 64 | ], 65 | 66 | ], 67 | 68 | ]; 69 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Reservation/DateOfUse.php: -------------------------------------------------------------------------------- 1 | 16, 17 | 'end' => 17, 18 | ]; 19 | 20 | public function __construct($date,$start_time,$end_time,Plan $plan,Options $options) 21 | { 22 | 23 | if(!$this->isAcceptableStartAndEndTime($start_time,$end_time,$plan)){ 24 | throw new \InvalidArgumentException('不正な開始時刻又は終了時刻が入力されています'); 25 | } 26 | if(!$this->isAcceptableMaxTime($start_time,$end_time,$plan)){ 27 | throw new \InvalidArgumentException('プランで指定された利用時間をオーバーしています'); 28 | } 29 | if(!$this->notCleaningTime($plan,$start_time,$end_time)){ 30 | throw new \InvalidArgumentException('2or3時間パックの場合16時~17時以外で指定して下さい'); 31 | } 32 | $this->date = $date; 33 | $this->start_time = $start_time; 34 | $this->end_time = $this->optimizeEndTime($options,$end_time); 35 | } 36 | 37 | 38 | private function isAcceptableStartAndEndTime($start_time,$end_time,$plan) 39 | { 40 | return $start_time >= AcceptableTime::acceptableStartTime($plan) && $end_time <= AcceptableTime::acceptableEndTime($plan); 41 | } 42 | 43 | private function isAcceptableMaxTime($start_time,$end_time,$plan) 44 | { 45 | if($plan->hasTwoHourPlan()){ 46 | return $end_time - $start_time <= 2; 47 | } 48 | if($plan->hasThreeHourPlan()){ 49 | return $end_time - $start_time <= 3; 50 | } 51 | return true; 52 | } 53 | 54 | private function optimizeEndTime($options,$end_time) 55 | { 56 | if($options->hasMidnightOption()){ 57 | return 24; 58 | } 59 | if($options->hasStayOption()){ 60 | return 9; 61 | } 62 | return $end_time; 63 | } 64 | 65 | public function getDate(): string 66 | { 67 | return $this->date; 68 | } 69 | 70 | public function getStartTime():int 71 | { 72 | return $this->start_time; 73 | } 74 | 75 | public function getEndTime():int 76 | { 77 | return $this->end_time; 78 | } 79 | 80 | public function notCleaningTime($plan,$start_time,$end_time):bool 81 | { 82 | if($plan->hasShortTimePlan()) { 83 | return $start_time >= $this->cleaningTime['end'] || $end_time <= $this->cleaningTime['start']; 84 | } 85 | return true; 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /packages/Asobiba/Infrastructure/Calendar/GoogleCalendar.php: -------------------------------------------------------------------------------- 1 | client = new Google_Client(); 23 | $this->client->useApplicationDefaultCredentials(); 24 | $this->client->addScope(Google_Service_Calendar::CALENDAR);//https://www.googleapis.com/auth/calendar 25 | $this->service = new \Google_Service_Calendar($this->client); 26 | $this->calendarId = env('GOOGLE_CALENDAR_ID'); 27 | 28 | } 29 | 30 | 31 | public function isBusy(string $startDateTime,string $endDateTime): bool 32 | { 33 | $this->freebusyReq = new Google_Service_Calendar_FreeBusyRequest( 34 | [ 35 | 'timeMin' => $startDateTime, 36 | 'timeMax' => $endDateTime, 37 | 'timeZone' => 'Asia/Tokyo', 38 | 'items' => [ 39 | ['id' => $this->calendarId] 40 | ] 41 | ] 42 | ); 43 | 44 | $result = $this->service->freebusy->query($this->freebusyReq); 45 | if($result->getCalendars()[$this->calendarId]->getBusy() === []){ 46 | return false; 47 | } 48 | return true; 49 | } 50 | 51 | public function createEvent(string $startDateTime,string $endDateTime,string $summary = '',string $location = '',string $desc = '') 52 | { 53 | try { 54 | $event = new \Google_Service_Calendar_Event([ 55 | 'summary' => $summary, 56 | 'location' => $location, 57 | 'description' => $desc, 58 | 'start' => [ 59 | 'dateTime' => $startDateTime, 60 | 'timeZone' => 'Asia/Tokyo', 61 | ], 62 | 'end' => [ 63 | 'dateTime' => $endDateTime, 64 | 'timeZone' => 'Asia/Tokyo', 65 | ] 66 | ]); 67 | $new_event = $this->service->events->insert($this->calendarId, $event); 68 | $eventId = $new_event->getId(); 69 | 70 | return $eventId; 71 | }catch(\Exception $e){ 72 | return false; 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->bind( 39 | ReservationRepositoryInterface::class, 40 | EloquentReservationRepository::class 41 | ); 42 | $this->app->bind( 43 | CustomerRepositoryInterface::class, 44 | EloquentCustomerRepository::class 45 | ); 46 | $this->app->bind( 47 | ReservationNotificationInterface::class, 48 | MailReservationNotification::class 49 | ); 50 | $this->app->bind( 51 | CalendarInterface::class, 52 | GoogleCalendar::class 53 | ); 54 | $this->app->bind( 55 | Availability::class,function(){ 56 | return new Availability( 57 | $this->app->make(CalendarInterface::class) 58 | ); 59 | }); 60 | $this->app->bind(AcceptanceReservationService::class,function(){ 61 | return new AcceptanceReservationService( 62 | $this->app->make(CustomerRepositoryInterface::class), 63 | $this->app->make(ReservationRepositoryInterface::class), 64 | $this->app->make(ReservationNotificationInterface::class), 65 | $this->app->make(Availability::class) 66 | ); 67 | } 68 | ); 69 | $this->app->bind(ReservationFactory::class,function(){ 70 | return new ReservationFactory( 71 | new CustomerFactory() 72 | ); 73 | }); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_DRIVER', 'sync'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Queue Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may configure the connection information for each server that 26 | | is used by your application. A default configuration has been added 27 | | for each back-end shipped with Laravel. You are free to add more. 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 | ], 43 | 44 | 'beanstalkd' => [ 45 | 'driver' => 'beanstalkd', 46 | 'host' => 'localhost', 47 | 'queue' => 'default', 48 | 'retry_after' => 90, 49 | ], 50 | 51 | 'sqs' => [ 52 | 'driver' => 'sqs', 53 | 'key' => 'your-public-key', 54 | 'secret' => 'your-secret-key', 55 | 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id', 56 | 'queue' => 'your-queue-name', 57 | 'region' => 'us-east-1', 58 | ], 59 | 60 | 'redis' => [ 61 | 'driver' => 'redis', 62 | 'connection' => 'default', 63 | 'queue' => 'default', 64 | 'retry_after' => 90, 65 | ], 66 | 67 | ], 68 | 69 | /* 70 | |-------------------------------------------------------------------------- 71 | | Failed Queue Jobs 72 | |-------------------------------------------------------------------------- 73 | | 74 | | These options configure the behavior of failed queue job logging so you 75 | | can control which database and table are used to store the jobs that 76 | | have failed. You may change them to any database / table you wish. 77 | | 78 | */ 79 | 80 | 'failed' => [ 81 | 'database' => env('DB_CONNECTION', 'mysql'), 82 | 'table' => 'failed_jobs', 83 | ], 84 | 85 | ]; 86 | -------------------------------------------------------------------------------- /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 | */ 30 | 31 | 'stores' => [ 32 | 33 | 'apc' => [ 34 | 'driver' => 'apc', 35 | ], 36 | 37 | 'array' => [ 38 | 'driver' => 'array', 39 | ], 40 | 41 | 'database' => [ 42 | 'driver' => 'database', 43 | 'table' => 'cache', 44 | 'connection' => null, 45 | ], 46 | 47 | 'file' => [ 48 | 'driver' => 'file', 49 | 'path' => storage_path('framework/cache/data'), 50 | ], 51 | 52 | 'memcached' => [ 53 | 'driver' => 'memcached', 54 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 55 | 'sasl' => [ 56 | env('MEMCACHED_USERNAME'), 57 | env('MEMCACHED_PASSWORD'), 58 | ], 59 | 'options' => [ 60 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 61 | ], 62 | 'servers' => [ 63 | [ 64 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 65 | 'port' => env('MEMCACHED_PORT', 11211), 66 | 'weight' => 100, 67 | ], 68 | ], 69 | ], 70 | 71 | 'redis' => [ 72 | 'driver' => 'redis', 73 | 'connection' => 'default', 74 | ], 75 | 76 | ], 77 | 78 | /* 79 | |-------------------------------------------------------------------------- 80 | | Cache Key Prefix 81 | |-------------------------------------------------------------------------- 82 | | 83 | | When utilizing a RAM based store such as APC or Memcached, there might 84 | | be other applications utilizing the same cache. So, we'll specify a 85 | | value to get prefixed to all our keys so we can avoid collisions. 86 | | 87 | */ 88 | 89 | 'prefix' => 'laravel', 90 | 91 | ]; 92 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## 業務内容など 2 | 3 | こちらのスライド参照(業務内容はP7以降) 4 |
YYPHP #13 初めてのコードレビュー
5 | 6 | 7 | ## 業務ルール 8 | 9 |

予約内容には以下の項目が含まれる

10 | 21 | 22 | 23 |

プランに関するルール

24 | 27 | 28 |

オプションに関する基本ルール

29 | 50 | 51 |

日程に関する基本ルール

52 | 60 | 61 |

開始時間に関する基本ルール

62 | 69 | 70 |

終了時間に関する基本ルール

71 | 92 | 93 |

利用時間帯に関するルール

94 | 103 | 104 |

利用人数に関する基本ルール

105 | 120 | 121 |

利用用途に関する基本ルール

122 | 125 | 126 |

質問に関する基本ルール

127 | 141 | 142 | 143 |

ステータスに関する基本ルール

144 | 160 | 161 | ## クラス図 162 | 163 | 164 | -------------------------------------------------------------------------------- /tests/Feature/Reservation/NotifyTest.php: -------------------------------------------------------------------------------- 1 | insert(["nextval" => 0]); 21 | DB::table('customer_seqs')->insert(["nextval" => 0]); 22 | } 23 | 24 | public function finish() 25 | { 26 | //要修正 27 | DB::delete('delete from customer_seqs'); 28 | DB::delete('delete from reservation_seqs'); 29 | DB::delete('delete from customers'); 30 | DB::statement("alter table options auto_increment = 1"); 31 | 32 | } 33 | /** 34 | * A basic test example. 35 | * 36 | * @return void 37 | */ 38 | public function testNotifyToCustomerWithQuestion() 39 | { 40 | $this->prepare(); 41 | 42 | $req = reqToArray(makeCorrectRequest()); 43 | 44 | //Notificationの生成 45 | $notification = $this->app->make(ReservationNotificationInterface::class); 46 | 47 | //一意な識別子の生成 48 | $customerRepo = $this->app->make(CustomerRepositoryInterface::class); 49 | $reservationRepo = $this->app->make(ReservationRepositoryInterface::class); 50 | $customerId = $customerRepo->nextIdentity(); 51 | $reservationId = $reservationRepo->nextIdentity(); 52 | 53 | //Reservationエンティティの生成 54 | $factory = $this->app->make(ReservationFactory::class); 55 | $reservation = $factory->createFromRequest($customerId,$reservationId,$req); 56 | 57 | $notification->notifyToCustomer($reservation); 58 | 59 | $this->assertTrue(true); 60 | 61 | $this->finish(); 62 | } 63 | 64 | public function testNotifyToCustomerWithoutQuestion() 65 | { 66 | $this->prepare(); 67 | 68 | $req = reqToArray(makeRequestWithoutQuestion()); 69 | 70 | //Notificationの生成 71 | $notification = $this->app->make(ReservationNotificationInterface::class); 72 | 73 | //一意な識別子の生成 74 | $customerRepo = $this->app->make(CustomerRepositoryInterface::class); 75 | $reservationRepo = $this->app->make(ReservationRepositoryInterface::class); 76 | $customerId = $customerRepo->nextIdentity(); 77 | $reservationId = $reservationRepo->nextIdentity(); 78 | 79 | //Reservationエンティティの生成 80 | $factory = $this->app->make(ReservationFactory::class); 81 | $reservation = $factory->createFromRequest($customerId,$reservationId,$req); 82 | 83 | $notification->notifyToCustomer($reservation); 84 | 85 | $this->assertTrue(true); 86 | 87 | $this->finish(); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /resources/views/welcome.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Laravel 9 | 10 | 11 | 12 | 13 | 14 | 66 | 67 | 68 |
69 | @if (Route::has('login')) 70 | 78 | @endif 79 | 80 |
81 |
82 | Laravel 83 |
84 | 85 | 92 |
93 |
94 | 95 | 96 | -------------------------------------------------------------------------------- /tests/utilities/functions.php: -------------------------------------------------------------------------------- 1 | name = 'テストユーザー'; 9 | $request->email = 'sansan106700@gmail.com'; 10 | $request->plan = '【非商用】基本プラン(平日)'; 11 | $request->options = ['ゴミ処理', 'カセットコンロ', '宿泊(1〜3名様)']; 12 | $request->date = '2017-11-26'; 13 | $request->start_time = 11; 14 | $request->end_time = 22; 15 | $request->number = 10; 16 | $request->purpose = '再現VTR'; 17 | $request->question = '途中退出ありですか?'; 18 | 19 | return $request; 20 | } 21 | 22 | function makeOtherRequest() 23 | { 24 | $request = new Illuminate\Http\Request(); 25 | $request->name = 'テストユーザー2'; 26 | $request->email = 'te106700@gmail.com'; 27 | $request->plan = '【商用】3時間パック'; 28 | $request->options = ['ゴミ処理', '宿泊(1〜3名様)', '電気グリル鍋']; 29 | $request->date = '2018-03-12'; 30 | $request->start_time = 19; 31 | $request->end_time = 22; 32 | $request->number = 10; 33 | $request->purpose = '再現VTR'; 34 | $request->question = 'いくらになりますか?'; 35 | 36 | return $request; 37 | } 38 | 39 | function makeRequestWithoutQuestion() 40 | { 41 | $request = new Illuminate\Http\Request(); 42 | $request->name = 'テストユーザー2'; 43 | $request->email = 'te106700@gmail.com'; 44 | $request->plan = '【商用】3時間パック'; 45 | $request->options = ['ゴミ処理', '宿泊(1〜3名様)', '電気グリル鍋']; 46 | $request->date = '2018-03-12'; 47 | $request->start_time = 19; 48 | $request->end_time = 22; 49 | $request->number = 10; 50 | $request->purpose = '再現VTR'; 51 | $request->question = null; 52 | 53 | return $request; 54 | } 55 | 56 | function makeOtherRequestWithPurpose() 57 | { 58 | $request = new Illuminate\Http\Request(); 59 | $request->name = 'テストユーザー2'; 60 | $request->email = 'te106700@gmail.com'; 61 | $request->plan = '【商用】3時間パック'; 62 | $request->options = ['ゴミ処理', '宿泊(1〜3名様)', '電気グリル鍋']; 63 | $request->date = '2018-03-12'; 64 | $request->start_time = 19; 65 | $request->end_time = 22; 66 | $request->number = 10; 67 | $request->purpose = '再現VTR'; 68 | $request->question = 'いくらになりますか?'; 69 | 70 | return $request; 71 | } 72 | 73 | function createReservation($id, $request) 74 | { 75 | return new Asobiba\Domain\Models\Reservation\Reservation( 76 | $id, 77 | $request->options, 78 | $request->plan, 79 | $request->number, 80 | $request->date, 81 | $request->start_time, 82 | $request->end_time, 83 | $request->purpose, 84 | $request->question 85 | ); 86 | } 87 | 88 | function reqToArray(Request $req): array 89 | { 90 | $exception = [ 91 | 'attributes', 92 | 'request', 93 | 'query', 94 | 'server', 95 | 'files', 96 | 'cookies', 97 | 'headers' 98 | ]; 99 | 100 | foreach($req as $key => $value){ 101 | if(in_array($key,$exception)){ 102 | continue; 103 | } 104 | $array[$key] = $value; 105 | } 106 | return $array; 107 | } -------------------------------------------------------------------------------- /tests/Feature/Reservation/ServiceTest.php: -------------------------------------------------------------------------------- 1 | insert(["nextval" => 0]); 18 | } 19 | 20 | public function finish() 21 | { 22 | //要修正 23 | DB::delete('delete from reservation_seqs'); 24 | DB::statement("alter table options auto_increment = 1"); 25 | 26 | } 27 | 28 | /** 29 | * A basic test example. 30 | * 31 | * @return void 32 | */ 33 | public function testReserve() 34 | { 35 | $this->prepare(); 36 | 37 | //1つ目の予約 38 | $request = reqToArray(makeCorrectRequest()); 39 | 40 | $service = $this->app->make(AcceptanceReservationService::class); 41 | $service->reserve($request); 42 | 43 | $this->assertDatabaseHas('reservations', [ 44 | 'plan' => '【非商用】基本プラン(平日)', 45 | 'id' => 1, 46 | 'name' => 'テストユーザー', 47 | 'email' => 'sansan106700@gmail.com', 48 | 'status' => 'Contact', 49 | 'price' => 19500, 50 | 'date' => '2017-11-26', 51 | 'number' => 10 52 | ]); 53 | 54 | 55 | $options = ['ゴミ処理' => 1500, 'カセットコンロ' => 1500, '宿泊(1〜3名様)' => 6000]; 56 | foreach ($options as $option => $price) { 57 | $this->assertDatabaseHas('options', [ 58 | 'option' => $option, 59 | 'price' => $price 60 | ]); 61 | } 62 | 63 | 64 | //2つ目の予約 65 | $request2 = reqToArray(makeCorrectRequest()); 66 | $service->reserve($request2); 67 | 68 | $this->assertDatabaseHas('reservations', [ 69 | 'plan' => '【非商用】基本プラン(平日)', 70 | 'id' => 2, 71 | 'name' => 'テストユーザー', 72 | 'email' => 'sansan106700@gmail.com', 73 | 'status' => 'Contact', 74 | 'price' => 19500, 75 | 'date' => '2017-11-26', 76 | 'number' => 10 77 | ]); 78 | 79 | $options = ['ゴミ処理' => 1500, 'カセットコンロ' => 1500, '宿泊(1〜3名様)' => 6000]; 80 | foreach ($options as $option => $price) { 81 | $this->assertDatabaseHas('options', [ 82 | 'option' => $option, 83 | 'price' => $price 84 | ]); 85 | } 86 | 87 | 88 | $this->finish(); 89 | } 90 | 91 | //予約済み日程での予約の場合 92 | public function testCheckCalenderNotAvailable() 93 | { 94 | $request = reqToArray(makeCorrectRequest()); 95 | 96 | $service = $this->app->make(AcceptanceReservationService::class); 97 | 98 | try { 99 | $service->reserve($request); 100 | $this->fail('例外無し'); 101 | }catch(\InvalidArgumentException $e){ 102 | $this->assertEquals('ご希望の時間帯は別の方が予約済みです',$e->getMessage()); 103 | } 104 | 105 | } 106 | 107 | public function testRequestToArray() 108 | { 109 | $request = makeCorrectRequest(); 110 | 111 | $array = reqToArray($request); 112 | dd($array); 113 | 114 | $this->assertTrue(true); 115 | 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /packages/Asobiba/Infrastructure/Repositories/EloquentReservationRepository.php: -------------------------------------------------------------------------------- 1 | factory = $factory; 25 | } 26 | 27 | 28 | /** 29 | * @return ReservationId 30 | */ 31 | public function nextIdentity(): ReservationId 32 | { 33 | DB::table($this->sequence_table_name)->update(["nextval" => DB::raw("LAST_INSERT_ID(nextval + 1)")]); 34 | $reservationId = DB::table($this->sequence_table_name)->selectRaw("LAST_INSERT_ID() as id")->first()->id; 35 | 36 | return new ReservationId($reservationId); 37 | } 38 | 39 | 40 | /** 41 | * @param array $req 42 | * @return Reservation 43 | */ 44 | public function new(array $req): Reservation 45 | { 46 | //エンティティの一意な識別子を生成 47 | $reservationId = $this->nextIdentity(); 48 | 49 | //Reservationエンティティの生成 50 | return $this->factory->createFromRequest($reservationId, $req); 51 | } 52 | 53 | /** 54 | * @param Reservation $reservation 55 | */ 56 | public function persist(Reservation $reservation) 57 | { 58 | DB::beginTransaction(); 59 | try { 60 | //Reservationの永続化 61 | $eloquentReservation = new EloquentReservation(); 62 | $eloquentReservation->id = $reservation->getId()->getId(); 63 | $eloquentReservation->name = $reservation->getCustomer()->getName(); 64 | $eloquentReservation->email = $reservation->getCustomer()->getEmail(); 65 | $eloquentReservation->plan = $reservation->getPlan()->getPlan(); 66 | $eloquentReservation->price = $reservation->getPlan()->getPrice(); 67 | $eloquentReservation->number = $reservation->getNumber()->getNumber(); 68 | $eloquentReservation->date = $reservation->getDate()->getDate(); 69 | $eloquentReservation->start_time = $reservation->getDate()->getStartTime(); 70 | $eloquentReservation->end_time = $reservation->getDate()->getEndTime(); 71 | $eloquentReservation->question = $reservation->getQuestion()->getQuestion(); 72 | $eloquentReservation->status = $reservation->getStatus(); 73 | $eloquentReservation->save(); 74 | 75 | //Reservationと関連するオプションの永続化 76 | if ($reservation->getOptionAndPriceSet()) { 77 | foreach ($reservation->getOptionAndPriceSet() as $optionName => $price) { 78 | $option = new EloquentOption(); 79 | $option->reservation_id = $reservation->getId()->getId(); 80 | $option->option = $optionName; 81 | $option->price = $price; 82 | $option->save(); 83 | } 84 | } 85 | 86 | DB::commit(); 87 | 88 | } catch (\Exception $e) { 89 | 90 | DB::rollback(); 91 | dd($e->getMessage()); 92 | 93 | } 94 | 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /tests/Feature/Reservation/CapacityTest.php: -------------------------------------------------------------------------------- 1 | insert(["nextval" => 0]); 18 | return new EloquentReservationRepository; 19 | } 20 | 21 | /** 22 | * Capacity test. 23 | * 24 | * @return void 25 | */ 26 | public function testOverCapacityNotBusinessPlan() 27 | { 28 | $request = makeCorrectRequest(); 29 | $request->number = 13; 30 | 31 | try{ 32 | $id = $this->repository()->nextIdentity(); 33 | createReservation($id,$request); 34 | $this->fail('例外発生無し'); 35 | }catch(\InvalidArgumentException $e){ 36 | $this->assertEquals('適切な利用人数を設定して下さい',$e->getMessage()); 37 | } 38 | } 39 | 40 | public function testOverCapacityBusinessPlan() 41 | { 42 | $request = makeCorrectRequest(); 43 | $request->plan = '【商用】基本1日プラン'; 44 | $request->number = 16; 45 | 46 | try{ 47 | $id = $this->repository()->nextIdentity(); 48 | createReservation($id,$request); 49 | $this->fail('例外発生無し'); 50 | }catch(\InvalidArgumentException $e){ 51 | $this->assertEquals('適切な利用人数を設定して下さい',$e->getMessage()); 52 | } 53 | } 54 | 55 | 56 | public function testOverCapacityNotBusinessPlanWithLargeGroupOption() 57 | { 58 | $request = makeCorrectRequest(); 59 | $request->options[] = '大人数レイアウト'; 60 | $request->number = 16; 61 | 62 | try{ 63 | $id = $this->repository()->nextIdentity(); 64 | createReservation($id,$request); 65 | $this->fail('例外発生無し'); 66 | }catch(\InvalidArgumentException $e){ 67 | $this->assertEquals('適切な利用人数を設定して下さい',$e->getMessage()); 68 | } 69 | } 70 | 71 | 72 | public function testCapacityOkNotBusinessPlan() 73 | { 74 | $request = makeCorrectRequest(); 75 | $request->number = 11; 76 | 77 | try{ 78 | $id = $this->repository()->nextIdentity(); 79 | createReservation($id,$request); 80 | $this->assertTrue(true); 81 | }catch(\InvalidArgumentException $e){ 82 | $this->fail($e->getMessage()); 83 | } 84 | } 85 | 86 | public function testCapacityOkBusinessPlan() 87 | { 88 | $request = makeCorrectRequest(); 89 | $request->plan = '【商用】基本1日プラン'; 90 | $request->number = 13; 91 | 92 | try{ 93 | $id = $this->repository()->nextIdentity(); 94 | createReservation($id,$request); 95 | $this->assertTrue(true); 96 | }catch(\InvalidArgumentException $e){ 97 | $this->fail($e->getMessage()); 98 | } 99 | } 100 | 101 | public function testCapacityOkNotBusinessPlanWithLargeGroupOption() 102 | { 103 | $request = makeCorrectRequest(); 104 | $request->options[] = '大人数レイアウト'; 105 | $request->number = 15; 106 | 107 | try{ 108 | $id = $this->repository()->nextIdentity(); 109 | createReservation($id,$request); 110 | $this->assertTrue(true); 111 | }catch(\InvalidArgumentException $e){ 112 | $this->fail($e->getMessage()); 113 | } 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /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", "token" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | 44 | 'api' => [ 45 | 'driver' => 'token', 46 | 'provider' => 'users', 47 | ], 48 | ], 49 | 50 | /* 51 | |-------------------------------------------------------------------------- 52 | | User Providers 53 | |-------------------------------------------------------------------------- 54 | | 55 | | All authentication drivers have a user provider. This defines how the 56 | | users are actually retrieved out of your database or other storage 57 | | mechanisms used by this application to persist your user's data. 58 | | 59 | | If you have multiple user tables or models you may configure multiple 60 | | sources which represent each model / table. These sources may then 61 | | be assigned to any extra authentication guards you have defined. 62 | | 63 | | Supported: "database", "eloquent" 64 | | 65 | */ 66 | 67 | 'providers' => [ 68 | 'users' => [ 69 | 'driver' => 'eloquent', 70 | 'model' => App\User::class, 71 | ], 72 | 73 | // 'users' => [ 74 | // 'driver' => 'database', 75 | // 'table' => 'users', 76 | // ], 77 | ], 78 | 79 | /* 80 | |-------------------------------------------------------------------------- 81 | | Resetting Passwords 82 | |-------------------------------------------------------------------------- 83 | | 84 | | You may specify multiple password reset configurations if you have more 85 | | than one user table or model in the application and you want to have 86 | | separate password reset settings based on the specific user types. 87 | | 88 | | The expire time is the number of minutes that the reset token should be 89 | | considered valid. This security feature keeps tokens short-lived so 90 | | they have less time to be guessed. You may change this as needed. 91 | | 92 | */ 93 | 94 | 'passwords' => [ 95 | 'users' => [ 96 | 'provider' => 'users', 97 | 'table' => 'password_resets', 98 | 'expire' => 60, 99 | ], 100 | ], 101 | 102 | ]; 103 | -------------------------------------------------------------------------------- /tests/Feature/Reservation/GetValueTest.php: -------------------------------------------------------------------------------- 1 | insert(["nextval" => 0]); 19 | return new EloquentReservationRepository; 20 | } 21 | 22 | /** 23 | * 24 | * Get plan name. 25 | * 26 | */ 27 | public function testGetPlanName() 28 | { 29 | $request = makeCorrectRequest(); 30 | 31 | $id = $this->repository()->nextIdentity(); 32 | $reservation = createReservation($id,$request); 33 | $this->assertEquals('【非商用】基本プラン(平日)',$reservation->getPlanName()); 34 | } 35 | 36 | /** 37 | * Get date & time. 38 | */ 39 | public function testGetDateTime() 40 | { 41 | $request = makeCorrectRequest(); 42 | 43 | $id = $this->repository()->nextIdentity(); 44 | $reservation = createReservation($id,$request); 45 | 46 | $this->assertEquals('2017-11-26',$reservation->getDate()); 47 | $this->assertEquals(11,$reservation->getStartTime()); 48 | $this->assertEquals(9,$reservation->getEndTime()); 49 | 50 | array_splice($request->options, 2, 1);//宿泊オプションを削除 51 | $id = $this->repository()->nextIdentity(); 52 | $reservation = createReservation($id,$request); 53 | 54 | $this->assertEquals(22,$reservation->getEndTime()); 55 | 56 | $request->options[2] = '深夜利用';//宿泊オプションを深夜利用に変更 57 | $id = $this->repository()->nextIdentity(); 58 | $reservation = createReservation($id,$request); 59 | 60 | $this->assertEquals(24,$reservation->getEndTime()); 61 | 62 | } 63 | 64 | /** 65 | * Get status of this reservation. 66 | */ 67 | public function testChangeStatus() 68 | { 69 | $request = makeCorrectRequest(); 70 | 71 | $id = $this->repository()->nextIdentity(); 72 | $reservation = createReservation($id,$request); 73 | 74 | $this->assertEquals('Contact',$reservation->getStatus()); 75 | $reservation->changeStatus('Confirmation'); 76 | $this->assertEquals('Confirmation',$reservation->getStatus()); 77 | $reservation->changeStatus('BeforePayment'); 78 | $this->assertEquals('BeforePayment',$reservation->getStatus()); 79 | $reservation->changeStatus('AfterPayment'); 80 | $this->assertEquals('AfterPayment',$reservation->getStatus()); 81 | $reservation->changeStatus('BeforeUse'); 82 | $this->assertEquals('BeforeUse',$reservation->getStatus()); 83 | $reservation->changeStatus('Used'); 84 | $this->assertEquals('Used',$reservation->getStatus()); 85 | $reservation->changeStatus('Canceled'); 86 | $this->assertEquals('Canceled',$reservation->getStatus()); 87 | 88 | try { 89 | $reservation->changeStatus('Confirmation'); 90 | $this->fail('例外無し'); 91 | }catch(\InvalidArgumentException $e){ 92 | $this->assertEquals('このステータスには変更出来ません',$e->getMessage()); 93 | } 94 | 95 | } 96 | public function testGetNumber() 97 | { 98 | $request = makeCorrectRequest(); 99 | 100 | $id = $this->repository()->nextIdentity(); 101 | $reservation = createReservation($id,$request); 102 | 103 | $this->assertEquals(10,$reservation->getNumber()); 104 | 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Reservation/Options.php: -------------------------------------------------------------------------------- 1 | 'ゴミ処理', 13 | 'コタツ(布団付き)' => 'コタツ(布団付き)', 14 | '電気グリル鍋' => '電気グリル鍋', 15 | '大きな鍋' => '大きな鍋', 16 | 'カセットコンロ' => 'カセットコンロ', 17 | 'たこ焼き器' => 'たこ焼き器', 18 | '大人数レイアウト' => '大人数レイアウト', 19 | '寿司桶' => '寿司桶', 20 | 'プロジェクター' => 'プロジェクター', 21 | '深夜利用' => '深夜利用', 22 | '宿泊(1〜3名様)' => '宿泊(1〜3名様)', 23 | '宿泊(4〜5名様)' => '宿泊(4〜5名様)', 24 | 'コテ' => 'コテ', 25 | '撮影用ミニライト' => '撮影用ミニライト', 26 | '姿見鏡' => '姿見鏡', 27 | 'サプライズ装飾' => 'サプライズ装飾', 28 | '炊飯器' => '炊飯器', 29 | 'トースター' => 'トースター', 30 | 'ミキサー' => 'ミキサー', 31 | '付けない' => '付けない', 32 | ]; 33 | 34 | private const priceOptionsSet = [ 35 | 'ゴミ処理' => 1500, 36 | 'コタツ(布団付き)' => 3000, 37 | '電気グリル鍋' => 2000, 38 | '大きな鍋' => 1000, 39 | 'カセットコンロ' => 1500, 40 | 'たこ焼き器' => 1500, 41 | '大人数レイアウト' => 4000, 42 | '寿司桶' => 500, 43 | 'プロジェクター' => 1500, 44 | '深夜利用' => 5000, 45 | '宿泊(1〜3名様)' => 6000, 46 | '宿泊(4〜5名様)' => 8000, 47 | 'コテ' => 1000, 48 | '撮影用ミニライト' => 1000, 49 | '姿見鏡' => 1000, 50 | 'サプライズ装飾' => 4000, 51 | '炊飯器' => 1500, 52 | 'トースター' => 1500, 53 | 'ミキサー' => 1000, 54 | '付けない' => 0, 55 | ]; 56 | 57 | public function __construct(array $options, Plan $plan, $end_time) 58 | { 59 | if (!self::isValidValue($options)) { 60 | throw new \InvalidArgumentException('定義されていない値'); 61 | } 62 | 63 | $this->options = $options; 64 | 65 | if (!$this->canSelectExtendTimeOptionOnDayTimePlan($plan)) { 66 | throw new \InvalidArgumentException('お昼プランの場合、深夜利用・宿泊オプションは利用出来ません'); 67 | } 68 | if (!$this->canSelectExtendTimeOptionOnShortTimePlan($plan, $end_time)) { 69 | throw new \InvalidArgumentException('深夜利用or宿泊オプションご希望の場合は、22時までのプランをご利用下さい'); 70 | } 71 | } 72 | 73 | public static function isValidValue($options) 74 | { 75 | foreach ($options as $option) { 76 | if (!array_key_exists($option, self::optionSet)) { 77 | return false; 78 | } 79 | } 80 | return true; 81 | } 82 | 83 | public function getTotalPrice(): int 84 | { 85 | $totalPrice = 0; 86 | foreach ($this->options as $option) { 87 | $totalPrice += $this::priceOptionsSet[$option]; 88 | } 89 | return (int)$totalPrice; 90 | } 91 | 92 | public function getOptionAndPriceSet(): array 93 | { 94 | return array_intersect_key($this::priceOptionsSet, array_flip($this->options)); 95 | } 96 | 97 | public function hasLargeGroupOption(): bool 98 | { 99 | return in_array('大人数レイアウト', $this->options, true); 100 | } 101 | 102 | public function hasStayOption(): bool 103 | { 104 | $stay = in_array('宿泊(1〜3名様)', $this->options, true); 105 | $stay2 = in_array('宿泊(4〜5名様)', $this->options, true); 106 | return $stay || $stay2; 107 | } 108 | 109 | public function hasMidnightOption(): bool 110 | { 111 | return in_array('深夜利用', $this->options, true); 112 | } 113 | 114 | public function canSelectExtendTimeOptionOnShortTimePlan($plan, $end_time): bool 115 | { 116 | if ($plan->hasShortTimePlan() && ($this->hasStayOption() || $this->hasMidnightOption()) && $end_time !== 22) { 117 | return false; 118 | } 119 | return true; 120 | } 121 | 122 | public function canSelectExtendTimeOptionOnDayTimePlan($plan): bool 123 | { 124 | if (($this->hasStayOption() || $this->hasMidnightOption()) && $plan->hasDayTimePlan()) { 125 | return false; 126 | } 127 | return true; 128 | } 129 | 130 | } 131 | 132 | 133 | ?> -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'mysql'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Database Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here are each of the database connections setup for your application. 24 | | Of course, examples of configuring each database platform that is 25 | | supported by Laravel is shown below to make development simple. 26 | | 27 | | 28 | | All database work in Laravel is done through the PHP PDO facilities 29 | | so make sure you have the driver for your particular database of 30 | | choice installed on your machine before you begin development. 31 | | 32 | */ 33 | 34 | 'connections' => [ 35 | 36 | 'sqlite' => [ 37 | 'driver' => 'sqlite', 38 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 39 | 'prefix' => '', 40 | ], 41 | 42 | 'mysql' => [ 43 | 'driver' => 'mysql', 44 | 'host' => env('DB_HOST', '127.0.0.1'), 45 | 'port' => env('DB_PORT', '3306'), 46 | 'database' => env('DB_DATABASE', 'forge'), 47 | 'username' => env('DB_USERNAME', 'forge'), 48 | 'password' => env('DB_PASSWORD', ''), 49 | 'unix_socket' => env('DB_SOCKET', ''), 50 | 'charset' => 'utf8mb4', 51 | 'collation' => 'utf8mb4_unicode_ci', 52 | 'prefix' => '', 53 | 'strict' => true, 54 | 'engine' => null, 55 | ], 56 | 57 | 'pgsql' => [ 58 | 'driver' => 'pgsql', 59 | 'host' => env('DB_HOST', '127.0.0.1'), 60 | 'port' => env('DB_PORT', '5432'), 61 | 'database' => env('DB_DATABASE', 'forge'), 62 | 'username' => env('DB_USERNAME', 'forge'), 63 | 'password' => env('DB_PASSWORD', ''), 64 | 'charset' => 'utf8', 65 | 'prefix' => '', 66 | 'schema' => 'public', 67 | 'sslmode' => 'prefer', 68 | ], 69 | 70 | 'sqlsrv' => [ 71 | 'driver' => 'sqlsrv', 72 | 'host' => env('DB_HOST', 'localhost'), 73 | 'port' => env('DB_PORT', '1433'), 74 | 'database' => env('DB_DATABASE', 'forge'), 75 | 'username' => env('DB_USERNAME', 'forge'), 76 | 'password' => env('DB_PASSWORD', ''), 77 | 'charset' => 'utf8', 78 | 'prefix' => '', 79 | ], 80 | 81 | ], 82 | 83 | /* 84 | |-------------------------------------------------------------------------- 85 | | Migration Repository Table 86 | |-------------------------------------------------------------------------- 87 | | 88 | | This table keeps track of all the migrations that have already run for 89 | | your application. Using this information, we can determine which of 90 | | the migrations on disk haven't actually been run in the database. 91 | | 92 | */ 93 | 94 | 'migrations' => 'migrations', 95 | 96 | /* 97 | |-------------------------------------------------------------------------- 98 | | Redis Databases 99 | |-------------------------------------------------------------------------- 100 | | 101 | | Redis is an open source, fast, and advanced key-value store that also 102 | | provides a richer set of commands than a typical key-value systems 103 | | such as APC or Memcached. Laravel makes it easy to dig right in. 104 | | 105 | */ 106 | 107 | 'redis' => [ 108 | 109 | 'client' => 'predis', 110 | 111 | 'default' => [ 112 | 'host' => env('REDIS_HOST', '127.0.0.1'), 113 | 'password' => env('REDIS_PASSWORD', null), 114 | 'port' => env('REDIS_PORT', 6379), 115 | 'database' => 0, 116 | ], 117 | 118 | ], 119 | 120 | ]; 121 | -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_DRIVER', 'smtp'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | SMTP Host Address 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may provide the host address of the SMTP server used by your 27 | | applications. A default option is provided that is compatible with 28 | | the Mailgun mail service which will provide reliable deliveries. 29 | | 30 | */ 31 | 32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | SMTP Host Port 37 | |-------------------------------------------------------------------------- 38 | | 39 | | This is the SMTP port used by your application to deliver e-mails to 40 | | users of the application. Like the host we have set this value to 41 | | stay compatible with the Mailgun e-mail application by default. 42 | | 43 | */ 44 | 45 | 'port' => env('MAIL_PORT', 587), 46 | 47 | /* 48 | |-------------------------------------------------------------------------- 49 | | Global "From" Address 50 | |-------------------------------------------------------------------------- 51 | | 52 | | You may wish for all e-mails sent by your application to be sent from 53 | | the same address. Here, you may specify a name and address that is 54 | | used globally for all e-mails that are sent by your application. 55 | | 56 | */ 57 | 58 | 'from' => [ 59 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 60 | 'name' => env('MAIL_FROM_NAME', 'Example'), 61 | ], 62 | 63 | /* 64 | |-------------------------------------------------------------------------- 65 | | E-Mail Encryption Protocol 66 | |-------------------------------------------------------------------------- 67 | | 68 | | Here you may specify the encryption protocol that should be used when 69 | | the application send e-mail messages. A sensible default using the 70 | | transport layer security protocol should provide great security. 71 | | 72 | */ 73 | 74 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | SMTP Server Username 79 | |-------------------------------------------------------------------------- 80 | | 81 | | If your SMTP server requires a username for authentication, you should 82 | | set it here. This will get used to authenticate with your server on 83 | | connection. You may also set the "password" value below this one. 84 | | 85 | */ 86 | 87 | 'username' => env('MAIL_USERNAME'), 88 | 89 | 'password' => env('MAIL_PASSWORD'), 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Sendmail System Path 94 | |-------------------------------------------------------------------------- 95 | | 96 | | When using the "sendmail" driver to send e-mails, we will need to know 97 | | the path to where Sendmail lives on this server. A default path has 98 | | been provided here, which will work well on most of your systems. 99 | | 100 | */ 101 | 102 | 'sendmail' => '/usr/sbin/sendmail -bs', 103 | 104 | /* 105 | |-------------------------------------------------------------------------- 106 | | Markdown Mail Settings 107 | |-------------------------------------------------------------------------- 108 | | 109 | | If you are using Markdown based email rendering, you may configure your 110 | | theme and component paths here, allowing you to customize the design 111 | | of the emails. Or, you may simply stick with the Laravel defaults! 112 | | 113 | */ 114 | 115 | 'markdown' => [ 116 | 'theme' => 'default', 117 | 118 | 'paths' => [ 119 | resource_path('views/vendor/mail'), 120 | ], 121 | ], 122 | 123 | ]; 124 | -------------------------------------------------------------------------------- /tests/Feature/Reservation/UseDateTimeTest.php: -------------------------------------------------------------------------------- 1 | insert(["nextval" => 0]); 17 | return new EloquentReservationRepository; 18 | } 19 | 20 | /** 21 | * Date test. 22 | * 23 | * @return void 24 | */ 25 | public function testIsAcceptableTimeOneDayPlan() 26 | { 27 | $request = makeCorrectRequest(); 28 | 29 | try{ 30 | $id = $this->repository()->nextIdentity(); 31 | $reservation = createReservation($id,$request); 32 | 33 | $this->assertTrue(true); 34 | }catch(\Exception $e){ 35 | $this->fail($e->getMessage()); 36 | } 37 | } 38 | 39 | public function testNotAcceptableTimeOneDayPlan() 40 | { 41 | $request = makeCorrectRequest(); 42 | $request->end_time = '23'; 43 | array_splice($request->options,2,1); 44 | try{ 45 | $id = $this->repository()->nextIdentity(); 46 | $reservation = createReservation($id,$request); 47 | 48 | $this->fail('例外発生無し'); 49 | }catch(\Exception $e){ 50 | $this->assertEquals('不正な開始時刻又は終了時刻が入力されています',$e->getMessage()); 51 | } 52 | } 53 | 54 | public function testNotAcceptableTimeShortPlan() 55 | { 56 | $request = makeCorrectRequest(); 57 | $request->plan = '【商用】3時間パック'; 58 | $request->start_time = 15; 59 | $request->end_time = 18; 60 | array_splice($request->options,2,1); 61 | try{ 62 | $id = $this->repository()->nextIdentity(); 63 | $reservation = createReservation($id,$request); 64 | 65 | $this->fail('例外発生無し'); 66 | }catch(\Exception $e){ 67 | $this->assertEquals('2or3時間パックの場合16時~17時以外で指定して下さい',$e->getMessage()); 68 | } 69 | } 70 | 71 | public function testNotAcceptableUtilizationTimeShortPlan() 72 | { 73 | $request = makeCorrectRequest(); 74 | $request->plan = '【商用】3時間パック'; 75 | $request->start_time = 17; 76 | $request->end_time = 22; 77 | 78 | try{ 79 | $id = $this->repository()->nextIdentity(); 80 | $reservation = createReservation($id,$request); 81 | 82 | $this->fail('例外発生無し'); 83 | }catch(\Exception $e){ 84 | $this->assertEquals('プランで指定された利用時間をオーバーしています',$e->getMessage()); 85 | } 86 | } 87 | 88 | 89 | public function testEditEndTimeDependentOptions() 90 | { 91 | //宿泊オプション 92 | $request = makeOtherRequest(); 93 | 94 | try { 95 | $id = $this->repository()->nextIdentity(); 96 | $reservation = createReservation($id,$request); 97 | 98 | $this->assertEquals($reservation->getEndTime(), 9); 99 | } catch (\Exception $e) { 100 | $this->fail($e->getMessage()); 101 | } 102 | //深夜利用オプション 103 | $request = makeCorrectRequest(); 104 | $request->options[2] = '深夜利用'; 105 | try { 106 | $id = $this->repository()->nextIdentity(); 107 | $reservation = createReservation($id,$request); 108 | 109 | $this->assertEquals($reservation->getEndTime(), 24); 110 | } catch (\Exception $e) { 111 | $this->fail($e->getMessage()); 112 | } 113 | } 114 | 115 | public function testNotAcceptDayTimePlanAndMidnightOrStayOptions() 116 | { 117 | 118 | $request = makeCorrectRequest(); 119 | $request->plan = '【商用】お昼5時間パック'; 120 | try { 121 | $id = $this->repository()->nextIdentity(); 122 | $reservation = createReservation($id,$request); 123 | 124 | $this->fail('例外無し'); 125 | } catch (\Exception $e) { 126 | $this->assertEquals('お昼プランの場合、深夜利用・宿泊オプションは利用出来ません', $e->getMessage()); 127 | } 128 | } 129 | 130 | public function testNotAcceptedEndTimeAndMidnightOrStayOptions() 131 | { 132 | $request = makeOtherRequest(); 133 | $request->start_time = 17; 134 | $request->end_time = 20; 135 | try{ 136 | $id = $this->repository()->nextIdentity(); 137 | $reservation = createReservation($id,$request); 138 | 139 | $this->fail('例外無し'); 140 | }catch(\Exception $e){ 141 | $this->assertEquals('深夜利用or宿泊オプションご希望の場合は、22時までのプランをご利用下さい',$e->getMessage()); 142 | } 143 | } 144 | 145 | } 146 | -------------------------------------------------------------------------------- /tests/Unit/CalendarTest.php: -------------------------------------------------------------------------------- 1 | insert(["nextval" => 0]); 23 | return $this->app->make(ReservationRepositoryInterface::class); 24 | } 25 | 26 | public function finish() 27 | { 28 | //要修正 29 | DB::delete('delete from reservation_seqs'); 30 | DB::statement("alter table options auto_increment = 1"); 31 | 32 | } 33 | /** 34 | * A basic test example. 35 | * 36 | * @return void 37 | */ 38 | public function testIsNotBusy() 39 | { 40 | date_default_timezone_set('Asia/Tokyo'); 41 | $calendar = $this->app->make(CalendarInterface::class); 42 | $date = '2017-12-19'; 43 | $start = 17; 44 | $end = 22; 45 | $dateArr = explode('-',$date); 46 | $year = $dateArr[0]; 47 | $month = $dateArr[1]; 48 | $day = $dateArr[2]; 49 | 50 | $startDateTime = date('c',mktime($start,0,0,$month,$day,$year)); 51 | $endDateTime = date('c',mktime($end,0,0,$month,$day,$year)); 52 | $this->assertFalse($result = $calendar->isBusy($startDateTime,$endDateTime)); 53 | } 54 | 55 | public function testIsBusy(){ 56 | 57 | date_default_timezone_set('Asia/Tokyo'); 58 | $calendar = $this->app->make(CalendarInterface::class); 59 | $date = '2017-12-19'; 60 | $start = 11; 61 | $end = 22; 62 | $dateArr = explode('-',$date); 63 | $year = $dateArr[0]; 64 | $month = $dateArr[1]; 65 | $day = $dateArr[2]; 66 | 67 | $startDateTime = date('c',mktime($start,0,0,$month,$day,$year)); 68 | $endDateTime = date('c',mktime($end,0,0,$month,$day,$year)); 69 | $this->assertTrue($result = $calendar->isBusy($startDateTime,$endDateTime)); 70 | } 71 | 72 | public function testCreateEvent() 73 | { 74 | 75 | date_default_timezone_set('Asia/Tokyo'); 76 | 77 | $calendar = $this->app->make(CalendarInterface::class); 78 | $date = '2018-01-06'; 79 | $start = 11; 80 | $end = 22; 81 | $dateArr = explode('-',$date); 82 | $year = $dateArr[0]; 83 | $month = $dateArr[1]; 84 | $day = $dateArr[2]; 85 | 86 | $startDateTime = date('c',mktime($start,0,0,$month,$day,$year)); 87 | $endDateTime = date('c',mktime($end,0,0,$month,$day,$year)); 88 | $summary = '仮押さえ(自)'; 89 | 90 | $eventId = $calendar->createEvent($startDateTime,$endDateTime,$summary); 91 | 92 | $this->assertTrue(true); 93 | } 94 | 95 | public function testIsNotAvailable() 96 | { 97 | try { 98 | $req = makeCorrectRequest(); 99 | $req->date = '2017-12-19'; 100 | // $req->options = array_splice($req->options,0,2); 101 | 102 | 103 | $reqArr = reqToArray($req); 104 | 105 | 106 | $reservation = $this->repository()->new($reqArr); 107 | 108 | $availability = $this->app->make(Availability::class); 109 | $availability->isAvailable($reservation); 110 | 111 | $this->finish(); 112 | $this->fail('例外なし'); 113 | }catch(\Exception $e){ 114 | 115 | $this->finish(); 116 | $this->assertEquals('ご希望の時間帯は別の方が予約済みです',$e->getMessage()); 117 | } 118 | } 119 | 120 | public function testIsAvailable() 121 | { 122 | try { 123 | $req = makeCorrectRequest(); 124 | $req->date = '2018-01-19'; 125 | // $req->options = array_splice($req->options,0,2); 126 | 127 | 128 | $reqArr = reqToArray($req); 129 | 130 | 131 | $reservation = $this->repository()->new($reqArr); 132 | 133 | $availability = $this->app->make(Availability::class); 134 | 135 | $this->assertTrue($availability->isAvailable($reservation)); 136 | $this->finish(); 137 | }catch(\Exception $e){ 138 | 139 | $this->finish(); 140 | $this->fail('例外発生:'.$e->getMessage()); 141 | 142 | } 143 | } 144 | 145 | 146 | public function testKeepDate() 147 | { 148 | $req = makeCorrectRequest(); 149 | $req->date = '2018-01-19'; 150 | $req->options = array_splice($req->options,0,2); 151 | 152 | $reqArr = reqToArray($req); 153 | 154 | $reservation = $this->repository()->new($reqArr); 155 | 156 | $availability = $this->app->make(Availability::class); 157 | 158 | $this->assertTrue($availability->keepDate($reservation)); 159 | 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /packages/Asobiba/Domain/Models/Reservation/Reservation.php: -------------------------------------------------------------------------------- 1 | id = $id; 64 | $this->customer = $customer; 65 | $this->plan = $plan; 66 | $this->options = $options; 67 | $this->dateOfUse = $dateOfUse; 68 | $this->number = $number; 69 | $this->capacity = $capacity; 70 | $this->purpose = $purpose; 71 | $this->question = $question; 72 | if ($this->hasQuestion()) { 73 | $this->status = new Status('Contact'); 74 | } else { 75 | $this->status = new Status('Confirmation'); 76 | } 77 | } 78 | //引数の型を独自の型にする・・外でインスタンス化する 79 | 80 | /** 81 | * @return ReservationId 82 | */ 83 | public function getId(): ReservationId 84 | { 85 | return $this->id; 86 | } 87 | 88 | 89 | public function getCustomer() :Customer 90 | { 91 | return $this->customer; 92 | } 93 | /** 94 | * get total price of this reservation 95 | * 96 | * @return int 97 | */ 98 | public function getTotalPrice(): int 99 | { 100 | return $this->options->getTotalPrice() + $this->plan->getPrice(); 101 | } 102 | 103 | 104 | /** 105 | * get plan of this reservation 106 | * 107 | * @return Plan 108 | */ 109 | public function getPlan(): Plan 110 | { 111 | return $this->plan; 112 | } 113 | 114 | /** 115 | * get options and price set of this reservation. 116 | * 117 | * @return array 118 | */ 119 | public function getOptionAndPriceSet(): array 120 | { 121 | return $this->options->getOptionAndPriceSet(); 122 | } 123 | 124 | /** 125 | * get plan name. 126 | * 127 | * @return string 128 | */ 129 | public function getPlanName(): string 130 | { 131 | return $this->plan->getPlan(); 132 | } 133 | 134 | /** 135 | * get capacity of guests. 136 | * 137 | * @return int 138 | */ 139 | public function getCapacity(): Capacity 140 | { 141 | return $this->capacity; 142 | } 143 | /** 144 | * get number of guests. 145 | * 146 | * @return int 147 | */ 148 | public function getNumber(): Number 149 | { 150 | return $this->number; 151 | } 152 | 153 | /** 154 | * get question of this reservation 155 | * 156 | * @return string 157 | */ 158 | public function getQuestion(): Question 159 | { 160 | return $this->question; 161 | } 162 | 163 | /** 164 | * @return string 165 | */ 166 | public function getStatus(): string 167 | { 168 | return (string)$this->status;//__toStringメソッドが定義されているため 169 | } 170 | 171 | 172 | /** 173 | * change status 174 | * @param string $status 175 | */ 176 | public function changeStatus(string $status) 177 | { 178 | $method = 'to' . $status; 179 | $this->status = $this->status->$method(); 180 | } 181 | 182 | /** 183 | * get Date 184 | * 185 | * @return string 186 | */ 187 | public function getDate(): dateOfUse 188 | { 189 | // return $this->dateOfUse->getDate(); 190 | return $this->dateOfUse; 191 | } 192 | 193 | /** 194 | * get StartTime 195 | * 196 | * @return int 197 | */ 198 | public function getStartTime(): int 199 | { 200 | return $this->dateOfUse->getStartTime(); 201 | } 202 | 203 | /** 204 | * get EndTime 205 | * 206 | * @return int 207 | */ 208 | public function getEndTime(): int 209 | { 210 | return $this->dateOfUse->getEndTime(); 211 | } 212 | 213 | /** 214 | * @return Purpose 215 | */ 216 | public function getPurpose(): Purpose 217 | { 218 | return $this->purpose; 219 | } 220 | 221 | /** 222 | * check if this reservation has question 223 | * 224 | * @return bool 225 | */ 226 | public function hasQuestion(): bool 227 | { 228 | return $this->question->isQuestion(); 229 | } 230 | 231 | 232 | } 233 | 234 | -------------------------------------------------------------------------------- /resources/lang/en/validation.php: -------------------------------------------------------------------------------- 1 | 'The :attribute must be accepted.', 17 | 'active_url' => 'The :attribute is not a valid URL.', 18 | 'after' => 'The :attribute must be a date after :date.', 19 | 'after_or_equal' => 'The :attribute must be a date after or equal to :date.', 20 | 'alpha' => 'The :attribute may only contain letters.', 21 | 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.', 22 | 'alpha_num' => 'The :attribute may only contain letters and numbers.', 23 | 'array' => 'The :attribute must be an array.', 24 | 'before' => 'The :attribute must be a date before :date.', 25 | 'before_or_equal' => 'The :attribute must be a date before or equal to :date.', 26 | 'between' => [ 27 | 'numeric' => 'The :attribute must be between :min and :max.', 28 | 'file' => 'The :attribute must be between :min and :max kilobytes.', 29 | 'string' => 'The :attribute must be between :min and :max characters.', 30 | 'array' => 'The :attribute must have between :min and :max items.', 31 | ], 32 | 'boolean' => 'The :attribute field must be true or false.', 33 | 'confirmed' => 'The :attribute confirmation does not match.', 34 | 'date' => 'The :attribute is not a valid date.', 35 | 'date_format' => 'The :attribute does not match the format :format.', 36 | 'different' => 'The :attribute and :other must be different.', 37 | 'digits' => 'The :attribute must be :digits digits.', 38 | 'digits_between' => 'The :attribute must be between :min and :max digits.', 39 | 'dimensions' => 'The :attribute has invalid image dimensions.', 40 | 'distinct' => 'The :attribute field has a duplicate value.', 41 | 'email' => 'The :attribute must be a valid email address.', 42 | 'exists' => 'The selected :attribute is invalid.', 43 | 'file' => 'The :attribute must be a file.', 44 | 'filled' => 'The :attribute field must have a value.', 45 | 'image' => 'The :attribute must be an image.', 46 | 'in' => 'The selected :attribute is invalid.', 47 | 'in_array' => 'The :attribute field does not exist in :other.', 48 | 'integer' => 'The :attribute must be an integer.', 49 | 'ip' => 'The :attribute must be a valid IP address.', 50 | 'ipv4' => 'The :attribute must be a valid IPv4 address.', 51 | 'ipv6' => 'The :attribute must be a valid IPv6 address.', 52 | 'json' => 'The :attribute must be a valid JSON string.', 53 | 'max' => [ 54 | 'numeric' => 'The :attribute may not be greater than :max.', 55 | 'file' => 'The :attribute may not be greater than :max kilobytes.', 56 | 'string' => 'The :attribute may not be greater than :max characters.', 57 | 'array' => 'The :attribute may not have more than :max items.', 58 | ], 59 | 'mimes' => 'The :attribute must be a file of type: :values.', 60 | 'mimetypes' => 'The :attribute must be a file of type: :values.', 61 | 'min' => [ 62 | 'numeric' => 'The :attribute must be at least :min.', 63 | 'file' => 'The :attribute must be at least :min kilobytes.', 64 | 'string' => 'The :attribute must be at least :min characters.', 65 | 'array' => 'The :attribute must have at least :min items.', 66 | ], 67 | 'not_in' => 'The selected :attribute is invalid.', 68 | 'numeric' => 'The :attribute must be a number.', 69 | 'present' => 'The :attribute field must be present.', 70 | 'regex' => 'The :attribute format is invalid.', 71 | 'required' => 'The :attribute field is required.', 72 | 'required_if' => 'The :attribute field is required when :other is :value.', 73 | 'required_unless' => 'The :attribute field is required unless :other is in :values.', 74 | 'required_with' => 'The :attribute field is required when :values is present.', 75 | 'required_with_all' => 'The :attribute field is required when :values is present.', 76 | 'required_without' => 'The :attribute field is required when :values is not present.', 77 | 'required_without_all' => 'The :attribute field is required when none of :values are present.', 78 | 'same' => 'The :attribute and :other must match.', 79 | 'size' => [ 80 | 'numeric' => 'The :attribute must be :size.', 81 | 'file' => 'The :attribute must be :size kilobytes.', 82 | 'string' => 'The :attribute must be :size characters.', 83 | 'array' => 'The :attribute must contain :size items.', 84 | ], 85 | 'string' => 'The :attribute must be a string.', 86 | 'timezone' => 'The :attribute must be a valid zone.', 87 | 'unique' => 'The :attribute has already been taken.', 88 | 'uploaded' => 'The :attribute failed to upload.', 89 | 'url' => 'The :attribute format is invalid.', 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Custom Validation Language Lines 94 | |-------------------------------------------------------------------------- 95 | | 96 | | Here you may specify custom validation messages for attributes using the 97 | | convention "attribute.rule" to name the lines. This makes it quick to 98 | | specify a specific custom language line for a given attribute rule. 99 | | 100 | */ 101 | 102 | 'custom' => [ 103 | 'attribute-name' => [ 104 | 'rule-name' => 'custom-message', 105 | ], 106 | ], 107 | 108 | /* 109 | |-------------------------------------------------------------------------- 110 | | Custom Validation Attributes 111 | |-------------------------------------------------------------------------- 112 | | 113 | | The following language lines are used to swap attribute place-holders 114 | | with something more reader friendly such as E-Mail Address instead 115 | | of "email". This simply helps us make messages a little cleaner. 116 | | 117 | */ 118 | 119 | 'attributes' => [], 120 | 121 | ]; 122 | -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'file'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Session Lifetime 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may specify the number of minutes that you wish the session 27 | | to be allowed to remain idle before it expires. If you want them 28 | | to immediately expire on the browser closing, set that option. 29 | | 30 | */ 31 | 32 | 'lifetime' => 120, 33 | 34 | 'expire_on_close' => false, 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Session Encryption 39 | |-------------------------------------------------------------------------- 40 | | 41 | | This option allows you to easily specify that all of your session data 42 | | should be encrypted before it is stored. All encryption will be run 43 | | automatically by Laravel and you can use the Session like normal. 44 | | 45 | */ 46 | 47 | 'encrypt' => false, 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | Session File Location 52 | |-------------------------------------------------------------------------- 53 | | 54 | | When using the native session driver, we need a location where session 55 | | files may be stored. A default has been set for you but a different 56 | | location may be specified. This is only needed for file sessions. 57 | | 58 | */ 59 | 60 | 'files' => storage_path('framework/sessions'), 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Session Database Connection 65 | |-------------------------------------------------------------------------- 66 | | 67 | | When using the "database" or "redis" session drivers, you may specify a 68 | | connection that should be used to manage these sessions. This should 69 | | correspond to a connection in your database configuration options. 70 | | 71 | */ 72 | 73 | 'connection' => null, 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Session Database Table 78 | |-------------------------------------------------------------------------- 79 | | 80 | | When using the "database" session driver, you may specify the table we 81 | | should use to manage the sessions. Of course, a sensible default is 82 | | provided for you; however, you are free to change this as needed. 83 | | 84 | */ 85 | 86 | 'table' => 'sessions', 87 | 88 | /* 89 | |-------------------------------------------------------------------------- 90 | | Session Cache Store 91 | |-------------------------------------------------------------------------- 92 | | 93 | | When using the "apc" or "memcached" session drivers, you may specify a 94 | | cache store that should be used for these sessions. This value must 95 | | correspond with one of the application's configured cache stores. 96 | | 97 | */ 98 | 99 | 'store' => null, 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Session Sweeping Lottery 104 | |-------------------------------------------------------------------------- 105 | | 106 | | Some session drivers must manually sweep their storage location to get 107 | | rid of old sessions from storage. Here are the chances that it will 108 | | happen on a given request. By default, the odds are 2 out of 100. 109 | | 110 | */ 111 | 112 | 'lottery' => [2, 100], 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | Session Cookie Name 117 | |-------------------------------------------------------------------------- 118 | | 119 | | Here you may change the name of the cookie used to identify a session 120 | | instance by ID. The name specified here will get used every time a 121 | | new session cookie is created by the framework for every driver. 122 | | 123 | */ 124 | 125 | 'cookie' => env( 126 | 'SESSION_COOKIE', 127 | str_slug(env('APP_NAME', 'laravel'), '_').'_session' 128 | ), 129 | 130 | /* 131 | |-------------------------------------------------------------------------- 132 | | Session Cookie Path 133 | |-------------------------------------------------------------------------- 134 | | 135 | | The session cookie path determines the path for which the cookie will 136 | | be regarded as available. Typically, this will be the root path of 137 | | your application but you are free to change this when necessary. 138 | | 139 | */ 140 | 141 | 'path' => '/', 142 | 143 | /* 144 | |-------------------------------------------------------------------------- 145 | | Session Cookie Domain 146 | |-------------------------------------------------------------------------- 147 | | 148 | | Here you may change the domain of the cookie used to identify a session 149 | | in your application. This will determine which domains the cookie is 150 | | available to in your application. A sensible default has been set. 151 | | 152 | */ 153 | 154 | 'domain' => env('SESSION_DOMAIN', null), 155 | 156 | /* 157 | |-------------------------------------------------------------------------- 158 | | HTTPS Only Cookies 159 | |-------------------------------------------------------------------------- 160 | | 161 | | By setting this option to true, session cookies will only be sent back 162 | | to the server if the browser has a HTTPS connection. This will keep 163 | | the cookie from being sent to you if it can not be done securely. 164 | | 165 | */ 166 | 167 | 'secure' => env('SESSION_SECURE_COOKIE', false), 168 | 169 | /* 170 | |-------------------------------------------------------------------------- 171 | | HTTP Access Only 172 | |-------------------------------------------------------------------------- 173 | | 174 | | Setting this value to true will prevent JavaScript from accessing the 175 | | value of the cookie and the cookie will only be accessible through 176 | | the HTTP protocol. You are free to modify this option if needed. 177 | | 178 | */ 179 | 180 | 'http_only' => true, 181 | 182 | /* 183 | |-------------------------------------------------------------------------- 184 | | Same-Site Cookies 185 | |-------------------------------------------------------------------------- 186 | | 187 | | This option determines how your cookies behave when cross-site requests 188 | | take place, and can be used to mitigate CSRF attacks. By default, we 189 | | do not enable this as other CSRF protection services are in place. 190 | | 191 | | Supported: "lax", "strict" 192 | | 193 | */ 194 | 195 | 'same_site' => null, 196 | 197 | ]; 198 | -------------------------------------------------------------------------------- /config/app.php: -------------------------------------------------------------------------------- 1 | env('APP_NAME', 'Laravel'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Application Environment 21 | |-------------------------------------------------------------------------- 22 | | 23 | | This value determines the "environment" your application is currently 24 | | running in. This may determine how you prefer to configure various 25 | | services your application utilizes. Set this in your ".env" file. 26 | | 27 | */ 28 | 29 | 'env' => env('APP_ENV', 'production'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Application Debug Mode 34 | |-------------------------------------------------------------------------- 35 | | 36 | | When your application is in debug mode, detailed error messages with 37 | | stack traces will be shown on every error that occurs within your 38 | | application. If disabled, a simple generic error page is shown. 39 | | 40 | */ 41 | 42 | 'debug' => env('APP_DEBUG', false), 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Application URL 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This URL is used by the console to properly generate URLs when using 50 | | the Artisan command line tool. You should set this to the root of 51 | | your application so that it is used when running Artisan tasks. 52 | | 53 | */ 54 | 55 | 'url' => env('APP_URL', 'http://localhost'), 56 | 57 | /* 58 | |-------------------------------------------------------------------------- 59 | | Application Timezone 60 | |-------------------------------------------------------------------------- 61 | | 62 | | Here you may specify the default timezone for your application, which 63 | | will be used by the PHP date and date-time functions. We have gone 64 | | ahead and set this to a sensible default for you out of the box. 65 | | 66 | */ 67 | 68 | 'timezone' => 'UTC', 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Application Locale Configuration 73 | |-------------------------------------------------------------------------- 74 | | 75 | | The application locale determines the default locale that will be used 76 | | by the translation service provider. You are free to set this value 77 | | to any of the locales which will be supported by the application. 78 | | 79 | */ 80 | 81 | 'locale' => 'en', 82 | 83 | /* 84 | |-------------------------------------------------------------------------- 85 | | Application Fallback Locale 86 | |-------------------------------------------------------------------------- 87 | | 88 | | The fallback locale determines the locale to use when the current one 89 | | is not available. You may change the value to correspond to any of 90 | | the language folders that are provided through your application. 91 | | 92 | */ 93 | 94 | 'fallback_locale' => 'en', 95 | 96 | /* 97 | |-------------------------------------------------------------------------- 98 | | Encryption Key 99 | |-------------------------------------------------------------------------- 100 | | 101 | | This key is used by the Illuminate encrypter service and should be set 102 | | to a random, 32 character string, otherwise these encrypted strings 103 | | will not be safe. Please do this before deploying an application! 104 | | 105 | */ 106 | 107 | 'key' => env('APP_KEY'), 108 | 109 | 'cipher' => 'AES-256-CBC', 110 | 111 | /* 112 | |-------------------------------------------------------------------------- 113 | | Logging Configuration 114 | |-------------------------------------------------------------------------- 115 | | 116 | | Here you may configure the log settings for your application. Out of 117 | | the box, Laravel uses the Monolog PHP logging library. This gives 118 | | you a variety of powerful log handlers / formatters to utilize. 119 | | 120 | | Available Settings: "single", "daily", "syslog", "errorlog" 121 | | 122 | */ 123 | 124 | 'log' => env('APP_LOG', 'single'), 125 | 126 | 'log_level' => env('APP_LOG_LEVEL', 'debug'), 127 | 128 | /* 129 | |-------------------------------------------------------------------------- 130 | | Autoloaded Service Providers 131 | |-------------------------------------------------------------------------- 132 | | 133 | | The service providers listed here will be automatically loaded on the 134 | | request to your application. Feel free to add your own services to 135 | | this array to grant expanded functionality to your applications. 136 | | 137 | */ 138 | 139 | 'providers' => [ 140 | 141 | /* 142 | * Laravel Framework Service Providers... 143 | */ 144 | Illuminate\Auth\AuthServiceProvider::class, 145 | Illuminate\Broadcasting\BroadcastServiceProvider::class, 146 | Illuminate\Bus\BusServiceProvider::class, 147 | Illuminate\Cache\CacheServiceProvider::class, 148 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, 149 | Illuminate\Cookie\CookieServiceProvider::class, 150 | Illuminate\Database\DatabaseServiceProvider::class, 151 | Illuminate\Encryption\EncryptionServiceProvider::class, 152 | Illuminate\Filesystem\FilesystemServiceProvider::class, 153 | Illuminate\Foundation\Providers\FoundationServiceProvider::class, 154 | Illuminate\Hashing\HashServiceProvider::class, 155 | Illuminate\Mail\MailServiceProvider::class, 156 | Illuminate\Notifications\NotificationServiceProvider::class, 157 | Illuminate\Pagination\PaginationServiceProvider::class, 158 | Illuminate\Pipeline\PipelineServiceProvider::class, 159 | Illuminate\Queue\QueueServiceProvider::class, 160 | Illuminate\Redis\RedisServiceProvider::class, 161 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, 162 | Illuminate\Session\SessionServiceProvider::class, 163 | Illuminate\Translation\TranslationServiceProvider::class, 164 | Illuminate\Validation\ValidationServiceProvider::class, 165 | Illuminate\View\ViewServiceProvider::class, 166 | 167 | /* 168 | * Package Service Providers... 169 | */ 170 | 171 | /* 172 | * Application Service Providers... 173 | */ 174 | App\Providers\AppServiceProvider::class, 175 | App\Providers\AuthServiceProvider::class, 176 | // App\Providers\BroadcastServiceProvider::class, 177 | App\Providers\EloquentServiceProvider::class, 178 | App\Providers\EventServiceProvider::class, 179 | App\Providers\RouteServiceProvider::class, 180 | 181 | ], 182 | 183 | /* 184 | |-------------------------------------------------------------------------- 185 | | Class Aliases 186 | |-------------------------------------------------------------------------- 187 | | 188 | | This array of class aliases will be registered when this application 189 | | is started. However, feel free to register as many as you wish as 190 | | the aliases are "lazy" loaded so they don't hinder performance. 191 | | 192 | */ 193 | 194 | 'aliases' => [ 195 | 196 | 'App' => Illuminate\Support\Facades\App::class, 197 | 'Artisan' => Illuminate\Support\Facades\Artisan::class, 198 | 'Auth' => Illuminate\Support\Facades\Auth::class, 199 | 'Blade' => Illuminate\Support\Facades\Blade::class, 200 | 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, 201 | 'Bus' => Illuminate\Support\Facades\Bus::class, 202 | 'Cache' => Illuminate\Support\Facades\Cache::class, 203 | 'Config' => Illuminate\Support\Facades\Config::class, 204 | 'Cookie' => Illuminate\Support\Facades\Cookie::class, 205 | 'Crypt' => Illuminate\Support\Facades\Crypt::class, 206 | 'DB' => Illuminate\Support\Facades\DB::class, 207 | 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 208 | 'Event' => Illuminate\Support\Facades\Event::class, 209 | 'File' => Illuminate\Support\Facades\File::class, 210 | 'Gate' => Illuminate\Support\Facades\Gate::class, 211 | 'Hash' => Illuminate\Support\Facades\Hash::class, 212 | 'Lang' => Illuminate\Support\Facades\Lang::class, 213 | 'Log' => Illuminate\Support\Facades\Log::class, 214 | 'Mail' => Illuminate\Support\Facades\Mail::class, 215 | 'Notification' => Illuminate\Support\Facades\Notification::class, 216 | 'Password' => Illuminate\Support\Facades\Password::class, 217 | 'Queue' => Illuminate\Support\Facades\Queue::class, 218 | 'Redirect' => Illuminate\Support\Facades\Redirect::class, 219 | 'Redis' => Illuminate\Support\Facades\Redis::class, 220 | 'Request' => Illuminate\Support\Facades\Request::class, 221 | 'Response' => Illuminate\Support\Facades\Response::class, 222 | 'Route' => Illuminate\Support\Facades\Route::class, 223 | 'Schema' => Illuminate\Support\Facades\Schema::class, 224 | 'Session' => Illuminate\Support\Facades\Session::class, 225 | 'Storage' => Illuminate\Support\Facades\Storage::class, 226 | 'URL' => Illuminate\Support\Facades\URL::class, 227 | 'Validator' => Illuminate\Support\Facades\Validator::class, 228 | 'View' => Illuminate\Support\Facades\View::class, 229 | 230 | ], 231 | 232 | ]; 233 | --------------------------------------------------------------------------------