diff --git a/app/CheckinWebhook.php b/app/CheckinWebhook.php new file mode 100644 index 0000000..185322c --- /dev/null +++ b/app/CheckinWebhook.php @@ -0,0 +1,28 @@ +id = Str::random(64); + }); + } + + public function user() + { + return $this->belongsTo(User::class); + } +} diff --git a/app/Http/Controllers/Api/WebhookController.php b/app/Http/Controllers/Api/WebhookController.php new file mode 100644 index 0000000..be1238d --- /dev/null +++ b/app/Http/Controllers/Api/WebhookController.php @@ -0,0 +1,14 @@ +hasMany(Like::class); } + + public function checkinWebhooks() + { + return $this->hasMany(CheckinWebhook::class); + } } diff --git a/database/migrations/2020_07_19_173931_create_checkin_webhooks_table.php b/database/migrations/2020_07_19_173931_create_checkin_webhooks_table.php new file mode 100644 index 0000000..6446464 --- /dev/null +++ b/database/migrations/2020_07_19_173931_create_checkin_webhooks_table.php @@ -0,0 +1,37 @@ +string('id', 64); + $table->integer('user_id')->nullable(); + $table->string('name'); + $table->timestamps(); + + $table->primary('id'); + + $table->foreign('user_id')->references('id')->on('users')->onDelete('set null'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('checkin_webhooks'); + } +} diff --git a/routes/api.php b/routes/api.php index 7c6979e..f4f2764 100644 --- a/routes/api.php +++ b/routes/api.php @@ -21,3 +21,5 @@ Route::middleware('auth')->group(function () { Route::post('/likes', 'Api\\LikeController@store'); Route::delete('/likes/{id}', 'Api\\LikeController@destroy'); }); + +Route::post('/webhooks/checkin/{webhook}', 'Api\\WebhookController@checkin');