add checkin_webhooks table
This commit is contained in:
parent
034a47cd25
commit
5926c6e640
28
app/CheckinWebhook.php
Normal file
28
app/CheckinWebhook.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CheckinWebhook extends Model
|
||||
{
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = ['name'];
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
self::creating(function (CheckinWebhook $webhook) {
|
||||
$webhook->id = Str::random(64);
|
||||
});
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
14
app/Http/Controllers/Api/WebhookController.php
Normal file
14
app/Http/Controllers/Api/WebhookController.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WebhookController extends Controller
|
||||
{
|
||||
public function checkin(Request $request)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
@ -71,4 +71,9 @@ class User extends Authenticatable
|
||||
{
|
||||
return $this->hasMany(Like::class);
|
||||
}
|
||||
|
||||
public function checkinWebhooks()
|
||||
{
|
||||
return $this->hasMany(CheckinWebhook::class);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateCheckinWebhooksTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('checkin_webhooks', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user