add cycle

This commit is contained in:
Fayyazi
2019-08-21 10:09:27 +04:30
parent e16fd9a120
commit 2872e09039
23 changed files with 213 additions and 485 deletions
+5 -1
View File
@@ -59,13 +59,17 @@ class PackageController extends Controller
}
public function destroy(Package $Package)
{
if (!auth('api')->user()->can('delete', $Package)) {
if (auth('api')->user()->cant('delete', $Package)) {
return \MessageResponse::error(trans('messages.access_denied'));
}
if(count($Package->items))
{
$Package->items()->detach();
}
if(count($Package->cycles))
{
$Package->cycles()->detach();
}
$Package->delete();
return \MessageResponse::success(trans('messages.success'));
}