-
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
Showing
4 changed files
with
90 additions
and
0 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
51 changes: 51 additions & 0 deletions
51
src/Http/Controllers/Api/V1/Admin/System/TinyMCEController.php
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,51 @@ | ||
<?php | ||
|
||
namespace NexaMerchant\Apis\Http\Controllers\Api\V1\Admin\System; | ||
|
||
use Illuminate\Support\Facades\Storage; | ||
|
||
class TinyMCEController extends Controller | ||
{ | ||
/** | ||
* Storage folder path. | ||
* | ||
* @var string | ||
*/ | ||
private $storagePath = 'tinymce'; | ||
|
||
/** | ||
* Upload file from tinymce. | ||
* | ||
* @return void | ||
*/ | ||
public function upload() | ||
{ | ||
$media = $this->storeMedia(); | ||
|
||
if (! empty($media)) { | ||
return response()->json([ | ||
'location' => $media['file_url'] | ||
]); | ||
} | ||
|
||
return response()->json([]); | ||
} | ||
|
||
/** | ||
* Store media. | ||
* | ||
* @return array | ||
*/ | ||
public function storeMedia() | ||
{ | ||
if (! request()->hasFile('file')) { | ||
return []; | ||
} | ||
|
||
return [ | ||
'file' => $path = request()->file('file')->store($this->storagePath), | ||
'file_name' => request()->file('file')->getClientOriginalName(), | ||
'file_url' => Storage::url($path), | ||
]; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -50,4 +50,9 @@ | |
* Reporting routes. | ||
*/ | ||
require 'reporting-routes.php'; | ||
|
||
/** | ||
* System routes. | ||
*/ | ||
require 'system-routes.php'; | ||
}); |
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 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Route; | ||
|
||
use NexaMerchant\Apis\Http\Controllers\Api\V1\Admin\System\TinyMCEController; | ||
|
||
/** | ||
* System routes. | ||
*/ | ||
Route::group([ | ||
'middleware' => ['auth:sanctum', 'sanctum.admin'], | ||
'prefix' => 'system', | ||
], function () { | ||
/** | ||
* TinyMCE routes. | ||
*/ | ||
Route::controller(TinyMCEController::class)->prefix('tinymce')->group(function () { | ||
Route::post('upload', 'upload'); | ||
}); | ||
}); |