mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
image processor added
This commit is contained in:
@@ -46,8 +46,9 @@ class ImportGithubMeetups extends Command
|
||||
['name' => $meetup['name']],
|
||||
[
|
||||
'city_id' => $city->id,
|
||||
'webpage' => $meetup['url'],
|
||||
'webpage' => $meetup['url'],
|
||||
'created_by' => 1,
|
||||
'community' => 'einundzwanzig'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,9 @@ class ReadAndSyncPodcastFeeds extends Command
|
||||
'created_at' => Carbon::parse($item->datePublished),
|
||||
]);
|
||||
}
|
||||
if (app()->environment('local')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
|
||||
33
app/Http/Controllers/ImageController.php
Normal file
33
app/Http/Controllers/ImageController.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use League\Glide\Responses\LaravelResponseFactory;
|
||||
use League\Glide\ServerFactory;
|
||||
|
||||
class ImageController extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function __invoke($path)
|
||||
{
|
||||
$filesystem = Storage::disk('public');
|
||||
|
||||
$server = ServerFactory::create([
|
||||
'response' => new LaravelResponseFactory(app('request')),
|
||||
'source' => $filesystem->getDriver(),
|
||||
'cache' => $filesystem->getDriver(),
|
||||
'cache_path_prefix' => '.cache',
|
||||
'base_url' => 'img',
|
||||
]);
|
||||
|
||||
return $server->getImageResponse($path, request()->all());
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -91,4 +92,25 @@ class Meetup extends Model implements HasMedia
|
||||
{
|
||||
return $this->hasMany(MeetupEvent::class);
|
||||
}
|
||||
|
||||
protected function logoSquare(): Attribute
|
||||
{
|
||||
$getPath = $this->getFirstMediaPath('logo');
|
||||
if ($getPath !== '') {
|
||||
$path = $this->getFirstMediaPath('logo');
|
||||
} else {
|
||||
$path = 'fallback/einundzwanzig.png';
|
||||
}
|
||||
|
||||
return Attribute::make(
|
||||
get: fn() => url()->route('img',
|
||||
[
|
||||
'path' => $path,
|
||||
'w' => 900,
|
||||
'h' => 900,
|
||||
'fit' => 'crop',
|
||||
'fm' => 'webp'
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user