Пример #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $this->theme->title(trans('pages.admin_roles_title'));
     $this->theme->description(trans('pages.admin_roles_desc'));
     $roles = Role::orderBy('created_at', 'desc')->paginate(AppConfig::DEFAULT_ITEMS_PER_PAGE);
     // 2 items per page
     $query = new QueryStringBuilder(['page' => $roles->currentPage()], adminUrl('user-roles'));
     return $this->_list(['roles' => $roles, 'query' => $query, 'page_helper' => new PaginationHelper($roles->lastPage(), $roles->currentPage(), $roles->perPage())]);
 }
Пример #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy(Request $request, $key)
 {
     $option = AppOption::where('key', $key)->firstOrFail();
     $redirect_url = adminUrl('app-options');
     $rdr = $request->session()->pull(AppConfig::KEY_REDIRECT_URL, '');
     if (!empty($rdr)) {
         $redirect_url = $rdr;
     }
     return $option->delete() === true ? redirect($redirect_url) : redirect($redirect_url)->withErrors([trans('error.database_delete')]);
 }
Пример #3
0
                            <th>name</th>
                            <th style="width: 20%;">date modified</th>
                        </tr>
                    </thead>
                    <?php 
foreach ($posts as $post) {
    ?>
                    <tr>
                        <td>
                            <?php 
    echo $post->ID;
    ?>
                        </td>
                        <td>
                            <a href="<?php 
    adminUrl();
    ?>
posts/edit/<?php 
    echo $post->ID;
    ?>
"><?php 
    echo $post->post_name;
    ?>
</a>
                            <div id="actions">
                            </div>
                        </td>
                        <td>
                            <?php 
    echo $post->post_modified;
    ?>
Пример #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy(Request $request, $id)
 {
     $user = User::findOrFail($id);
     $redirect_url = adminUrl('users');
     $rdr = $request->session()->pull(AppConfig::KEY_REDIRECT_URL, '');
     if (!empty($rdr)) {
         $redirect_url = $rdr;
     }
     if ($user->hasRole('owner')) {
         return redirect($redirect_url)->withErrors([trans('error._cannot_delete', ['reason' => trans('error.is_role_owner')])]);
     }
     return $user->delete() === true ? redirect($redirect_url) : redirect($redirect_url)->withErrors([trans('error.database_delete')]);
 }
Пример #5
0
 public function copyTo(Request $request)
 {
     $themeWidget = ThemeWidget::findOrFail($request->input('widget_id'));
     $validator = Validator::make($request->all(), ['placeholder' => 'required|in:' . implode(',', array_keys(HomeThemeFacade::placeholders()))]);
     $redirect = redirect(adminUrl('widgets'));
     if ($validator->fails()) {
         return $redirect->withErrors($validator);
     }
     ThemeWidget::create(['widget_name' => $themeWidget->widget_name, 'theme_name' => $themeWidget->theme_name, 'placeholder' => $request->input('placeholder'), 'constructing_data' => $themeWidget->constructing_data, 'active' => $themeWidget->active, 'order' => ThemeWidget::where('placeholder', $request->input('placeholder'))->count() + 1]);
     return $redirect;
 }
Пример #6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Request $request, $id)
 {
     $link = Link::findOrFail($id);
     $redirect_url = adminUrl('links');
     $rdr = $request->session()->pull(AppConfig::KEY_REDIRECT_URL, '');
     if (!empty($rdr)) {
         $redirect_url = $rdr;
     }
     return $link->delete() === true ? redirect($redirect_url) : redirect($redirect_url)->withErrors([trans('error.database_delete')]);
 }
Пример #7
0
 public function deactivate(Request $request, $name)
 {
     $extensionClasses = array_keys(ExtensionsFacade::all());
     $activatedExtensions = activatedExtensions();
     if (in_array($name, $extensionClasses) && in_array($name, $activatedExtensions)) {
         $activatedExtensions = array_diff($activatedExtensions, [$name]);
         setOption('activated_extensions', $activatedExtensions);
     }
     $redirect_url = adminUrl('extensions');
     $rdr = $request->session()->pull(AppConfig::KEY_REDIRECT_URL, '');
     if (!empty($rdr)) {
         $redirect_url = $rdr;
     }
     return redirect($redirect_url);
 }
Пример #8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Request $request, $id)
 {
     $category = Category::where('type', Category::LINK)->where('id', $id)->firstOrFail();
     if ($category->type != Category::LINK) {
         abort(404);
     }
     $redirect_url = adminUrl('link-categories');
     $rdr = $request->session()->pull(AppConfig::KEY_REDIRECT_URL, '');
     if (!empty($rdr)) {
         $redirect_url = $rdr;
     }
     if ($category->links()->count() <= 0) {
         $success = true;
         DB::beginTransaction();
         try {
             Category::where('parent_id', $id)->update(['parent_id' => null]);
             $category->delete();
             DB::commit();
         } catch (\Exception $ex) {
             DB::rollBack();
             $success = false;
         }
         return $success ? redirect($redirect_url) : redirect($redirect_url)->withErrors([trans('error.database_delete')]);
     }
     return redirect($redirect_url)->withErrors([trans('error.category_not_empty')]);
 }
Пример #9
0
 public function updateEmail(Request $request)
 {
     $validator = Validator::make($request->all(), ['file_locale' => 'required', 'file_name' => 'required', 'file_content' => 'required']);
     if ($validator->fails()) {
         return redirect(adminUrl('ui-lang/email'))->withErrors($validator);
     }
     $storage = Storage::disk('email');
     $file_path = str_replace(['../', '..'], '', $request->input('file_name') . '/' . $request->input('file_locale') . '.blade.php');
     if (!$storage->exists($file_path)) {
         abort(404);
     } else {
         $storage->put($file_path, $request->input('file_content'));
     }
     return redirect(adminUrl('ui-lang/email') . '?file_locale=' . $request->input('file_locale') . '&file_name=' . $request->input('file_name'))->with('response', trans('error.success'));
 }
Пример #10
0
function redirectUrlAfterLogin(User $user)
{
    $localeCode = $user->settings->locale;
    $redirect_url = homeUrl();
    $overwrite_url = session()->pull(AppConfig::KEY_REDIRECT_URL);
    if (!empty($overwrite_url)) {
        $redirect_url = $overwrite_url;
    } elseif ($user->can('access-admin')) {
        $redirect_url = adminUrl(null, [], $localeCode);
    }
    return $redirect_url;
}