Exemple #1
0
 public function update(UpdateProfileRequest $request)
 {
     $usrdata = $request;
     $profchange = profile::createOrUpdate($request, $this->mtu->id);
     return $profchange;
     //view('user.profile')->with('profmsg', $profchange);
     //post or put request
 }
Exemple #2
0
 public static function createOrUpdate($usrdata, $id)
 {
     $user = Auth::user();
     $record = self::where('usr_id', '=', $id)->first();
     if (is_null($record)) {
         $record = new profile();
         $record->usr_id = $user->id;
         $record->prof_name = $usrdata['profname'];
         $record->bio = $usrdata['profbio'];
         $record->website = $usrdata['profsite'];
         $record->save();
         return 'New profile save successful';
     } else {
         $record->prof_name = $usrdata['profname'];
         $record->bio = $usrdata['profbio'];
         $record->website = $usrdata['profsite'];
         $record->save();
         return ' Record updated successfully';
     }
 }