edit static pages in backend
This commit is contained in:
parent
e771c4921f
commit
783ac823ba
59 changed files with 1644 additions and 761 deletions
26
app/Events/Pages/PageUpdated.php
Normal file
26
app/Events/Pages/PageUpdated.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events\Pages;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class PageUpdated.
|
||||
*/
|
||||
class PageUpdated
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
public $page;
|
||||
|
||||
/**
|
||||
* @param $page
|
||||
*/
|
||||
public function __construct($page)
|
||||
{
|
||||
$this->page = $page;
|
||||
}
|
||||
}
|
12
app/Exceptions/GeneralException.php
Normal file
12
app/Exceptions/GeneralException.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class GeneralException.
|
||||
*/
|
||||
class GeneralException extends Exception
|
||||
{
|
||||
}
|
|
@ -1,9 +1,13 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
use App\Exceptions\GeneralException;
|
||||
use App\Models\Page;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
|
@ -40,7 +44,7 @@ class HomeController extends Controller
|
|||
// }
|
||||
|
||||
// }
|
||||
return view('rdr.home.index');
|
||||
return view('frontend.home.index');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,7 +54,7 @@ class HomeController extends Controller
|
|||
*/
|
||||
public function contact(): View
|
||||
{
|
||||
return view('rdr.home.contact');
|
||||
return view('frontend.home.contact');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,7 +64,7 @@ class HomeController extends Controller
|
|||
*/
|
||||
public function imprint(): View
|
||||
{
|
||||
return view('rdr.home.imprint');
|
||||
return view('frontend.home.imprint');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,7 +74,7 @@ class HomeController extends Controller
|
|||
*/
|
||||
public function about(): View
|
||||
{
|
||||
return view('rdr.home.about');
|
||||
return view('frontend.home.about');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,6 +84,21 @@ class HomeController extends Controller
|
|||
*/
|
||||
public function news(): View
|
||||
{
|
||||
return view('rdr.home.news');
|
||||
return view('frontend.home.news');
|
||||
}
|
||||
|
||||
/**
|
||||
* show page by $page_slug.
|
||||
*/
|
||||
public function showPage($slug)
|
||||
{
|
||||
// $result = $pages->findBySlug($slug);
|
||||
if (!is_null(Page::query()->wherePage_slug($slug)->firstOrFail())) {
|
||||
$result = Page::query()->wherePage_slug($slug)->firstOrFail();
|
||||
return view('frontend.pages.index')
|
||||
->withpage($result);
|
||||
} else {
|
||||
throw new GeneralException(trans('exceptions.backend.access.pages.not_found'));
|
||||
}
|
||||
}
|
||||
}
|
15
app/Http/Controllers/PagesController.php → app/Http/Controllers/Frontend/PagesController.php
Executable file → Normal file
15
app/Http/Controllers/PagesController.php → app/Http/Controllers/Frontend/PagesController.php
Executable file → Normal file
|
@ -1,13 +1,8 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers\Frontend;
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Dataset;
|
||||
use App\Book;
|
||||
use App\Category;
|
||||
use App\Shelf;
|
||||
use App\Periode;
|
||||
use App\Student;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
|
@ -19,11 +14,11 @@ class PagesController extends Controller
|
|||
// $this->middleware('auth');
|
||||
}
|
||||
|
||||
public function documents() : View
|
||||
public function datasets() : View
|
||||
{
|
||||
// $books = Book::with('category', 'shelf')->orderByTitle()->get();
|
||||
$documents = Dataset::orderByType()->get();
|
||||
return view('rdr.document.documents', compact('documents'));
|
||||
return view('frontend.dataset.dataset', compact('documents'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,6 +32,6 @@ class PagesController extends Controller
|
|||
$document = Dataset::findOrFail($id);
|
||||
$document->load('titles');
|
||||
$document->load('abstracts');
|
||||
return view('rdr.document.show', compact('document'));
|
||||
return view('frontend.dataset.show', compact('document'));
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Dataset;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class SitelinkController extends Controller
|
||||
{
|
||||
|
@ -13,15 +13,15 @@ class SitelinkController extends Controller
|
|||
//get server state published
|
||||
$serverState = 'published';
|
||||
$select = DB::table('documents')
|
||||
->where('server_state', 'LIKE', "%".$serverState."%");
|
||||
->where('server_state', 'LIKE', "%" . $serverState . "%");
|
||||
|
||||
$select
|
||||
->select(DB::raw('YEAR(published_date) as published_date'))
|
||||
->distinct(true);
|
||||
->select(DB::raw('YEAR(published_date) as published_date'))
|
||||
->distinct(true);
|
||||
|
||||
$this->years = $select->pluck('published_date');
|
||||
$this->ids = array();
|
||||
return view('rdr.sitelink.index')->with(['years'=> $this->years,'documents'=> $this->ids]);
|
||||
return view('frontend.sitelink.index')->with(['years' => $this->years, 'documents' => $this->ids]);
|
||||
}
|
||||
|
||||
public function list($year)
|
||||
|
@ -32,14 +32,13 @@ class SitelinkController extends Controller
|
|||
//$select = DB::table('documents')
|
||||
//->where('server_state','LIKE', "%".$serverState."%");
|
||||
$select = Dataset::with('titles', 'authors')
|
||||
->where('server_state', 'LIKE', "%".$serverState."%");
|
||||
->where('server_state', 'LIKE', "%" . $serverState . "%");
|
||||
|
||||
$from = (int)$year;
|
||||
$until = $year + 1;
|
||||
$until = $year + 1;
|
||||
$select
|
||||
->whereYear('server_date_published', '>=', $from)
|
||||
->whereYear('server_date_published', '<', $until);
|
||||
|
||||
->whereYear('server_date_published', '>=', $from)
|
||||
->whereYear('server_date_published', '<', $until);
|
||||
|
||||
$documents = $select
|
||||
->get();
|
||||
|
@ -51,11 +50,11 @@ class SitelinkController extends Controller
|
|||
// return $item->year !== $year;
|
||||
//});
|
||||
|
||||
|
||||
//$select->select('id');
|
||||
//$this->ids = $select->pluck('id');
|
||||
//return view('rdr.sitelink.index')->with(['years'=> $this->years,'ids'=> $this->ids]);
|
||||
return view('rdr.sitelink.index')->with(['years'=> $this->years,'documents'=> $documents]);
|
||||
return view('frontend.sitelink.index')
|
||||
->with(['years' => $this->years, 'documents' => $documents]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -316,7 +316,7 @@ class RequestController extends Controller
|
|||
*/
|
||||
private function _addLandingPageAttribute(\DOMNode $document, $dataid)
|
||||
{
|
||||
$url = route('document.show', $dataid);
|
||||
$url = route('frontend.dataset.show', $dataid);
|
||||
|
||||
$owner = $document->ownerDocument;
|
||||
$attr = $owner->createAttribute('landingpage');
|
||||
|
|
|
@ -6,17 +6,27 @@ use App\Models\Page;
|
|||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Pages\IndexPageRequest;
|
||||
use App\Http\Requests\Pages\UpdatePageRequest;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use App\Exceptions\GeneralException;
|
||||
use App\Events\Pages\PageUpdated;
|
||||
|
||||
class PageController extends Controller
|
||||
{
|
||||
/**
|
||||
* Associated Repository Model.
|
||||
*/
|
||||
const MODEL = Page::class;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(IndexPageRequest $request)
|
||||
public function index(IndexPageRequest $request): View
|
||||
{
|
||||
return new view('settings.pages.index');
|
||||
return view('settings.page.index');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,19 +69,34 @@ class PageController extends Controller
|
|||
*/
|
||||
public function edit(Page $page)
|
||||
{
|
||||
//
|
||||
return view('settings.page.edit')
|
||||
->withPage($page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param @param \App\Http\Requests\Pages\UpdatePageRequest $request
|
||||
* @param \App\Models\Page $page
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Page $page)
|
||||
public function update(UpdatePageRequest $request, Page $page) : RedirectResponse
|
||||
{
|
||||
//
|
||||
// $this->pages->update($page, $request->except(['_method', '_token']));
|
||||
$input = $request->except(['_method', '_token']);
|
||||
// Making extra fields
|
||||
$input['page_slug'] = str_slug($input['title']);
|
||||
$input['status'] = isset($input['status']) ? 1 : 0;
|
||||
$input['updated_by'] = \Auth::user()->id;
|
||||
|
||||
if ($page->update($input)) {
|
||||
event(new PageUpdated($page));
|
||||
|
||||
return redirect()
|
||||
->route('settings.page.index')
|
||||
->with('flash_message', trans('alerts.backend.pages.updated'));
|
||||
}
|
||||
throw new GeneralException(trans('exceptions.backend.pages.update_error'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,4 +109,9 @@ class PageController extends Controller
|
|||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function query()
|
||||
{
|
||||
return call_user_func(static::MODEL.'::query');
|
||||
}
|
||||
}
|
||||
|
|
46
app/Http/Controllers/Settings/PagesTableController.php
Normal file
46
app/Http/Controllers/Settings/PagesTableController.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Models\Page;
|
||||
use App\Http\Controllers\Controller;
|
||||
// use App\Http\Requests\Backend\Pages\ManagePageRequest;
|
||||
use App\Http\Requests\Pages\IndexPageRequest;
|
||||
// use App\Repositories\Backend\Pages\PagesRepository;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
/**
|
||||
* Class PagesTableController.
|
||||
*/
|
||||
class PagesTableController extends Controller
|
||||
{
|
||||
protected $pages;
|
||||
|
||||
|
||||
public function __construct() //(PagesRepository $pages)
|
||||
{
|
||||
//$this->pages = factory(Page::class, 2)->make();
|
||||
$this->pages = Page::get();
|
||||
}
|
||||
|
||||
|
||||
public function get()
|
||||
{
|
||||
$test = Datatables::of($this->pages)
|
||||
->escapeColumns(['title'])
|
||||
->addColumn('status', function ($page) {
|
||||
return $page->status;
|
||||
})
|
||||
->addColumn('created_at', function ($page) {
|
||||
return $page->created_at->toDateString();
|
||||
})
|
||||
->addColumn('created_by', function ($page) {
|
||||
return $page->created_by;
|
||||
})
|
||||
->addColumn('actions', function ($page) {
|
||||
return $page->action_buttons;
|
||||
})
|
||||
->make(true);
|
||||
return $test;
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class StaticPageController extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function imprint()
|
||||
{
|
||||
////$books = Book::available()->orderByTitle()->lists('title', 'id');
|
||||
//$persons = Person::active()->orderByName()->pluck('last_name', 'id');
|
||||
////$categories = Category::lists('category', 'id');
|
||||
//$categories = Project::get();
|
||||
|
||||
//return view('rdr.borrow.borrow', compact('persons', 'categories'));
|
||||
}
|
||||
}
|
33
app/Http/Requests/Pages/EditPageRequest.php
Normal file
33
app/Http/Requests/Pages/EditPageRequest.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Pages;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
/**
|
||||
* Class EditPageRequest.
|
||||
*/
|
||||
class EditPageRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
true;//return access()->allow('edit-page');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
34
app/Http/Requests/Pages/UpdatePageRequest.php
Normal file
34
app/Http/Requests/Pages/UpdatePageRequest.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Pages;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
/**
|
||||
* Class UpdatePageRequest.
|
||||
*/
|
||||
class UpdatePageRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;//return access()->allow('edit-page');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'title' => 'required|max:191',
|
||||
'description' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
use App\Dataset;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register all of the routes for an application.
|
||||
| It's a breeze. Simply tell Laravel the URIs it should respond to
|
||||
| and give it the controller to call when that URI is requested.
|
||||
|
|
||||
*/
|
||||
// Route::get('/api/dropdown/peminjaman/{id}', [
|
||||
// 'as' => 'api.dropdown.peminjaman', 'uses' => 'PeminjamanController@dropdown'
|
||||
// ]);
|
||||
Route::get('/api/dropdown/borrow/{id}', function ($id) {
|
||||
if (Request::ajax()) {
|
||||
//$category_id = Input::get('category_id');
|
||||
// $books = Book::available()->orderByTitle()->where('category_id', '=', $id)->get();
|
||||
$books = Dataset::OrderByType()->where('project_id', '=', $id)->get();
|
||||
return Response::json($books);
|
||||
}
|
||||
});
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
trait ModelTrait
|
||||
{
|
||||
/**
|
||||
|
@ -9,7 +11,7 @@ trait ModelTrait
|
|||
*/
|
||||
public function getEditButtonAttribute($permission, $route)
|
||||
{
|
||||
if (access()->allow($permission)) {
|
||||
if (Auth::user()->can($permission)) {
|
||||
return '<a href="'.route($route, $this).'" class="btn btn-flat btn-default">
|
||||
<i data-toggle="tooltip" data-placement="top" title="Edit" class="fa fa-pencil"></i>
|
||||
</a>';
|
||||
|
@ -21,7 +23,7 @@ trait ModelTrait
|
|||
*/
|
||||
public function getDeleteButtonAttribute($permission, $route)
|
||||
{
|
||||
if (access()->allow($permission)) {
|
||||
if (Auth::user()->can($permission)) {
|
||||
return '<a href="'.route($route, $this).'"
|
||||
class="btn btn-flat btn-default" data-method="delete"
|
||||
data-trans-button-cancel="'.trans('buttons.general.cancel').'"
|
||||
|
|
|
@ -4,9 +4,11 @@ namespace App\Models;
|
|||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\User;
|
||||
use App\Models\ModelTrait;
|
||||
|
||||
class Page extends Model
|
||||
{
|
||||
use ModelTrait;
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
|
@ -43,6 +45,40 @@ class Page extends Model
|
|||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getActionButtonsAttribute()
|
||||
{
|
||||
return '<div class="btn-group action-btn">
|
||||
'.$this->getEditButtonAttribute('page', 'settings.page.edit').'
|
||||
'.$this->getViewButtonAttribute().'
|
||||
'.$this->getDeleteButtonAttribute('page', 'settings.page.destroy').'
|
||||
</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getViewButtonAttribute()
|
||||
{
|
||||
return '<a target="_blank" href="'. route('frontend.pages.show', $this->page_slug) .'" class="btn btn-flat btn-default">
|
||||
<i data-toggle="tooltip" data-placement="top" title="View Page" class="fa fa-eye"></i>
|
||||
</a>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStatusLabelAttribute()
|
||||
{
|
||||
if ($this->isActive()) {
|
||||
return "<label class='label label-success'>".trans('labels.general.active').'</label>';
|
||||
}
|
||||
|
||||
return "<label class='label label-danger'>".trans('labels.general.inactive').'</label>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue