Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Commit

Permalink
Revert to prev version
Browse files Browse the repository at this point in the history
  • Loading branch information
yugo412 committed Sep 30, 2017
1 parent 3d71292 commit fcc5115
Show file tree
Hide file tree
Showing 206 changed files with 98,549 additions and 6,762 deletions.
6 changes: 1 addition & 5 deletions .env.example
Expand Up @@ -34,8 +34,4 @@ PUSHER_APP_SECRET=
LINE_CHANNEL=
LINE_SECRET=

JWT_SECRET=

SCOUT_DRIVER=elasticsearch
ELASTICSEARCH_INDEX=elasticsearch
ELASTICSEARCH_HOST=http://localhost:9200
JWT_SECRET=
32 changes: 2 additions & 30 deletions app/Glosarium/Category.php
Expand Up @@ -5,12 +5,10 @@
use Carbon\Carbon;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;

class Category extends Model
{
use Sluggable;
use Searchable;

protected $table = 'glosarium_categories';

Expand All @@ -29,7 +27,6 @@ class Category extends Model
'updated_diff',
'edit_url',
'destroy_url',
'summary',
];

protected $hidden = [
Expand All @@ -43,26 +40,6 @@ class Category extends Model
'is_published' => 'boolean',
];

/**
* Get the index name for the model.
*
* @return string
*/
public function searchableAs()
{
return 'glosarium_category_index';
}

/**
* Get the indexable data array for the model.
*
* @return array
*/
public function toSearchableArray()
{
return $this->toArray();
}

/**
* Default parameter for URI.
*
Expand Down Expand Up @@ -103,11 +80,6 @@ public function getUpdatedDiffAttribute()
return $updatedAt->diffForHumans();
}

public function getSummaryAttribute()
{
return str_limit($this->attributes['description'], 50);
}

/**
* @return mixed
*/
Expand All @@ -122,9 +94,9 @@ public function words()
* @param object $query Eloquent
* @return Eloquent
*/
public function scopeFilter($query, $keyword = null)
public function scopeFilter($query)
{
$keyword = request('keyword', $keyword);
$keyword = request('keyword');

if ($keyword) {
$query->where('name', 'LIKE', '%' . $keyword . '%');
Expand Down
40 changes: 10 additions & 30 deletions app/Glosarium/Word.php
Expand Up @@ -6,12 +6,10 @@
use Carbon\Carbon;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;

class Word extends Model
{
use Sluggable;
use Searchable;

protected $table = 'glosarium_words';

Expand All @@ -34,7 +32,16 @@ class Word extends Model
];

protected $hidden = [

'id',
'category_id',
'alias',
'pronounce',
'status',
'is_published',
'is_standard',
'created_at',
'updated_at',
'user_id',
];

protected $appends = [
Expand All @@ -56,26 +63,6 @@ class Word extends Model
'has_description' => 'boolean',
];

/**
* Get the index name for the model.
*
* @return string
*/
public function searchableAs()
{
return 'glosarium_word_index';
}

/**
* Get the indexable data array for the model.
*
* @return array
*/
public function toSearchableArray()
{
return $this->toArray();
}

public function getRouteKeyName()
{
return 'slug';
Expand Down Expand Up @@ -179,13 +166,6 @@ public function scopeFilter($query)
}
}

// filter by category
if (request('category')) {
$query->whereHas('category', function ($category) {
return $category->whereSlug(request('category'));
});
}

return $query;
}

Expand Down
9 changes: 1 addition & 8 deletions app/Http/Controllers/Admin/Bot/KeywordController.php
Expand Up @@ -20,13 +20,6 @@

class KeywordController extends Controller
{
public function paginate()
{
$keywords = Keyword::orderBy('keyword', 'ASC')
->paginate(request('limit', 20));

return response()->json($keywords);
}
/**
* Display a listing of the resource.
*
Expand Down Expand Up @@ -108,7 +101,7 @@ public function update(KeywordRequest $request, Keyword $keyword)
{
abort_if(!Auth::user()->can('update', $keyword), 403, trans('global.http.403'));

$keyword->message = $request->message;
$keyword->message = $request->message;
$keyword->description = $request->description;
$keyword->save();

Expand Down
15 changes: 2 additions & 13 deletions app/Http/Controllers/Admin/Glosarium/CategoryController.php
Expand Up @@ -19,17 +19,6 @@

class CategoryController extends Controller
{
public function paginate()
{
$categories = Category::orderBy('name', 'ASC')
->paginate(request('limit', 20));

if (request()->all()) {
$categories->appends(request()->all());
}

return response()->json($categories);
}
/**
* Display a listing of the resource.
*
Expand Down Expand Up @@ -74,8 +63,8 @@ public function update(CategoryRequest $request, Category $category)
{
abort_if(!Auth()->user()->can('edit', $category), 403, trans('global.http.403'));

$category->name = $category->name;
$category->description = $category->description;
$category->name = $category->name;
$category->description = $category->description;
$category->is_published = $category->publish;
$category->save();

Expand Down
15 changes: 0 additions & 15 deletions app/Http/Controllers/Admin/UserController.php
Expand Up @@ -19,21 +19,6 @@

class UserController extends Controller
{
public function paginate()
{
abort_if(!Auth::user()->can('show', User::class), 403, trans('global.http.403'));

$users = User::orderBy('name', 'ASC')
->filter()
->paginate(request('limit', 20));

if (request('keyword')) {
$users->appends(request()->all());
}

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

/**
* Display a listing of the resource.
*
Expand Down
11 changes: 0 additions & 11 deletions app/Http/Controllers/AppController.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/RegisterController.php
Expand Up @@ -40,7 +40,7 @@ public function __construct()
{
$this->middleware('guest');

$this->redirectTo = route('user.account.dashboard');
$this->redirectTo = route('glosarium.word.index');
}

/**
Expand Down
2 changes: 0 additions & 2 deletions app/Http/Controllers/ContactController.php
Expand Up @@ -88,7 +88,6 @@ public function send(ContactRequest $request)
} catch (Exception $e) {
if (request()->ajax()) {
return response()->json([
'status' => false,
'message' => trans('contact.msg.failed'),
]);
}
Expand All @@ -100,7 +99,6 @@ public function send(ContactRequest $request)

if (request()->ajax()) {
return response()->json([
'status' => true,
'title' => trans('contact.msg.thank'),
'message' => $message,
]);
Expand Down
17 changes: 6 additions & 11 deletions app/Http/Controllers/Glosarium/CategoryController.php
Expand Up @@ -86,7 +86,7 @@ public function paginate()
public function index()
{
// create image
$image = new Image;
$image = new Image;
$imagePath = $image->addText(trans('glosarium.category.index'), 50, 400, 200)
->render('images/pages', 'category')
->path();
Expand All @@ -100,24 +100,19 @@ public function index()
* @param string $slug
* @return Illuminate\Http\Response
*/
public function show()
public function show($slug)
{
$this->cacheTime = Carbon::now()->addDays(7);

$slug = request('slug');
$category = Cache::remember($slug, $this->cacheTime, function () use ($slug) {
return Category::whereSlug($slug)
->first();
});

if (request()->ajax()) {
return response()->json($category);
}

abort_if(empty($category), 404, trans('glosarium.category.notFound'));

// create header image
$image = new Image;
$image = new Image;
$imagePath = $image->addText($category->name, 50, 400, 200)
->render('images/glosariums/categories', $category->slug)
->path();
Expand All @@ -131,7 +126,7 @@ public function total()
abort_if(!request()->ajax(), 404, trans('global.notFound'));

$cacheTime = \Carbon\Carbon::now()->addDays(30);
$total = Cache::remember('category.total', $cacheTime, function () {
$total = Cache::remember('category.total', $cacheTime, function () {
return \App\Glosarium\Category::count();
});

Expand All @@ -155,8 +150,8 @@ public function update(CategoryRequest $request, $slug)
{
$category = Category::whereSlug($slug)->firstOrFail();

$category->name = $request->name;
$category->description = $request->description;
$category->name = $request->name;
$category->description = $request->description;
$category->is_published = $request->publish;
$category->save();

Expand Down

0 comments on commit fcc5115

Please sign in to comment.