/** * Run the database seeds. * * @return void */ public function run() { $faker = \Faker\Factory::create(); $division = ['Regular', 'Extenesion']; $stream = ['Natural', 'Social']; $region = ['Tigray', 'Afar', 'Amhara', 'Oromia', 'Addis Ababa', 'Somolia']; foreach (range(1, 55) as $index) { Profile::create(['user_id' => $index, 'profile_pic' => '/propic/' . $faker->numberBetween(0, 4) . '.jpg', 'bio' => $faker->paragraph, 'school' => $faker->word, 'division' => $division[$faker->numberBetween(0, 1)], 'stream' => $stream[$faker->numberBetween(0, 1)], 'region' => $region[$faker->numberBetween(0, 5)]]); } }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Requests\ProfileUpdateFormRequest $request, $id) { //validate the inputes //check if the user can update $profile = Profile::findOrFail($id); //Get all inputes $name = $profile->user->id . '_profile_pic'; if (\Input::hasfile('profile_pic')) { $extention = \Input::file('profile_pic')->getClientOriginalExtension(); $filename = $name . '.' . $extention; $destination_path = 'storage/users/' . $profile->user->id . '/profilepic'; $profile_pic_path = '/' . $destination_path . '/' . $filename; $isuploaded = \Input::file('profile_pic')->move($destination_path, $filename); } else { $filename = $profile->profile_pic; } //update profile $profile->fill(['profile_pic' => $profile_pic_path, 'bio' => $request->bio, 'region' => $request->region, 'school' => $request->school, 'division' => $request->division, 'stream' => $request->stream])->save(); //redirect user to profile show route $message = "You have successfully update your profile"; return \Redirect::route('user.profile.show', \Auth::user()->id)->with('success', $message); }