mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
added upload
This commit is contained in:
parent
cc9f6c343b
commit
58bf4b85e7
@ -14,6 +14,7 @@ use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
|
||||
use Visiosoft\LocationModule\City\CityModel;
|
||||
use Visiosoft\LocationModule\Country\CountryModel;
|
||||
use Visiosoft\LocationModule\District\DistrictModel;
|
||||
use Visiosoft\MediaFieldType\Http\Controller\UploadController;
|
||||
|
||||
class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
{
|
||||
@ -562,4 +563,33 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
->whereJsonContains('cf_json', [$key => $value])
|
||||
->first();
|
||||
}
|
||||
|
||||
public function uploadImage()
|
||||
{
|
||||
$folder_repository = app(FolderRepositoryInterface::class);
|
||||
|
||||
if (request()->has(['adv_id', 'upload'])
|
||||
and $adv = $this->newQuery()->find(request('adv_id'))
|
||||
and $folder = $folder_repository->findBySlug('images')) {
|
||||
|
||||
|
||||
$upload_service = app(UploadController::class);
|
||||
|
||||
request()->offsetSet('folder', $folder->id);
|
||||
|
||||
if ($response = $upload_service->upload()) {
|
||||
|
||||
$file_id = $response->getData()->id;
|
||||
|
||||
DB::table('advs_advs_files')->insert([
|
||||
'entry_id' => $adv->id,
|
||||
'file_id' => $file_id
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,4 +58,6 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
|
||||
public function currentAds();
|
||||
|
||||
public function findByCFJSON($key, $value);
|
||||
|
||||
public function uploadImage();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user