monteecristoo’s blog

https://twitter.com/irakaarozo

Laravel pagination backend setting with Vue.js

@relationships.php

public function res_recommend() // users not follow
{
  $fs = $this->follows()->get(); // Auth_userがfollowしているuser
  $follows = array();
  foreach($fs as $f) {
    array_push($follows, $f->target_id);
  }
  array_push($follows, $this->id);
  $users = \App\User::whereNotIn('id', $follows)->paginate(3); // $follows以外のuser
  return $users;
}