/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $data = $request->only(['gender', 'address', 'bio', 'birthday', 'birthplace', 'city', 'email', 'enabled', 'first_name', 'last_name', 'phone_number', 'postalcode', 'website']);
     $personalInfo = PersonalInformation::where('user_id', '=', Auth::user()->id)->first();
     if ($personalInfo != null) {
         $data['enabled'] = $data['enabled'] ? 1 : 0;
         $personalInfo->update($data);
         // updating
     } else {
         // creating
         $personalInfo = new PersonalInformation();
         $personalInfo->enabled = $data['enabled'] ? 1 : 0;
         $personalInfo->user_id = Auth::user()->id;
         $personalInfo->first_name = $data['first_name'];
         $personalInfo->last_name = $data['last_name'];
         $personalInfo->phone_number = $data['phone_number'];
         $personalInfo->birthday = $data['birthday'];
         $personalInfo->birthplace = $data['birthplace'];
         $personalInfo->address = $data['address'];
         $personalInfo->postalcode = $data['postalcode'];
         $personalInfo->city = $data['city'];
         $personalInfo->email = $data['email'];
         $personalInfo->website = $data['website'];
         $personalInfo->bio = $data['bio'];
         $personalInfo->save();
     }
     return response()->api('OK');
 }
Пример #2
0
 public function generatePdf()
 {
     $personalInfo = PersonalInformation::where('user_id', '=', Auth::user()->id)->where('enabled', '=', 1)->first();
     $skills = SKill::with('skillType')->where('user_id', '=', Auth::user()->id)->where('enabled', '=', 1)->get();
     $work = Work::where('user_id', '=', Auth::user()->id)->where('enabled', '=', 1)->get();
     $education = Education::where('user_id', '=', Auth::user()->id)->where('enabled', '=', 1)->get();
     $photo = Photo::where('user_id', '=', Auth::user()->id)->where('enabled', '=', 1)->get();
     $data = ['personal' => $personalInfo->toArray(), 'skills' => $skills->toArray(), 'work' => $work->toArray(), 'education' => $education->toArray(), 'photo' => $photo->toArray()];
     // $headers = array(
     //     'Content-Type' => 'application/octet-stream',
     //     'Content-Length' => strlen($pdf),
     //     'Content-Dsiposition' => 'attachment; filename="resume.pdf"',
     //     'Authorization' => 'Bearer '.
     // )
     $pdf = PDF::loadView('resume', array('data' => $data));
     return $pdf->download('resume.pdf');
 }
Пример #3
0
 public function githubCallback()
 {
     $githubUser = Socialite::driver('github')->scopes(['gist'])->user();
     $user = JWTAuth::setToken(Session::get('token'))->authenticate();
     $personalInfo = PersonalInformation::where('user_id', '=', $user->id)->first();
     $photo = Photo::where('user_id', '=', $user->id)->where('name', '=', 'Github')->first();
     $client = new Client();
     $response = $client->request('GET', $githubUser->avatar);
     $body = $response->getBody();
     if ($photo == null) {
         $ph = new Photo();
         $ph->name = 'Github';
         $ph->url = base64_encode($body);
         $ph->user_id = $user->id;
         $ph->enabled = false;
         $ph->save();
     }
     if ($personalInfo != null) {
         // update the information
         $personalInfo->first_name = $githubUser->user['name'];
         $personalInfo->email = $githubUser->user['email'];
         $personalInfo->bio = $githubUser->user['bio'];
         $personalInfo->save();
     } else {
         // create it
         $pi = new PersonalInformation();
         $pi->user_id = Auth::user()->id;
         $pi->first_name = $githubUser->user['name'];
         $pi->email = $githubUser->user['email'];
         $pi->bio = $githubUser->user['bio'];
         $pi->save();
     }
     $view = View::make('welcome');
     $view->script = 'window.close();';
     return $view;
 }