|
@@ -8,6 +8,7 @@ use App\Http\Controllers\{
|
|
AvatarController
|
|
AvatarController
|
|
};
|
|
};
|
|
use Auth, Cache, URL;
|
|
use Auth, Cache, URL;
|
|
|
|
+use Carbon\Carbon;
|
|
use App\{
|
|
use App\{
|
|
Avatar,
|
|
Avatar,
|
|
Notification,
|
|
Notification,
|
|
@@ -50,6 +51,21 @@ class BaseApiController extends Controller
|
|
return response()->json($res);
|
|
return response()->json($res);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function notifications(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $pid = Auth::user()->profile->id;
|
|
|
|
+ $timeago = Carbon::now()->subMonths(6);
|
|
|
|
+ $notifications = Notification::with('actor')
|
|
|
|
+ ->whereProfileId($pid)
|
|
|
|
+ ->whereDate('created_at', '>', $timeago)
|
|
|
|
+ ->orderBy('created_at','desc')
|
|
|
|
+ ->paginate(10);
|
|
|
|
+ $resource = new Fractal\Resource\Collection($notifications, new NotificationTransformer());
|
|
|
|
+ $res = $this->fractal->createData($resource)->toArray();
|
|
|
|
+
|
|
|
|
+ return response()->json($res);
|
|
|
|
+ }
|
|
|
|
+
|
|
public function accounts(Request $request, $id)
|
|
public function accounts(Request $request, $id)
|
|
{
|
|
{
|
|
$profile = Profile::findOrFail($id);
|
|
$profile = Profile::findOrFail($id);
|