Ejemplo n.º 1
0
 public function run()
 {
     DB::table('users')->delete();
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = Hash::make('kierkegaard');
     $user->save();
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = Hash::make('usuario1');
     $user->save();
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = Hash::make('usuario2');
     $user->save();
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = Hash::make('usuario3');
     $user->save();
 }
Ejemplo n.º 2
0
 public function store(Request $request)
 {
     $user = User::find($request['user']['sub']);
     $center = new Center();
     DB::transaction(function () use($request, $center, $user) {
         if ($request->has('location') && isset($request->input('location')['address_components'])) {
             $geo = $this->processGeoValue($request->input('location'));
             $location = Location::firstOrCreate($geo);
             $location->save();
             $center->location_id = $location->id;
         }
         $center->title = $request->input('title');
         $center->description = $request->input('description');
         $center->details = $request->input('details');
         $center->main_picture = $request->input('main_picture');
         $center->twitter_hashtag = $request->input('twitter_hashtag');
         $center->instagram_hashtag = $request->input('instagram_hashtag');
         $center->save();
     });
     return $center;
 }
Ejemplo n.º 3
0
 public function addLogoMedia(Request $request)
 {
     if (!$request->hasFile('file')) {
         return Response::json(['error' => 'No File Sent']);
     }
     if (!$request->file('file')->isValid()) {
         return Response::json(['error' => 'File is not valid']);
     }
     $file = $request->file('file');
     $v = Validator::make($request->all(), ['file' => 'required|mimes:jpeg,jpg,png|max:8000']);
     if ($v->fails()) {
         return Response::json(['error' => $v->errors()]);
     }
     $user = User::find($request['user']['sub']);
     $image = Media::create(['name' => $request->file('file')->getClientOriginalName(), 'ext' => $request->file('file')->guessExtension(), 'title' => $request->input('title'), 'description' => $request->input('description'), 'url' => $request->input('url'), 'user_id' => $user->id, 'type' => 'DATA']);
     $filename = 'media_' . md5(strtolower(trim($image->name))) . '_' . $image->id . '.' . $image->ext;
     $image->name = $filename;
     $image->save();
     Storage::disk('local')->put($filename, File::get($file));
     Storage::disk('s3-aruma')->put('/aruma/' . $filename, file_get_contents($file), 'public');
     return Response::json(['OK' => 1, 'filename' => $image->name, 'media_id' => $image->id]);
 }
Ejemplo n.º 4
0
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['username' => 'required', 'email' => 'required|email|unique:users,email', 'password' => 'required']);
     if ($validator->fails()) {
         return response()->json(['message' => $validator->messages()], 400);
     }
     $user = new User();
     $user->username = $request->input('username');
     $user->email = $request->input('email');
     $user->password = Hash::make($request->input('password'));
     $user->name = $request->input('name');
     $user->lastname = $request->input('lastname');
     $user->save();
     $gravatar = md5(strtolower(trim($user->email)));
     $user->photo = $gravatar;
     $user->save();
     Storage::disk('s3-slam')->put('/slam/profiles/' . $gravatar, file_get_contents('http://www.gravatar.com/avatar/' . $gravatar . '?d=identicon&s=150'), 'public');
     return response()->json($user);
 }
Ejemplo n.º 5
0
 public function removePicture(Request $request, $organizationId, $mediaId)
 {
     $user = User::find($request['user']['sub']);
     $organization = Organization::find($organizationId);
     DB::transaction(function () use($request, $organization, $mediaId) {
         if ($organization->media_id == $mediaId) {
             $organization->media_id = null;
             $organization->main_picture = null;
             $organization->save();
         }
         DB::table('organizations_medias')->where('organization_id', '=', $organization->id)->where('media_id', '=', $mediaId)->delete();
         Media::destroy($mediaId);
     });
 }
Ejemplo n.º 6
0
 public function removePicture(Request $request, $activityId, $mediaId)
 {
     $user = User::find($request['user']['sub']);
     $activity = Activity::find($activityId);
     DB::transaction(function () use($request, $activity, $mediaId) {
         if ($activity->media_id == $mediaId) {
             $activity->media_id = null;
             $activity->main_picture = null;
             $activity->save();
         }
         DB::table('activities_medias')->where('activity_id', '=', $activity->id)->where('media_id', '=', $mediaId)->delete();
         Media::destroy($mediaId);
     });
 }
Ejemplo n.º 7
0
 public function signup(Request $request)
 {
     $validator = Validator::make($request->all(), ['username' => 'required', 'email' => 'required|email|unique:users,email', 'password' => 'required']);
     if ($validator->fails()) {
         return response()->json(['message' => $validator->messages()], 400);
     }
     $user = new User();
     $user->username = $request->input('username');
     $user->email = $request->input('email');
     $user->password = Hash::make($request->input('password'));
     $user->save();
     //$this->dispatch(new UpdateProfilePicture($user));
     $gravatar = md5(strtolower(trim($user->email)));
     $user->photo = $gravatar;
     $user->save();
     Storage::disk('s3-aruma')->put('/aruma/profiles/' . $gravatar, file_get_contents('http://www.gravatar.com/avatar/' . $gravatar . '?d=identicon&s=150'), 'public');
     return response()->json(['token' => $this->createToken($user)]);
 }