update v1.0.7.9 R.C.
This is a Release Candidate. We are still testing.
This commit is contained in:
@@ -63,23 +63,18 @@ class ArticleController extends Controller
|
||||
public function getData()
|
||||
{
|
||||
$article = new Article();
|
||||
$articles = $article
|
||||
->select('id', 'name', 'description', 'publish_time', 'slug')
|
||||
->orderBy('publish_time','desc')
|
||||
->get();
|
||||
// returns chumper datatable
|
||||
return Datatable::query($article)
|
||||
/* searcable column name */
|
||||
->searchColumns('name')
|
||||
/* order column name and description */
|
||||
->orderColumns('name', 'description')
|
||||
return Datatable::Collection($articles)
|
||||
|
||||
/* add column name */
|
||||
->addColumn('name', function ($model) {
|
||||
$string = strip_tags($model->name);
|
||||
if (strlen($string) > 40) {
|
||||
// truncate string
|
||||
$stringCut = substr($string, 0, 40);
|
||||
} else {
|
||||
$stringCut = $model->name;
|
||||
}
|
||||
$name = str_limit($model->name, 20, '...');
|
||||
|
||||
return $stringCut.'...';
|
||||
return "<p title=$model->name>$name</p>";
|
||||
})
|
||||
/* add column Created */
|
||||
->addColumn('publish_time', function ($model) {
|
||||
@@ -90,7 +85,7 @@ class ArticleController extends Controller
|
||||
/* add column action */
|
||||
->addColumn('Actions', function ($model) {
|
||||
/* here are all the action buttons and modal popup to delete articles with confirmations */
|
||||
return '<span data-toggle="modal" data-target="#deletearticle'.$model->id.'"><a href="#" ><button class="btn btn-danger btn-xs"></a> '.\Lang::get('lang.delete').' </button></span> <a href=article/'.$model->id.'/edit class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a> <a href=show/'.$model->slug.' class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>
|
||||
return '<span data-toggle="modal" data-target="#deletearticle'.$model->id.'"><a href="#" ><button class="btn btn-danger btn-xs"></a> '.\Lang::get('lang.delete').' </button></span> <a href='.url("article/$model->id/edit").' class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a> <a href='.url("show/$model->slug").' class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>
|
||||
<div class="modal fade" id="deletearticle'.$model->id.'">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
@@ -103,12 +98,14 @@ class ArticleController extends Controller
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
|
||||
<a href="article/delete/'.$model->slug.'"><button class="btn btn-danger">delete</button></a>
|
||||
<a href='.url("article/delete/$model->slug").'><button class="btn btn-danger">delete</button></a>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
})
|
||||
->searchColumns('name', 'description', 'publish_time')
|
||||
->orderColumns('name', 'description', 'publish_time')
|
||||
->make();
|
||||
}
|
||||
|
||||
@@ -253,9 +250,9 @@ class ArticleController extends Controller
|
||||
$article->publish_time = $publishTime;
|
||||
$article->save();
|
||||
|
||||
return redirect('article')->with('success', Lang::get('lang.article_updated_successfully'));
|
||||
return redirect()->back()->with('success', Lang::get('lang.article_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('article')->with('fails', Lang::get('lang.article_not_updated').'<li>'.$e->getMessage().'</li>');
|
||||
return redirect()->back()->with('fails', Lang::get('lang.article_not_updated').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,12 +282,12 @@ class ArticleController extends Controller
|
||||
}
|
||||
if ($article) {
|
||||
if ($article->delete()) {//true:redirect to index page with success message
|
||||
return Redirect::back()->with('success', Lang::get('lang.article_deleted_successfully'));
|
||||
return redirect('article')->with('success', Lang::get('lang.article_deleted_successfully'));
|
||||
} else { //redirect to index page with fails message
|
||||
return Redirect::back()->with('fails', Lang::get('lang.article_not_deleted'));
|
||||
return redirect('article')->with('fails', Lang::get('lang.article_not_deleted'));
|
||||
}
|
||||
} else {
|
||||
return Redirect::back()->with('fails', Lang::get('lang.article_can_not_deleted'));
|
||||
return redirect('article')->with('fails', Lang::get('lang.article_can_not_deleted'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -77,14 +77,7 @@ class CategoryController extends Controller
|
||||
/* add column name */
|
||||
->addColumn('name', function ($model) {
|
||||
$string = strip_tags($model->name);
|
||||
if (strlen($string) > 40) {
|
||||
// truncate string
|
||||
$stringCut = substr($string, 0, 40);
|
||||
} else {
|
||||
$stringCut = $model->name;
|
||||
}
|
||||
|
||||
return $stringCut.'...';
|
||||
return str_limit($string, 20);
|
||||
})
|
||||
/* add column Created */
|
||||
->addColumn('Created', function ($model) {
|
||||
@@ -127,7 +120,7 @@ class CategoryController extends Controller
|
||||
public function create(Category $category)
|
||||
{
|
||||
/* Get the all attributes in the category model */
|
||||
$category = $category->get();
|
||||
$category = $category->lists('name','id')->toArray();
|
||||
/* get the view page to create new category with all attributes
|
||||
of category model */
|
||||
try {
|
||||
@@ -148,13 +141,12 @@ class CategoryController extends Controller
|
||||
public function store(Category $category, CategoryRequest $request)
|
||||
{
|
||||
/* Get the whole request from the form and insert into table via model */
|
||||
$sl = $request->input('slug');
|
||||
$sl = $request->input('name');
|
||||
$slug = str_slug($sl, '-');
|
||||
$category->slug = $slug;
|
||||
// send success message to index page
|
||||
try {
|
||||
$category->fill($request->except('slug'))->save();
|
||||
|
||||
$category->fill($request->input())->save();
|
||||
return Redirect::back()->with('success', Lang::get('lang.category_inserted_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return Redirect::back()->with('fails', Lang::get('lang.category_not_inserted').'<li>'.$e->getMessage().'</li>');
|
||||
@@ -169,15 +161,13 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function edit($slug)
|
||||
public function edit($id)
|
||||
{
|
||||
// fetch the category
|
||||
$cid = Category::where('id', $slug)->first();
|
||||
$id = $cid->id;
|
||||
/* get the atributes of the category model whose id == $id */
|
||||
$category = Category::whereId($id)->first();
|
||||
$categories = Category::lists('name','id')->toArray();
|
||||
/* get the Edit page the selected category via id */
|
||||
return view('themes.default1.agent.kb.category.edit', compact('category'));
|
||||
return view('themes.default1.agent.kb.category.edit', compact('category','categories'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,22 +179,18 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function update($slug, CategoryUpdate $request)
|
||||
public function update($id, CategoryRequest $request)
|
||||
{
|
||||
|
||||
/* Edit the selected category via id */
|
||||
$category = Category::where('id', $slug)->first();
|
||||
$sl = $request->input('slug');
|
||||
$category = Category::where('id', $id)->first();
|
||||
$sl = $request->input('name');
|
||||
$slug = str_slug($sl, '-');
|
||||
// dd($slug);
|
||||
$category->slug = $slug;
|
||||
/* update the values at the table via model according with the request */
|
||||
//redirct to index page with success message
|
||||
try {
|
||||
$category->fill($request->all())->save();
|
||||
$category->slug = $slug;
|
||||
$category->save();
|
||||
|
||||
$category->fill($request->input())->save();
|
||||
return redirect('category')->with('success', Lang::get('lang.category_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
//redirect to index with fails message
|
||||
|
@@ -125,11 +125,11 @@ class PageController extends Controller
|
||||
*/
|
||||
public function store(PageRequest $request)
|
||||
{
|
||||
$sl = $request->input('slug');
|
||||
$sl = $request->input('name');
|
||||
$slug = str_slug($sl, '-');
|
||||
$this->page->slug = $slug;
|
||||
try {
|
||||
$this->page->fill($request->except('slug'))->save();
|
||||
$this->page->fill($request->input())->save();
|
||||
|
||||
return redirect('page')->with('success', Lang::get('lang.page_created_successfully'));
|
||||
} catch (Exception $e) {
|
||||
@@ -163,13 +163,12 @@ class PageController extends Controller
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function update($slug, PageUpdate $request)
|
||||
public function update($slug, PageRequest $request)
|
||||
{
|
||||
// get pages with respect to slug
|
||||
$pages = $this->page->where('slug', $slug)->first();
|
||||
$sl = $request->input('slug');
|
||||
$sl = $request->input('name');
|
||||
$slug = str_slug($sl, '-');
|
||||
$this->page->slug = $slug;
|
||||
try {
|
||||
$pages->fill($request->all())->save();
|
||||
$pages->slug = $slug;
|
||||
|
Reference in New Issue
Block a user