Guest User

Untitled

a guest
Jan 16th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. class Invitation extends Model
  2. {
  3. protected $primaryKey = 'invite_code';
  4.  
  5. protected $fillable = ['invite_code', 'creator_id', 'expires_at'];
  6. protected $dates = ['created_at', 'updated_at', 'expires_at'];
  7.  
  8. public function getRouteKey()
  9. {
  10. return $this->attributes['invite_code'];
  11. }
  12.  
  13. public function user()
  14. {
  15. return $this->belongsTo(User::class);
  16. }
  17.  
  18. public function creator()
  19. {
  20. return $this->belongsTo(User::class, 'creator_id');
  21. }
  22. }
  23.  
  24. Route::get('/test/{id}', function($id) {
  25. $i = AppInvitation::find($id);
  26. dump( $i->invite_code );
  27. });
  28.  
  29. Schema::create('invitations', function (Blueprint $table) {
  30. $table->string('invite_code')->primary();
  31. $table->integer('creator_id');
  32. $table->integer('user_id');
  33. $table->timestamps();
  34. $table->dateTime('expires_at');
  35. });
Add Comment
Please, Sign In to add comment