mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* Invoice Ninja (https://invoiceninja.com)
|
||
|
*
|
||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||
|
*
|
||
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||
|
*
|
||
|
* @license https://opensource.org/licenses/AAL
|
||
|
*/
|
||
|
|
||
|
namespace App\Jobs\Util;
|
||
|
|
||
|
use Illuminate\Http\Request;
|
||
|
use Illuminate\Support\Facades\Storage;
|
||
|
use Intervention\Image\ImageManager;
|
||
|
use Illuminate\Bus\Queueable;
|
||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||
|
use Illuminate\Queue\InteractsWithQueue;
|
||
|
use Illuminate\Queue\SerializesModels;
|
||
|
|
||
|
class UploadAvatar implements ShouldQueue
|
||
|
{
|
||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||
|
|
||
|
protected $file;
|
||
|
|
||
|
protected $directory;
|
||
|
|
||
|
public function __construct($file, $directory)
|
||
|
{
|
||
|
$this->file = $file;
|
||
|
$this->directory = $directory;
|
||
|
}
|
||
|
|
||
|
public function handle() : ?string
|
||
|
{
|
||
|
|
||
|
//make dir
|
||
|
Storage::makeDirectory('public/' . $this->directory, 0755);
|
||
|
|
||
|
//upload file
|
||
|
$path = Storage::putFile('public/' . $this->directory, $this->file);
|
||
|
|
||
|
$url = Storage::url($path);
|
||
|
|
||
|
//return file path
|
||
|
if($url)
|
||
|
return $url;
|
||
|
else
|
||
|
return null;
|
||
|
|
||
|
}
|
||
|
}
|