Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Invitation extends Model
- {
- protected $primaryKey = 'invite_code';
- protected $fillable = ['invite_code', 'creator_id', 'expires_at'];
- protected $dates = ['created_at', 'updated_at', 'expires_at'];
- public function getRouteKey()
- {
- return $this->attributes['invite_code'];
- }
- public function user()
- {
- return $this->belongsTo(User::class);
- }
- public function creator()
- {
- return $this->belongsTo(User::class, 'creator_id');
- }
- }
- Route::get('/test/{id}', function($id) {
- $i = AppInvitation::find($id);
- dump( $i->invite_code );
- });
- Schema::create('invitations', function (Blueprint $table) {
- $table->string('invite_code')->primary();
- $table->integer('creator_id');
- $table->integer('user_id');
- $table->timestamps();
- $table->dateTime('expires_at');
- });
Add Comment
Please, Sign In to add comment