diff --git a/backend/app/Models/Offer.php b/backend/app/Models/Offer.php new file mode 100644 index 0000000..cbf399f --- /dev/null +++ b/backend/app/Models/Offer.php @@ -0,0 +1,36 @@ + + */ + protected $fillable = [ + 'owner_id', + 'name', + 'type', + 'price', + 'rooms', + 'yandex_mark', + 'text', + 'is_group', + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ +// 'is_group' => 'boolean', + ]; +} diff --git a/backend/app/Models/OfferPhoto.php b/backend/app/Models/OfferPhoto.php new file mode 100644 index 0000000..8891912 --- /dev/null +++ b/backend/app/Models/OfferPhoto.php @@ -0,0 +1,21 @@ + + */ + protected $fillable = [ + 'offer_id', + 'file', + ]; +} diff --git a/backend/app/Models/Order.php b/backend/app/Models/Order.php new file mode 100644 index 0000000..5e19055 --- /dev/null +++ b/backend/app/Models/Order.php @@ -0,0 +1,35 @@ + + */ + protected $fillable = [ + 'offer_id', + 'user_id', + 'start_date', + 'end_date', + 'price', + 'discount', + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'start_date' => 'datetime', + 'end_date' => 'datetime', + ]; +} diff --git a/backend/app/Models/Review.php b/backend/app/Models/Review.php new file mode 100644 index 0000000..e924c4a --- /dev/null +++ b/backend/app/Models/Review.php @@ -0,0 +1,23 @@ + + */ + protected $fillable = [ + 'offer_id', + 'user_id', + 'comment', + 'rating', + ]; +} diff --git a/backend/app/Models/User.php b/backend/app/Models/User.php index 8996368..0282ad6 100644 --- a/backend/app/Models/User.php +++ b/backend/app/Models/User.php @@ -2,7 +2,6 @@ namespace App\Models; -use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; @@ -18,8 +17,12 @@ class User extends Authenticatable * @var array */ protected $fillable = [ - 'name', + 'first_name', + 'last_name', + 'middle_name', 'email', + 'phone', + 'photo', 'password', ]; @@ -30,7 +33,6 @@ class User extends Authenticatable */ protected $hidden = [ 'password', - 'remember_token', ]; /** @@ -38,7 +40,7 @@ class User extends Authenticatable * * @var array */ - protected $casts = [ - 'email_verified_at' => 'datetime', - ]; +// protected $casts = [ +// 'email_verified_at' => 'datetime', +// ]; } diff --git a/backend/composer.json b/backend/composer.json index 164c94b..18a7cbb 100644 --- a/backend/composer.json +++ b/backend/composer.json @@ -13,7 +13,7 @@ }, "require-dev": { "fakerphp/faker": "^1.9.1", - "laravel/sail": "^1.0.1", + "laravel/sail": "^1.14", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^6.1", "phpunit/phpunit": "^9.5.10", diff --git a/backend/composer.lock b/backend/composer.lock index d337df3..7b5506a 100644 --- a/backend/composer.lock +++ b/backend/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1abc7822bd9f28e9a62986817bf04f76", + "content-hash": "3c9da13e09c625e7ca22f1d572bd7f2d", "packages": [ { "name": "brick/math", diff --git a/backend/config/auth.php b/backend/config/auth.php index d8c6cee..2cbf567 100644 --- a/backend/config/auth.php +++ b/backend/config/auth.php @@ -64,11 +64,6 @@ return [ 'driver' => 'eloquent', 'model' => App\Models\User::class, ], - - // 'users' => [ - // 'driver' => 'database', - // 'table' => 'users', - // ], ], /* diff --git a/backend/database/migrations/2014_10_12_000000_create_users_table.php b/backend/database/migrations/2014_10_12_000000_create_users_table.php index cf6b776..6d3255e 100644 --- a/backend/database/migrations/2014_10_12_000000_create_users_table.php +++ b/backend/database/migrations/2014_10_12_000000_create_users_table.php @@ -15,11 +15,13 @@ return new class extends Migration { Schema::create('users', function (Blueprint $table) { $table->id(); - $table->string('name'); + $table->string('first_name'); + $table->string('last_name'); + $table->string('middle_name')->nullable(); $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); + $table->string('phone')->unique()->nullable(); + $table->string('photo')->nullable(); $table->string('password'); - $table->rememberToken(); $table->timestamps(); }); } diff --git a/backend/database/migrations/2022_05_26_030738_create_offers_table.php b/backend/database/migrations/2022_05_26_030738_create_offers_table.php new file mode 100644 index 0000000..a3d0fd1 --- /dev/null +++ b/backend/database/migrations/2022_05_26_030738_create_offers_table.php @@ -0,0 +1,39 @@ +id(); + $table->foreignId('owner_id'); + $table->string('name'); + $table->enum('type', ['studio']); + $table->decimal('price'); + $table->unsignedSmallInteger('rooms'); + $table->string('yandex_mark')->nullable(); + $table->text('text'); + $table->boolean('is_group'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('offers'); + } +}; diff --git a/backend/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php b/backend/database/migrations/2022_05_26_035738_create_offer_photos_table.php similarity index 55% rename from backend/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php rename to backend/database/migrations/2022_05_26_035738_create_offer_photos_table.php index fd235f8..6e5f8e5 100644 --- a/backend/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php +++ b/backend/database/migrations/2022_05_26_035738_create_offer_photos_table.php @@ -13,13 +13,10 @@ return new class extends Migration */ public function up() { - Schema::create('personal_access_tokens', function (Blueprint $table) { + Schema::create('offer_photos', function (Blueprint $table) { $table->id(); - $table->morphs('tokenable'); - $table->string('name'); - $table->string('token', 64)->unique(); - $table->text('abilities')->nullable(); - $table->timestamp('last_used_at')->nullable(); + $table->foreignId('offer_id'); + $table->string('file'); $table->timestamps(); }); } @@ -31,6 +28,6 @@ return new class extends Migration */ public function down() { - Schema::dropIfExists('personal_access_tokens'); + Schema::dropIfExists('offer_photos'); } }; diff --git a/backend/database/migrations/2022_05_26_035905_create_reviews_table.php b/backend/database/migrations/2022_05_26_035905_create_reviews_table.php new file mode 100644 index 0000000..62106f4 --- /dev/null +++ b/backend/database/migrations/2022_05_26_035905_create_reviews_table.php @@ -0,0 +1,35 @@ +id(); + $table->foreignId('offer_id'); + $table->foreignId('user_id'); + $table->text('comment'); + $table->unsignedFloat('rating'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('reviews'); + } +}; diff --git a/backend/database/migrations/2022_05_26_035920_create_orders_table.php b/backend/database/migrations/2022_05_26_035920_create_orders_table.php new file mode 100644 index 0000000..8375b27 --- /dev/null +++ b/backend/database/migrations/2022_05_26_035920_create_orders_table.php @@ -0,0 +1,37 @@ +id(); + $table->foreignId('offer_id'); + $table->foreignId('user_id'); + $table->date('start_date'); + $table->date('end_date'); + $table->decimal('price'); + $table->decimal('discount'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('orders'); + } +}; diff --git a/backend/routes/web.php b/backend/routes/web.php index b130397..edd263d 100644 --- a/backend/routes/web.php +++ b/backend/routes/web.php @@ -13,6 +13,6 @@ use Illuminate\Support\Facades\Route; | */ -Route::get('/', function () { - return view('welcome'); -}); +//Route::get('/', function () { +// return view('welcome'); +//});