diff --git a/app/Http/Controllers/PlaceController.php b/app/Http/Controllers/PlaceController.php new file mode 100644 index 000000000..89e5710a3 --- /dev/null +++ b/app/Http/Controllers/PlaceController.php @@ -0,0 +1,23 @@ +findOrFail($id); + $posts = Status::wherePlaceId($place->id) + ->whereScope('public') + ->orderByDesc('created_at') + ->paginate(10); + return view('discover.places.show', compact('place', 'posts')); + } +} diff --git a/app/Place.php b/app/Place.php new file mode 100644 index 000000000..c7c7d68be --- /dev/null +++ b/app/Place.php @@ -0,0 +1,33 @@ +id . '/' . $this->slug); + } + + public function posts() + { + return $this->hasMany(Status::class); + } + + public function postCount() + { + return $this->posts()->count(); + } +} diff --git a/database/migrations/2019_08_07_184030_create_places_table.php b/database/migrations/2019_08_07_184030_create_places_table.php new file mode 100644 index 000000000..29ca172d0 --- /dev/null +++ b/database/migrations/2019_08_07_184030_create_places_table.php @@ -0,0 +1,45 @@ +bigIncrements('id'); + $table->string('slug')->index(); + $table->string('name')->index(); + $table->string('country')->index(); + $table->json('aliases')->nullable(); + $table->decimal('lat', 9, 6)->nullable(); + $table->decimal('long', 9, 6)->nullable(); + $table->unique(['slug', 'country', 'lat', 'long']); + $table->timestamps(); + }); + + Schema::table('statuses', function (Blueprint $table) { + $table->bigInteger('place_id')->unsigned()->nullable()->index(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('places'); + Schema::table('statuses', function (Blueprint $table) { + $table->dropColumn('place_id'); + }); + } +}