public function destroy($id = null)
{
// If multiple ids are specified
if ($id == 'multiple') {
$selected_ids = trim(Input::get('selected_ids'));
if ($selected_ids == '') {
return Redirect::back()->with('error_message', trans('error_messages.nothing_selected_delete'));
}
$selected_ids = explode(' ', $selected_ids);
} else {
$selected_ids = array($id);
}
foreach ($selected_ids as $id) {
$theme = Theme::findOrFail($id);
if (\Setting::value("{$theme->target}_theme") == $theme->id) {
return Redirect::back()->with('error_message', "The theme {$theme->name} can not be deleted because it is currently being used as {$theme->target} theme.");
}
File::delete($theme->screenshot);
File::deleteDirectory(app_path() . "/../resources/views/{$theme->target}/{$theme->directory}/", false);
File::deleteDirectory(public_path() . "/assets/{$theme->target}/{$theme->directory}/", false);
$theme->settings()->delete();
$theme->delete();
}
$wasOrWere = count($selected_ids) > 1 ? 's were' : ' was';
$message = 'The theme' . $wasOrWere . ' deleted.';
return Redirect::to("backend/theme-manager")->with('success_message', $message);
}