PublicApiController.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\{
  5. Hashtag,
  6. Follower,
  7. Like,
  8. Media,
  9. Notification,
  10. Profile,
  11. StatusHashtag,
  12. Status,
  13. UserFilter
  14. };
  15. use Auth,Cache;
  16. use Carbon\Carbon;
  17. use League\Fractal;
  18. use App\Transformer\Api\{
  19. AccountTransformer,
  20. RelationshipTransformer,
  21. StatusTransformer,
  22. };
  23. use App\Jobs\StatusPipeline\NewStatusPipeline;
  24. use League\Fractal\Serializer\ArraySerializer;
  25. use League\Fractal\Pagination\IlluminatePaginatorAdapter;
  26. class PublicApiController extends Controller
  27. {
  28. protected $fractal;
  29. public function __construct()
  30. {
  31. $this->fractal = new Fractal\Manager();
  32. $this->fractal->setSerializer(new ArraySerializer());
  33. }
  34. protected function getUserData()
  35. {
  36. if(false == Auth::check()) {
  37. return [];
  38. } else {
  39. $profile = Auth::user()->profile;
  40. if($profile->status) {
  41. return [];
  42. }
  43. $user = new Fractal\Resource\Item($profile, new AccountTransformer());
  44. return $this->fractal->createData($user)->toArray();
  45. }
  46. }
  47. protected function getLikes($status)
  48. {
  49. if(false == Auth::check()) {
  50. return [];
  51. } else {
  52. $profile = Auth::user()->profile;
  53. if($profile->status) {
  54. return [];
  55. }
  56. $likes = $status->likedBy()->orderBy('created_at','desc')->paginate(10);
  57. $collection = new Fractal\Resource\Collection($likes, new AccountTransformer());
  58. return $this->fractal->createData($collection)->toArray();
  59. }
  60. }
  61. protected function getShares($status)
  62. {
  63. if(false == Auth::check()) {
  64. return [];
  65. } else {
  66. $profile = Auth::user()->profile;
  67. if($profile->status) {
  68. return [];
  69. }
  70. $shares = $status->sharedBy()->orderBy('created_at','desc')->paginate(10);
  71. $collection = new Fractal\Resource\Collection($shares, new AccountTransformer());
  72. return $this->fractal->createData($collection)->toArray();
  73. }
  74. }
  75. public function status(Request $request, $username, int $postid)
  76. {
  77. $profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
  78. $status = Status::whereProfileId($profile->id)->findOrFail($postid);
  79. $this->scopeCheck($profile, $status);
  80. $item = new Fractal\Resource\Item($status, new StatusTransformer());
  81. $res = [
  82. 'status' => $this->fractal->createData($item)->toArray(),
  83. 'user' => $this->getUserData(),
  84. 'likes' => $this->getLikes($status),
  85. 'shares' => $this->getShares($status),
  86. 'reactions' => [
  87. 'liked' => $status->liked(),
  88. 'shared' => $status->shared(),
  89. 'bookmarked' => $status->bookmarked(),
  90. ],
  91. ];
  92. return response()->json($res, 200, [], JSON_PRETTY_PRINT);
  93. }
  94. public function statusComments(Request $request, $username, int $postId)
  95. {
  96. $this->validate($request, [
  97. 'min_id' => 'nullable|integer|min:1',
  98. 'max_id' => 'nullable|integer|min:1|max:'.PHP_INT_MAX,
  99. 'limit' => 'nullable|integer|min:5|max:50'
  100. ]);
  101. $limit = $request->limit ?? 10;
  102. $profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
  103. $status = Status::whereProfileId($profile->id)->whereCommentsDisabled(false)->findOrFail($postId);
  104. $this->scopeCheck($profile, $status);
  105. if(Auth::check()) {
  106. $pid = Auth::user()->profile->id;
  107. $filtered = UserFilter::whereUserId($pid)
  108. ->whereFilterableType('App\Profile')
  109. ->whereIn('filter_type', ['mute', 'block'])
  110. ->pluck('filterable_id')->toArray();
  111. } else {
  112. $filtered = [];
  113. }
  114. if($request->filled('min_id') || $request->filled('max_id')) {
  115. if($request->filled('min_id')) {
  116. $replies = $status->comments()
  117. ->whereNull('reblog_of_id')
  118. ->whereNotIn('profile_id', $filtered)
  119. ->select('id', 'caption', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
  120. ->where('id', '>=', $request->min_id)
  121. ->orderBy('id', 'desc')
  122. ->paginate($limit);
  123. }
  124. if($request->filled('max_id')) {
  125. $replies = $status->comments()
  126. ->whereNull('reblog_of_id')
  127. ->whereNotIn('profile_id', $filtered)
  128. ->select('id', 'caption', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
  129. ->where('id', '<=', $request->max_id)
  130. ->orderBy('id', 'desc')
  131. ->paginate($limit);
  132. }
  133. } else {
  134. $replies = $status->comments()
  135. ->whereNull('reblog_of_id')
  136. ->whereNotIn('profile_id', $filtered)
  137. ->select('id', 'caption', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
  138. ->orderBy('id', 'desc')
  139. ->paginate($limit);
  140. }
  141. $resource = new Fractal\Resource\Collection($replies, new StatusTransformer(), 'data');
  142. $resource->setPaginator(new IlluminatePaginatorAdapter($replies));
  143. $res = $this->fractal->createData($resource)->toArray();
  144. return response()->json($res, 200, [], JSON_PRETTY_PRINT);
  145. }
  146. public function statusLikes(Request $request, $username, $id)
  147. {
  148. $profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
  149. $status = Status::whereProfileId($profile->id)->findOrFail($id);
  150. $this->scopeCheck($profile, $status);
  151. $likes = $this->getLikes($status);
  152. return response()->json([
  153. 'data' => $likes
  154. ]);
  155. }
  156. public function statusShares(Request $request, $username, $id)
  157. {
  158. $profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
  159. $status = Status::whereProfileId($profile->id)->findOrFail($id);
  160. $this->scopeCheck($profile, $status);
  161. $shares = $this->getShares($status);
  162. return response()->json([
  163. 'data' => $shares
  164. ]);
  165. }
  166. protected function scopeCheck(Profile $profile, Status $status)
  167. {
  168. if($profile->is_private == true && Auth::check() == false) {
  169. abort(404);
  170. }
  171. switch ($status->scope) {
  172. case 'public':
  173. case 'unlisted':
  174. break;
  175. case 'private':
  176. $user = Auth::check() ? Auth::user() : false;
  177. if(!$user) {
  178. abort(403);
  179. } else {
  180. $follows = $profile->followedBy($user->profile);
  181. if($follows == false && $profile->id !== $user->profile->id && $user->is_admin == false) {
  182. abort(404);
  183. }
  184. }
  185. break;
  186. case 'direct':
  187. abort(404);
  188. break;
  189. case 'draft':
  190. abort(404);
  191. break;
  192. default:
  193. abort(404);
  194. break;
  195. }
  196. }
  197. public function publicTimelineApi(Request $request)
  198. {
  199. $this->validate($request,[
  200. 'page' => 'nullable|integer|max:40',
  201. 'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
  202. 'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
  203. 'limit' => 'nullable|integer|max:20'
  204. ]);
  205. if(config('instance.timeline.local.is_public') == false && !Auth::check()) {
  206. abort(403, 'Authentication required.');
  207. }
  208. $page = $request->input('page');
  209. $min = $request->input('min_id');
  210. $max = $request->input('max_id');
  211. $limit = $request->input('limit') ?? 3;
  212. $private = Cache::remember('profiles:private', now()->addMinutes(1440), function() {
  213. return Profile::whereIsPrivate(true)
  214. ->orWhere('unlisted', true)
  215. ->orWhere('status', '!=', null)
  216. ->pluck('id');
  217. });
  218. if(Auth::check()) {
  219. $pid = Auth::user()->profile->id;
  220. $filters = UserFilter::whereUserId($pid)
  221. ->whereFilterableType('App\Profile')
  222. ->whereIn('filter_type', ['mute', 'block'])
  223. ->pluck('filterable_id')->toArray();
  224. $filtered = array_merge($private->toArray(), $filters);
  225. } else {
  226. $filtered = $private->toArray();
  227. }
  228. if($min || $max) {
  229. $dir = $min ? '>' : '<';
  230. $id = $min ?? $max;
  231. $timeline = Status::select(
  232. 'id',
  233. 'uri',
  234. 'caption',
  235. 'rendered',
  236. 'profile_id',
  237. 'type',
  238. 'in_reply_to_id',
  239. 'reblog_of_id',
  240. 'is_nsfw',
  241. 'scope',
  242. 'local',
  243. 'reply_count',
  244. 'comments_disabled',
  245. 'created_at',
  246. 'updated_at'
  247. )->where('id', $dir, $id)
  248. ->with('profile', 'hashtags', 'mentions')
  249. ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album'])
  250. ->whereLocal(true)
  251. ->whereNull('uri')
  252. ->whereNotIn('profile_id', $filtered)
  253. ->whereNull('in_reply_to_id')
  254. ->whereNull('reblog_of_id')
  255. ->whereVisibility('public')
  256. ->orderBy('created_at', 'desc')
  257. ->limit($limit)
  258. ->get();
  259. } else {
  260. $timeline = Status::select(
  261. 'id',
  262. 'uri',
  263. 'caption',
  264. 'rendered',
  265. 'profile_id',
  266. 'type',
  267. 'in_reply_to_id',
  268. 'reblog_of_id',
  269. 'is_nsfw',
  270. 'scope',
  271. 'local',
  272. 'reply_count',
  273. 'comments_disabled',
  274. 'created_at',
  275. 'updated_at'
  276. )->whereIn('type', ['photo', 'photo:album', 'video', 'video:album'])
  277. ->with('profile', 'hashtags', 'mentions')
  278. ->whereLocal(true)
  279. ->whereNull('uri')
  280. ->whereNotIn('profile_id', $filtered)
  281. ->whereNull('in_reply_to_id')
  282. ->whereNull('reblog_of_id')
  283. ->whereVisibility('public')
  284. ->orderBy('created_at', 'desc')
  285. ->simplePaginate($limit);
  286. }
  287. $fractal = new Fractal\Resource\Collection($timeline, new StatusTransformer());
  288. $res = $this->fractal->createData($fractal)->toArray();
  289. return response()->json($res);
  290. }
  291. public function homeTimelineApi(Request $request)
  292. {
  293. if(!Auth::check()) {
  294. return abort(403);
  295. }
  296. $this->validate($request,[
  297. 'page' => 'nullable|integer|max:40',
  298. 'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
  299. 'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
  300. 'limit' => 'nullable|integer|max:20'
  301. ]);
  302. $page = $request->input('page');
  303. $min = $request->input('min_id');
  304. $max = $request->input('max_id');
  305. $limit = $request->input('limit') ?? 3;
  306. // TODO: Use redis for timelines
  307. // $timeline = Timeline::build()->local();
  308. $pid = Auth::user()->profile->id;
  309. $following = Cache::remember('profile:following:'.$pid, now()->addMinutes(1440), function() use($pid) {
  310. $following = Follower::whereProfileId($pid)->pluck('following_id');
  311. return $following->push($pid)->toArray();
  312. });
  313. $private = Cache::remember('profiles:private', 1440, function() {
  314. return Profile::whereIsPrivate(true)
  315. ->orWhere('unlisted', true)
  316. ->orWhere('status', '!=', null)
  317. ->pluck('id');
  318. });
  319. $private = $private->diff($following)->flatten();
  320. $filters = UserFilter::whereUserId($pid)
  321. ->whereFilterableType('App\Profile')
  322. ->whereIn('filter_type', ['mute', 'block'])
  323. ->pluck('filterable_id')->toArray();
  324. $filtered = array_merge($private->toArray(), $filters);
  325. if($min || $max) {
  326. $dir = $min ? '>' : '<';
  327. $id = $min ?? $max;
  328. $timeline = Status::select(
  329. 'id',
  330. 'uri',
  331. 'caption',
  332. 'rendered',
  333. 'profile_id',
  334. 'type',
  335. 'in_reply_to_id',
  336. 'reblog_of_id',
  337. 'is_nsfw',
  338. 'scope',
  339. 'local',
  340. 'reply_count',
  341. 'comments_disabled',
  342. 'created_at',
  343. 'updated_at'
  344. )->whereIn('type', ['photo', 'photo:album', 'video', 'video:album'])
  345. ->with('profile', 'hashtags', 'mentions')
  346. ->where('id', $dir, $id)
  347. ->whereIn('profile_id', $following)
  348. ->whereNotIn('profile_id', $filtered)
  349. ->whereNull('in_reply_to_id')
  350. ->whereNull('reblog_of_id')
  351. ->whereIn('visibility',['public', 'unlisted', 'private'])
  352. ->orderBy('created_at', 'desc')
  353. ->limit($limit)
  354. ->get();
  355. } else {
  356. $timeline = Status::select(
  357. 'id',
  358. 'uri',
  359. 'caption',
  360. 'rendered',
  361. 'profile_id',
  362. 'type',
  363. 'in_reply_to_id',
  364. 'reblog_of_id',
  365. 'is_nsfw',
  366. 'scope',
  367. 'local',
  368. 'reply_count',
  369. 'comments_disabled',
  370. 'created_at',
  371. 'updated_at'
  372. )->whereIn('type', ['photo', 'photo:album', 'video', 'video:album'])
  373. ->with('profile', 'hashtags', 'mentions')
  374. ->whereIn('profile_id', $following)
  375. ->whereNotIn('profile_id', $filtered)
  376. ->whereNull('in_reply_to_id')
  377. ->whereNull('reblog_of_id')
  378. ->whereIn('visibility',['public', 'unlisted', 'private'])
  379. ->orderBy('created_at', 'desc')
  380. ->simplePaginate($limit);
  381. }
  382. $fractal = new Fractal\Resource\Collection($timeline, new StatusTransformer());
  383. $res = $this->fractal->createData($fractal)->toArray();
  384. return response()->json($res);
  385. }
  386. public function networkTimelineApi(Request $request)
  387. {
  388. if(!Auth::check()) {
  389. return abort(403);
  390. }
  391. $this->validate($request,[
  392. 'page' => 'nullable|integer|max:40',
  393. 'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
  394. 'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
  395. 'limit' => 'nullable|integer|max:20'
  396. ]);
  397. $page = $request->input('page');
  398. $min = $request->input('min_id');
  399. $max = $request->input('max_id');
  400. $limit = $request->input('limit') ?? 3;
  401. // TODO: Use redis for timelines
  402. // $timeline = Timeline::build()->local();
  403. $pid = Auth::user()->profile->id;
  404. $private = Cache::remember('profiles:private', now()->addMinutes(1440), function() {
  405. return Profile::whereIsPrivate(true)
  406. ->orWhere('unlisted', true)
  407. ->orWhere('status', '!=', null)
  408. ->pluck('id');
  409. });
  410. $filters = UserFilter::whereUserId($pid)
  411. ->whereFilterableType('App\Profile')
  412. ->whereIn('filter_type', ['mute', 'block'])
  413. ->pluck('filterable_id')->toArray();
  414. $filtered = array_merge($private->toArray(), $filters);
  415. if($min || $max) {
  416. $dir = $min ? '>' : '<';
  417. $id = $min ?? $max;
  418. $timeline = Status::select(
  419. 'id',
  420. 'uri',
  421. 'caption',
  422. 'rendered',
  423. 'profile_id',
  424. 'type',
  425. 'in_reply_to_id',
  426. 'reblog_of_id',
  427. 'is_nsfw',
  428. 'scope',
  429. 'local',
  430. 'reply_count',
  431. 'comments_disabled',
  432. 'created_at',
  433. 'updated_at'
  434. )->where('id', $dir, $id)
  435. ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album'])
  436. ->whereNotIn('profile_id', $filtered)
  437. ->whereNotNull('uri')
  438. ->whereNull('in_reply_to_id')
  439. ->whereNull('reblog_of_id')
  440. ->whereVisibility('public')
  441. ->latest()
  442. ->limit($limit)
  443. ->get();
  444. } else {
  445. $timeline = Status::select(
  446. 'id',
  447. 'uri',
  448. 'caption',
  449. 'rendered',
  450. 'profile_id',
  451. 'type',
  452. 'in_reply_to_id',
  453. 'reblog_of_id',
  454. 'is_nsfw',
  455. 'scope',
  456. 'local',
  457. 'reply_count',
  458. 'comments_disabled',
  459. 'created_at',
  460. 'updated_at'
  461. )->whereIn('type', ['photo', 'photo:album', 'video', 'video:album'])
  462. ->whereNotIn('profile_id', $filtered)
  463. ->whereNull('in_reply_to_id')
  464. ->whereNull('reblog_of_id')
  465. ->whereNotNull('uri')
  466. ->whereVisibility('public')
  467. ->latest()
  468. ->simplePaginate($limit);
  469. }
  470. $fractal = new Fractal\Resource\Collection($timeline, new StatusTransformer());
  471. $res = $this->fractal->createData($fractal)->toArray();
  472. return response()->json($res);
  473. }
  474. public function relationships(Request $request)
  475. {
  476. abort_if(!Auth::check(), 403);
  477. $this->validate($request, [
  478. 'id' => 'required|array|min:1|max:20',
  479. 'id.*' => 'required|integer'
  480. ]);
  481. $ids = collect($request->input('id'));
  482. $filtered = $ids->filter(function($v) {
  483. return $v != Auth::user()->profile->id;
  484. });
  485. $relations = Profile::whereNull('status')->findOrFail($filtered->all());
  486. $fractal = new Fractal\Resource\Collection($relations, new RelationshipTransformer());
  487. $res = $this->fractal->createData($fractal)->toArray();
  488. return response()->json($res);
  489. }
  490. public function account(Request $request, $id)
  491. {
  492. $profile = Profile::whereNull('status')->findOrFail($id);
  493. $resource = new Fractal\Resource\Item($profile, new AccountTransformer());
  494. $res = $this->fractal->createData($resource)->toArray();
  495. return response()->json($res);
  496. }
  497. public function accountFollowers(Request $request, $id)
  498. {
  499. abort_unless(Auth::check(), 403);
  500. $profile = Profile::with('user')->whereNull('status')->whereNull('domain')->findOrFail($id);
  501. if(Auth::id() != $profile->user_id && $profile->is_private || !$profile->user->settings->show_profile_followers) {
  502. return response()->json([]);
  503. }
  504. $followers = $profile->followers()->orderByDesc('followers.created_at')->paginate(10);
  505. $resource = new Fractal\Resource\Collection($followers, new AccountTransformer());
  506. $res = $this->fractal->createData($resource)->toArray();
  507. return response()->json($res);
  508. }
  509. public function accountFollowing(Request $request, $id)
  510. {
  511. abort_unless(Auth::check(), 403);
  512. $profile = Profile::with('user')->whereNull('status')->whereNull('domain')->findOrFail($id);
  513. if(Auth::id() != $profile->user_id && $profile->is_private || !$profile->user->settings->show_profile_following) {
  514. return response()->json([]);
  515. }
  516. $following = $profile->following()->orderByDesc('followers.created_at')->paginate(10);
  517. $resource = new Fractal\Resource\Collection($following, new AccountTransformer());
  518. $res = $this->fractal->createData($resource)->toArray();
  519. return response()->json($res);
  520. }
  521. public function accountStatuses(Request $request, $id)
  522. {
  523. $this->validate($request, [
  524. 'only_media' => 'nullable',
  525. 'pinned' => 'nullable',
  526. 'exclude_replies' => 'nullable',
  527. 'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
  528. 'since_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
  529. 'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
  530. 'limit' => 'nullable|integer|min:1|max:24'
  531. ]);
  532. $profile = Profile::whereNull('status')->findOrFail($id);
  533. $limit = $request->limit ?? 9;
  534. $max_id = $request->max_id;
  535. $min_id = $request->min_id;
  536. $scope = $request->only_media == true ?
  537. ['photo', 'photo:album', 'video', 'video:album'] :
  538. ['photo', 'photo:album', 'video', 'video:album', 'share', 'reply'];
  539. if($profile->is_private) {
  540. if(!Auth::check()) {
  541. return response()->json([]);
  542. }
  543. $pid = Auth::user()->profile->id;
  544. $following = Cache::remember('profile:following:'.$pid, now()->addMinutes(1440), function() use($pid) {
  545. $following = Follower::whereProfileId($pid)->pluck('following_id');
  546. return $following->push($pid)->toArray();
  547. });
  548. $visibility = true == in_array($profile->id, $following) ? ['public', 'unlisted', 'private'] : [];
  549. } else {
  550. if(Auth::check()) {
  551. $pid = Auth::user()->profile->id;
  552. $following = Cache::remember('profile:following:'.$pid, now()->addMinutes(1440), function() use($pid) {
  553. $following = Follower::whereProfileId($pid)->pluck('following_id');
  554. return $following->push($pid)->toArray();
  555. });
  556. $visibility = true == in_array($profile->id, $following) ? ['public', 'unlisted', 'private'] : ['public', 'unlisted'];
  557. } else {
  558. $visibility = ['public', 'unlisted'];
  559. }
  560. }
  561. $dir = $min_id ? '>' : '<';
  562. $id = $min_id ?? $max_id;
  563. $timeline = Status::select(
  564. 'id',
  565. 'uri',
  566. 'caption',
  567. 'rendered',
  568. 'profile_id',
  569. 'type',
  570. 'in_reply_to_id',
  571. 'reblog_of_id',
  572. 'is_nsfw',
  573. 'scope',
  574. 'local',
  575. 'created_at',
  576. 'updated_at'
  577. )->whereProfileId($profile->id)
  578. ->whereIn('type', $scope)
  579. ->whereLocal(true)
  580. ->whereNull('uri')
  581. ->where('id', $dir, $id)
  582. ->whereIn('visibility', $visibility)
  583. ->latest()
  584. ->limit($limit)
  585. ->get();
  586. $resource = new Fractal\Resource\Collection($timeline, new StatusTransformer());
  587. $res = $this->fractal->createData($resource)->toArray();
  588. return response()->json($res);
  589. }
  590. }