/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(StoreNewPhotoRequest $request) { $data = $request->only(['name', 'url']); $photo = new Photo(); $photo->user_id = Auth::user()->id; $photo->name = $data['name']; $photo->url = $data['url']; $photo->save(); return $this->response->collection(Auth::user()->photos, new PhotoTransformer()); }
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'); }
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; }