Exemplo n.º 1
0
 public function processImageUpload(Request $request)
 {
     $user = User::find($request['user']['sub']);
     $file = $request->file('file');
     $image = Media::create(['name' => $request->file('file')->getClientOriginalName(), 'ext' => $request->file('file')->guessExtension(), 'title' => $request->input('title'), 'description' => $request->input('description'), 'user_id' => $user->id, 'type' => 'IMAGE']);
     $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('/uca/' . $filename, file_get_contents($file), 'public');
     return $image;
 }
Exemplo n.º 2
0
 public function setMainPicture(Request $request, $organizationId, $mediaId)
 {
     $user = User::find($request['user']['sub']);
     $organization = Organization::find($organizationId);
     $media = Media::find($mediaId);
     DB::transaction(function () use($request, $organization, $media) {
         $organization->main_picture = $media->name;
         $organization->save();
     });
     return $media;
 }