1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace App;
- use Illuminate\Http\Request;
- class Post extends Model {
-
- protected $fillable = ['body', 'title'];
-
- public function addComment(string $body) {
- $this->comments()->create(compact('body'));
- }
- public function comments()
- {
- return $this->hasMany(Comment::class);
- }
- }
|