Post.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace App;
  3. use Carbon\Carbon;
  4. class Post extends Model
  5. {
  6. /**
  7. * These fields are OK for mass assignement.
  8. *
  9. * @var array
  10. */
  11. protected $fillable = ['body', 'title', 'user_id'];
  12. /**
  13. * @param string $body
  14. */
  15. public function addComment(string $body)
  16. {
  17. // Comment::create([
  18. // 'body' => $body,
  19. // 'post_id' => $this->id,
  20. // ]);
  21. $this->comments()->create(compact('body'));
  22. }
  23. public static function archives()
  24. {
  25. $archives = static::selectRaw(<<<EOT
  26. year(created_at) as year,
  27. monthname(created_at) as month,
  28. count(*) published
  29. EOT
  30. )->groupBy('year', 'month')
  31. ->orderByRaw('min(created_at) desc')
  32. ->get()
  33. ->toArray();
  34. return $archives;
  35. }
  36. public function comments()
  37. {
  38. return $this->hasMany(Comment::class);
  39. }
  40. public function user()
  41. {
  42. return $this->belongsTo(User::class);
  43. }
  44. /**
  45. * Enables a "filter()" method on Post queries.
  46. */
  47. public function scopeFilter($query, array $filters = [])
  48. {
  49. if ($month = $filters['month'] ?? NULL)
  50. {
  51. /* When parsing just a month name, Carbon returns a date built
  52. from the current date at midnight, with the month replaced by the
  53. specified month name */
  54. $query->whereMonth('created_at', Carbon::parse($month)->month);
  55. }
  56. if ($year = (int) $filters['year'] ?? NULL)
  57. {
  58. /* When parsing just a month name, Carbon returns a date built
  59. from the current date at midnight, with the month replaced by the
  60. specified month name */
  61. $query->whereYear('created_at', $year);
  62. }
  63. return $query;
  64. }
  65. }
PANIC: session(release): write data/sessions/d/4/d4e224b36c86f8c3: no space left on device

PANIC

session(release): write data/sessions/d/4/d4e224b36c86f8c3: no space left on device
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/session@v1.0.3/session.go:204 (0xb13e07)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:80 (0x967b75)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:157 (0x9512ee)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:135 (0x951205)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:124 (0x967cc4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:114 (0x967bf6)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/recovery.go:161 (0x15baec4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/logger.go:40 (0x96b257)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:157 (0x9512ee)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:135 (0x951205)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:124 (0x967cc4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/router.go:187 (0x972959)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/router.go:304 (0x973a01)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/macaron.go:218 (0x96c572)
/my/cache/.heroku/go/go1.26.3/go/src/net/http/server.go:3311 (0x85a5cd)
/my/cache/.heroku/go/go1.26.3/go/src/net/http/server.go:2073 (0x837f6f)
/my/cache/.heroku/go/go1.26.3/go/src/runtime/asm_amd64.s:1771 (0x493380)