Skip to content

Commit

Permalink
Merge pull request #75 from Kovah/dev
Browse files Browse the repository at this point in the history
v0.0.25
  • Loading branch information
Kovah authored Oct 29, 2019
2 parents f77cc7b + 13d327e commit 82ff258
Show file tree
Hide file tree
Showing 60 changed files with 932 additions and 1,025 deletions.
32 changes: 32 additions & 0 deletions app/Http/Controllers/API/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Http\Controllers\Controller;
use App\Models\Link;
use App\Models\LinkList;
use App\Models\Tag;
use Illuminate\Http\Request;

Expand Down Expand Up @@ -45,6 +46,37 @@ public function getTags(Request $request)
return response()->json($tags);
}

/**
* @param Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function getLists(Request $request)
{
$query = $request->get('query', false);

if (!$query) {
return response()->json([]);
}

// Search for tags
$tags = LinkList::byUser(auth()->user()->id)
->where('name', 'like', '%' . $query . '%')
->orderBy('name', 'asc')
->get();

if (!$tags->isEmpty()) {
// Properly format the results
$tags = $tags->map(function ($item) {
return [
'value' => $item->name,
'text' => $item->name,
];
});
}

return response()->json($tags);
}

/**
* @param Request $request
* @return \Illuminate\Http\JsonResponse
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/App/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\Link;
use App\Models\LinkList;
use App\Models\Note;
use App\Models\Tag;

Expand All @@ -28,7 +29,7 @@ public function index()

$stats = [
'total_links' => Link::count(),
'total_categories' => Category::count(),
'total_lists' => LinkList::count(),
'total_tags' => Tag::count(),
'total_notes' => Note::count(),
'total_broken_links' => $broken_links,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace App\Http\Controllers\Guest;

use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\LinkList;
use Illuminate\Http\Request;

class CategoryController extends Controller
class ListController extends Controller
{
/**
* Display the specified resource.
Expand All @@ -17,14 +17,14 @@ class CategoryController extends Controller
*/
public function show(Request $request, $id)
{
$category = Category::find($id);
$list = LinkList::find($id);

if (empty($category)) {
if (empty($list)) {
abort(404);
}

// Get links of the category
$links = $category->links()->privateOnly(false);
$links = $list->links()->privateOnly(false);

if ($request->has('orderBy') && $request->has('orderDir')) {
$links->orderBy($request->get('orderBy'), $request->get('orderDir'));
Expand All @@ -34,9 +34,9 @@ public function show(Request $request, $id)

$links = $links->paginate(getPaginationLimit());

return view('guest.categories.show', [
'category' => $category,
'category_links' => $links,
return view('guest.lists.show', [
'list' => $list,
'list_links' => $links,
'route' => $request->getBaseUrl(),
'order_by' => $request->get('orderBy'),
'order_dir' => $request->get('orderDir'),
Expand Down
192 changes: 0 additions & 192 deletions app/Http/Controllers/Models/CategoryController.php

This file was deleted.

10 changes: 1 addition & 9 deletions app/Http/Controllers/Models/LinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ public function create()
// Reset the bookmarklet session identifier to prevent issues on regular pages
session()->forget('bookmarklet.create');

return view('models.links.create')
->with('categories', Category::parentOnly()
->byUser(auth()->user()->id)
->orderBy('name')
->get());
return view('models.links.create');
}

/**
Expand Down Expand Up @@ -134,10 +130,6 @@ public function edit($id)
}

return view('models.links.edit')
->with('categories', Category::parentOnly()
->byUser(auth()->user()->id)
->orderBy('name', 'asc')
->get())
->with('link', $link);
}

Expand Down
Loading

0 comments on commit 82ff258

Please sign in to comment.