-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edbb615
commit d88e4fe
Showing
19 changed files
with
1,203 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Use an official PHP runtime as a parent image | ||
FROM php:8.1-fpm | ||
|
||
WORKDIR /app | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
libzip-dev \ | ||
unzip | ||
|
||
RUN docker-php-ext-install pdo pdo_mysql zip | ||
|
||
COPY . /app | ||
|
||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | ||
|
||
RUN composer install --no-interaction --optimize-autoloader | ||
|
||
EXPOSE 9000 | ||
|
||
CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=9000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
|
||
use App\Services\FirestoreService; | ||
|
||
class ImageController extends Controller | ||
{ | ||
protected $firestoreService; | ||
|
||
public function __construct(FirestoreService $firestoreService) | ||
{ | ||
$this->firestoreService = $firestoreService; | ||
} | ||
|
||
public function index() | ||
{ | ||
// return "hi"; | ||
$imageUrls = $this->firestoreService->getImageUrlsFromStorage("robotics-website-4a145.appspot.com"); | ||
|
||
return response()->json([ | ||
'data' => $imageUrls | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Workshop; | ||
use Illuminate\Http\Request; | ||
|
||
class WorkshopController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
*/ | ||
public function index() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Show the form for creating a new resource. | ||
*/ | ||
public function create() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
*/ | ||
public function store(Request $request) | ||
{ | ||
$workshop = Workshop::create([ | ||
'title' => $request->title, | ||
'description' => $request->description, | ||
'start_date' => $request->start_date, | ||
'location' => $request->location, | ||
'duration' => $request->duration, | ||
]); | ||
|
||
return response()->json(['workshop' => $workshop], 200); | ||
} | ||
|
||
/** | ||
* Display the specified resource. | ||
*/ | ||
public function show(Request $request, Workshop $workshop) | ||
{ | ||
$workshop = Workshop::find($request->id); | ||
|
||
return response( | ||
[ | ||
'workshop' => $workshop, | ||
], | ||
200 | ||
); | ||
} | ||
|
||
public function showActive() | ||
{ | ||
$workshops = Workshop::whereBetween('id', [1, 3])->get(); | ||
return response( | ||
[ | ||
'workshops' => $workshops, | ||
], | ||
200 | ||
); | ||
} | ||
|
||
/** | ||
* Show the form for editing the specified resource. | ||
*/ | ||
public function edit(Workshop $workshop) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Update the specified resource in storage. | ||
*/ | ||
public function update(Request $request, Workshop $workshop) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
*/ | ||
public function destroy(Workshop $workshop) | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Image extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = ['url']; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use App\Models\Image; | ||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Workshop extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = [ | ||
'title', | ||
'description', | ||
'start_date', | ||
'location', | ||
'duration', | ||
]; | ||
|
||
|
||
protected $casts = [ | ||
// 'start_date' => 'datetime', | ||
'duration' => 'integer', | ||
]; | ||
|
||
public function images() | ||
{ | ||
return $this->belongsToMany(Image::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace App\Services; | ||
|
||
use Google\Cloud\Firestore\FirestoreClient; | ||
use Google\Cloud\Storage\StorageClient; | ||
use Google\Cloud\Core\Exception\GoogleException; | ||
|
||
class FirestoreService | ||
{ | ||
protected $firestore; | ||
protected $storage; | ||
|
||
public function __construct() | ||
{ | ||
$this->firestore = new FirestoreClient(); | ||
|
||
try { | ||
// Replace 'your-project-id' with your actual Google Cloud Project ID | ||
$this->storage = new StorageClient(['projectId' => 'robotics-website-4a145']); | ||
} catch (GoogleException $e) { | ||
// Handle exception, e.g., log or throw | ||
} | ||
} | ||
|
||
public function getImageUrlsFromStorage($bucketName) | ||
{ | ||
$bucket = $this->storage->bucket($bucketName); | ||
|
||
$objects = $bucket->objects(); | ||
|
||
$imageUrls = []; | ||
|
||
foreach ($objects as $object) { | ||
// Assuming all objects in the bucket are images | ||
$imageUrls[] = $object->signedUrl(strtotime('+1 hour')); | ||
} | ||
|
||
return $imageUrls; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.