/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ public function create(array $data) { $user = User::create(['username' => $data['username'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); $user->assignRole(1); $settings = new Setting(); $settings->user_id = $user->id; $settings->date_format = 'd/m/Y'; $settings->save(); return $user; }
/** * @param string $input * @return \HorseStories\Models\Users\User */ public function search($input) { return $this->user->where('username', 'like', '%' . $input . '%')->orWhere('first_name', 'like', '%' . $input . '%')->orWhere('last_name', 'like', '%' . $input . '%')->get(); }
/** * @param \HorseStories\Models\Users\User $user * @return \HorseStories\Models\Statuses\Status[] */ public function getFeedForUser(User $user) { $horseIds = $user->follows()->lists('horse_id'); $horseIds[] = $user->horses()->lists('id')->all(); return $this->status->with('comments')->whereIn('horse_id', array_flatten($horseIds))->latest()->get(); }
/** * @param int $userId * @return \Illuminate\View\View */ public function index($userId) { $user = User::with('horses')->where('id', $userId)->firstOrFail(); return view('horses.index', compact('user')); }