mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
added api
This commit is contained in:
parent
01a5968e80
commit
e84f9418a5
@ -32,4 +32,5 @@ return [
|
||||
'sold_status_change' => "Your Ad's Status Has Been Set to Sold!",
|
||||
'status_change' => "Your Ad's Status Has Been Set to :status!",
|
||||
'disabled_detailed_options_for_admin_role' => "Detailed product options are disabled.",
|
||||
'permission_error' => 'You do not have permission for this action',
|
||||
];
|
||||
|
||||
@ -32,4 +32,5 @@ return [
|
||||
'sold_status_change' => "İlanın Durumu Satıldı Olarak Ayarlanmıştır!",
|
||||
'status_change' => "İlanın durumu Ayarland :status !",
|
||||
'disabled_detailed_options_for_admin_role' => "Ayrıntılı ürün seçenekleri devre dışı bırakıldı.",
|
||||
'permission_error' => 'Bu işlem için yetkiniz bulunmamaktadır',
|
||||
];
|
||||
|
||||
@ -1,11 +1,36 @@
|
||||
<?php namespace Visiosoft\AdvsModule\Adv;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Visiosoft\ConnectModule\Command\CheckRequiredParams;
|
||||
|
||||
class AdvApiCollection extends AdvRepository
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
public function getMyAds()
|
||||
{
|
||||
return $this->model->userAdv()
|
||||
->where('advs_advs.finish_at', '>', date('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
public function createNewAd(array $params)
|
||||
{
|
||||
return $this->newQuery()->create($params);
|
||||
}
|
||||
|
||||
public function deleteAd(array $params)
|
||||
{
|
||||
$this->dispatch(new CheckRequiredParams(['ad_id'], $params));
|
||||
|
||||
if (!$ad = $this->newQuery()->find($params['ad_id'])) {
|
||||
throw new \Exception(trans('visiosoft.module.advs::message.ad_doesnt_exist'),404);
|
||||
}
|
||||
|
||||
if ($ad->created_by_id != Auth::id()) {
|
||||
throw new \Exception(trans('visiosoft.module.advs::message.permission_error'),403);
|
||||
}
|
||||
|
||||
return $ad->delete();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user