Images can now be uploaded via the media endpoint in a basic way

This commit is contained in:
Jonny Barnes 2017-03-18 20:09:11 +00:00
parent 16015d3f4b
commit 764557b96b
10 changed files with 125 additions and 75 deletions

View file

@ -4,11 +4,10 @@ declare(strict_types=1);
namespace App\Services;
use App\Note;
use App\Place;
use App\Jobs\SendWebMentions;
use App\Jobs\SyndicateToTwitter;
use App\Jobs\SyndicateToFacebook;
use Illuminate\Support\Facades\Log;
use App\{Media, Note, Place};
use App\Jobs\{SendWebMentions, SyndicateToFacebook, SyndicateToTwitter};
class NoteService
{
@ -55,6 +54,15 @@ class NoteService
}
}
*/
//add support for media uploaded as URLs
foreach ($data['photo'] as $photo) {
// check the media was uploaded to my endpoint
if (starts_with($photo, config('filesystems.disks.s3.url'))) {
$path = substr($photo, strlen(config('filesystems.disks.s3.url')));
$media = Media::where('path', ltrim($path, '/'))->firstOrFail();
$note->media()->save($media);
}
}
$note->save();