. */ namespace App\Http\Controllers\Api\Web; use App\Http\Controllers\ApiControllerBase; use App\Models\Image; use App\Models\User; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Response; class ImagesController extends ApiControllerBase { public function getOwned(User $user) { $this->authorize('get-images', $user); $query = Image::where('uploaded_by', $user->id); $images = []; foreach ($query->get() as $image) { $images[] = [ 'id' => $image->id, 'urls' => [ 'small' => $image->getUrl(Image::SMALL), 'normal' => $image->getUrl(Image::NORMAL), 'thumbnail' => $image->getUrl(Image::THUMBNAIL), 'original' => $image->getUrl(Image::ORIGINAL), ], 'filename' => $image->filename, ]; } return response()->json($images, 200); } }