Commit ffae1c31 authored by Viral Solani's avatar Viral Solani

merge branch develop

parent 41d7098b
<?php
namespace App\Http\Controllers\Backend\Menu;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Menu\CreateMenuRequest;
use App\Http\Requests\Backend\Menu\DeleteMenuRequest;
use App\Http\Requests\Backend\Menu\EditMenuRequest;
use App\Http\Requests\Backend\Menu\ManageMenuRequest;
use App\Http\Requests\Backend\Menu\StoreMenuRequest;
use App\Http\Requests\Backend\Menu\UpdateMenuRequest;
use App\Models\Menu\Menu;
use App\Repositories\Backend\Menu\MenuRepository;
use Illuminate\Support\Facades\DB;
class MenuController extends Controller
{
protected $menu;
/**
* @param \App\Repositories\Backend\Menu\MenuRepository $menu
*/
public function __construct(MenuRepository $menu)
{
$this->menu = $menu;
}
/**
* Display a listing of the resource.
*
* @param \App\Http\Requests\Backend\Menu\ManageMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
public function index(ManageMenuRequest $request)
{
return view('backend.menus.index');
}
/**
* Show the form for creating a new resource.
*
* @param \App\Http\Requests\Backend\Menu\CreateMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
public function create(CreateMenuRequest $request)
{
$types = [
'backend' => 'Backend',
'frontend' => 'Frontend',
];
$modules = DB::table('modules')->get();
return view('backend.menus.create')->withTypes($types)->withModules($modules);
}
/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\Backend\Menu\StoreMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
public function store(StoreMenuRequest $request)
{
$this->menu->create($request->except('_token'));
return redirect()->route('admin.menus.index')->withFlashSuccess(trans('alerts.backend.menus.created'));
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Menu\Menu $menu
* @param \App\Http\Requests\Backend\Menu\EditMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
public function edit(Menu $menu, EditMenuRequest $request)
{
$types = [
'backend' => 'Backend',
'frontend' => 'Frontend',
];
$modules = DB::table('modules')->get();
return view('backend.menus.edit')
->with('types', $types)
->with('menu', $menu)
->with('modules', $modules);
}
/**
* Update the specified resource in storage.
*
* @param \App\Models\Menu\Menu $menu
* @param \App\Http\Requests\Backend\Menu\UpdateMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
public function update(Menu $menu, UpdateMenuRequest $request)
{
$this->menu->update($menu, $request->all());
return redirect()
->route('admin.menus.index')
->with('flash_success', trans('alerts.backend.menus.updated'));
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Menu\Menu $menu
* @param \App\Http\Requests\Backend\Menu\DeleteMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
public function destroy(Menu $menu, DeleteMenuRequest $request)
{
$this->menu->delete($menu);
return redirect()
->route('admin.menus.index')
->with('flash_success', trans('alerts.backend.menus.deleted'));
}
}
<?php
namespace App\Http\Controllers\Backend\Menu;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Menu\CreateMenuRequest;
class MenuFormController extends Controller
{
/**
* Get the form for modal popup.
*
* @param string $formName
* @param \App\Http\Requests\Backend\Menu\CreateMenuRequest
*
* @return \Illuminate\Http\Response
*/
public function create($formName, CreateMenuRequest $request)
{
if (in_array($formName, ['_add_custom_url_form'])) {
return view('backend.menus.'.$formName);
}
return abort(404);
}
}
<?php
namespace App\Http\Controllers\Backend\Menu;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Menu\ManageMenuRequest;
use App\Repositories\Backend\Menu\MenuRepository;
use Carbon\Carbon;
use Yajra\DataTables\Facades\DataTables;
/**
* Class MenuTableController.
*/
class MenuTableController extends Controller
{
protected $menus;
/**
* @param \App\Repositories\Backend\Menu\MenuRepository $menus
*/
public function __construct(MenuRepository $menus)
{
$this->menus = $menus;
}
/**
* @param \App\Http\Requests\Backend\Menu\ManageMenuRequest $request
*
* @return mixed
*/
public function __invoke(ManageMenuRequest $request)
{
return Datatables::of($this->menus->getForDataTable())
->escapeColumns(['name'])
->addColumn('type', function ($menus) {
return ucwords($menus->type);
})
->addColumn('created_at', function ($menus) {
return Carbon::parse($menus->created_at)->toDateTimeString();
})
->addColumn('updated_at', function ($menus) {
return Carbon::parse($menus->updated_at)->toDateTimeString();
})
->addColumn('actions', function ($menus) {
return $menus->action_buttons;
})
->make(true);
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class CreateMenuRequest.
*/
class CreateMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('create-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class DeleteMenuRequest.
*/
class DeleteMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('delete-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class EditMenuRequest.
*/
class EditMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('edit-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class ManageMenuRequest.
*/
class ManageMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('view-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class StoreMenuRequest.
*/
class StoreMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('create-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required',
'type' => 'required',
];
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class UpdateMenuRequest.
*/
class UpdateMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('edit-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required',
'type' => 'required',
];
}
}
<?php
namespace App\Models\Menu;
use App\Models\Menu\Traits\Attribute\MenuAttribute;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Menu extends Model
{
use ModelTrait,
MenuAttribute,
SoftDeletes{
// MenuAttribute::getEditButtonAttribute insteadof ModelTrait;
}
/**
* The database table used by the model.
*
* @var string
*/
protected $table;
protected $fillable = [
'name',
'type',
'items',
];
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->table = config('access.menus_table');
}
}
<?php
namespace App\Models\Menu\Traits\Attribute;
/**
* Class MenuAttribute.
*/
trait MenuAttribute
{
/**
* @return string
*/
public function getActionButtonsAttribute()
{
return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute('edit-menu', 'admin.menus.edit').'
'.$this->getDeleteButtonAttribute('delete-menu', 'admin.menus.destroy').'
</div>';
}
}
<?php
namespace App\Repositories\Backend\Menu;
use App\Exceptions\GeneralException;
use App\Models\Menu\Menu;
use App\Repositories\BaseRepository;
use Illuminate\Database\Eloquent\Model;
/**
* Class MenuRepository.
*/
class MenuRepository extends BaseRepository
{
/**
* Associated Repository Model.
*/
const MODEL = Menu::class;
/**
* @return mixed
*/
public function getForDataTable()
{
return $this->query()
->select([
config('access.menus_table').'.id',
config('access.menus_table').'.name',
config('access.menus_table').'.type',
config('access.menus_table').'.created_at',
config('access.menus_table').'.updated_at',
]);
}
/**
* @param array $input
*
* @throws \App\Exceptions\GeneralException
*
* @return bool
*/
public function create(array $input)
{
if ($this->query()->where('name', $input['name'])->first()) {
throw new GeneralException(trans('exceptions.backend.menus.already_exists'));
}
$input['created_by'] = access()->user()->id;
if (Menu::create($input)) {
return true;
}
throw new GeneralException(trans('exceptions.backend.menus.create_error'));
}
/**
* @param \App\Models\Menu\Menu $menu
* @param $input
*
* @throws \App\Exceptions\GeneralException
*
* return bool
*/
public function update(Menu $menu, array $input)
{
if ($this->query()->where('name', $input['name'])->where('id', '!=', $menu->id)->first()) {
throw new GeneralException(trans('exceptions.backend.menus.already_exists'));
}
$input['updated_by'] = access()->user()->id;
if ($menu->update($input)) {
return true;
}
throw new GeneralException(trans('exceptions.backend.menus.update_error'));
}
/**
* @param \App\Models\Menu\Menu $menu
*
* @throws \App\Exceptions\GeneralException
*
* @return bool
*/
public function delete(Menu $menu)
{
if ($menu->delete()) {
return true;
}
throw new GeneralException(trans('exceptions.backend.menus.delete_error'));
}
}
{{ Form::open(['class' => 'form-horizontal hidden', 'role' => 'form', 'method' => 'post', 'id' => 'menu-add-custom-url']) }}
<div class="form-group">
{{ Form::label('name', trans('labels.backend.menus.field.name'), ['class' => 'col-lg-3 col-md-3 col-sm-3 control-label required']) }}
<div class="col-lg-9 col-md-9 col-sm-9">
{{ Form::text('name', null, ['class' => 'form-control box-size mi-name', 'id' => '', 'placeholder' => trans('labels.backend.menus.field.name'), 'required' => 'required']) }}
</div>
</div>
<div class="form-group">
{{ Form::label('url', trans('labels.backend.menus.field.url'), ['class' => 'col-lg-3 col-md-3 col-sm-3 control-label']) }}
<div class="col-lg-9 col-md-9 col-sm-9">
{{ Form::text('url', null, ['class' => 'form-control box-size mi-url', 'placeholder' => trans('labels.backend.menus.field.url')]) }}
</div>
</div>
<div class="form-group">
{{ Form::label('url', trans('labels.backend.menus.field.url_type'), ['class' => 'col-lg-3 col-md-3 col-sm-3 control-label']) }}
<div class="col-lg-9 col-md-9 col-sm-9 ">
<div class="radio">
<label class="radio-inline">{{ Form::radio('url_type', 'route', null, ['class' => 'mi-url_type_route']) }} {{ trans('labels.backend.menus.field.url_types.route') }}</label>
<label class="radio-inline">{{ Form::radio('url_type', 'static', true, ['class' => 'mi-url_type_static']) }} {{ trans('labels.backend.menus.field.url_types.static') }}</label>
</div>
<div class="checkbox">
{{ Form::hidden('open_in_new_tab', 0) }}
<label>
{{ Form::checkbox('open_in_new_tab', 1, false, ['class' => 'mi-open_in_new_tab']) }} {{ trans('labels.backend.menus.field.open_in_new_tab') }}
</label>
</div>
</div>
</div>
<div class="form-group">
{{ Form::label('icon', trans('labels.backend.menus.field.icon'), ['class' => 'col-lg-3 col-md-3 col-sm-3 control-label', 'title' => trans('labels.backend.menus.field.icon_title')]) }}
<div class="col-lg-9 col-md-9 col-sm-9">
{{ Form::text('icon', null, ['class' => 'form-control box-size mi-icon', 'placeholder' => trans('labels.backend.menus.field.icon_title')]) }}
</div>
</div>
<div class="form-group view-permission-block">
{{ Form::label('view_permission_id', trans('labels.backend.menus.field.view_permission_id'), ['class' => 'col-lg-3 col-md-3 col-sm-3 control-label']) }}
<div class="col-lg-9 col-md-9 col-sm-9">
{{ Form::text('view_permission_id', null, ['class' => 'form-control box-size mi-view_permission_id', 'placeholder' => trans('labels.backend.menus.field.view_permission_id')]) }}
</div>
</div>
{{ Form::hidden('id', null, ['class' => 'mi-id']) }}
<div class="box-body">
<div class="form-group">
<div class="edit-form-btn">
{{ Form::reset(trans('buttons.general.cancel'), ['class' => 'btn btn-default btn-md', 'data-dismiss' => 'modal']) }}
{{ Form::submit(trans('buttons.general.save'), ['class' => 'btn btn-primary btn-md']) }}
<div class="clearfix"></div>
</div>
</div>
</div>
{{ Form::close() }}
@extends ('backend.layouts.app')
@section ('title', trans('labels.backend.menus.management') . ' | ' . trans('labels.backend.menus.create'))
@section('page-header')
<h1>
{{ trans('labels.backend.menus.management') }}
<small>{{ trans('labels.backend.menus.create') }}</small>
</h1>
@endsection
@section('content')
{{ Form::open(['route' => 'admin.menus.store', 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'post', 'id' => 'create-menu', 'files' => false]) }}
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('labels.backend.menus.create') }}</h3>
<div class="box-tools pull-right">
@include('backend.menus.partials.header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
{{-- Including Form blade file --}}
<div class="box-body">
<div class="form-group">
@include("backend.menus.form")
<div class="edit-form-btn">
{{ link_to_route('admin.menus.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }}
{{ Form::submit(trans('buttons.general.crud.create'), ['class' => 'btn btn-primary btn-md']) }}
<div class="clearfix"></div>
</div>
</div>
</div><!--box-->
</div>
{{ Form::close() }}
@include("backend.menus.partials.modal")
@endsection
@extends ('backend.layouts.app')
@section ('title', trans('labels.backend.menus.management') . ' | ' . trans('labels.backend.menus.edit'))
@section('page-header')
<h1>
{{ trans('labels.backend.menus.management') }}
<small>{{ trans('labels.backend.menus.edit') }}</small>
</h1>
@endsection
@section('content')
{{ Form::model($menu, ['route' => ['admin.menus.update', $menu], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH', 'id' => 'edit-role', 'files' => true]) }}
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('labels.backend.menus.edit') }}</h3>
<div class="box-tools pull-right">
@include('backend.menus.partials.header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
{{-- Including Form blade file --}}
<div class="box-body">
<div class="form-group">
@include("backend.menus.form")
<div class="edit-form-btn">
{{ link_to_route('admin.menus.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }}
{{ Form::submit(trans('buttons.general.crud.update'), ['class' => 'btn btn-primary btn-md']) }}
<div class="clearfix"></div>
</div>
</div>
</div><!--box-->
</div>
{{ Form::close() }}
@include("backend.menus.partials.modal")
@endsection
\ No newline at end of file
This diff is collapsed.
@extends ('backend.layouts.app')
@section ('title', trans('labels.backend.menus.management'))
@section('after-styles')
{{ Html::style("css/backend/plugin/datatables/dataTables.bootstrap.min.css") }}
@endsection
@section('page-header')
<h1>{{ trans('labels.backend.menus.management') }}</h1>
@endsection
@section('content')
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('labels.backend.menus.management') }}</h3>
<div class="box-tools pull-right">
@include('backend.menus.partials.header-buttons')
</div>
</div><!-- /.box-header -->
<div class="box-body">
<div class="table-responsive data-table-wrapper">
<table id="menus-table" class="table table-condensed table-hover table-bordered">
<thead>
<tr>
<th>{{ trans('labels.backend.menus.table.name') }}</th>
<th>{{ trans('labels.backend.menus.table.type') }}</th>
<th>{{ trans('labels.backend.menus.table.createdat') }}</th>
<th>{{ trans('labels.general.actions') }}</th>
</tr>
</thead>
<thead class="transparent-bg">
<tr>
<th>
{!! Form::text('first_name', null, ["class" => "search-input-text form-control", "data-column" => 0, "placeholder" => trans('labels.backend.menus.table.name')]) !!}
<a class="reset-data" href="javascript:void(0)"><i class="fa fa-times"></i></a>
</th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
</table>
</div><!--table-responsive-->
</div><!-- /.box-body -->
</div><!--box-->
<!--<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('history.backend.recent_history') }}</h3>
<div class="box-tools pull-right">
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div><!-- /.box tools -->
</div><!-- /.box-header -->
<div class="box-body">
{{-- {!! history()->renderType('Blog') !!} --}}
</div><!-- /.box-body -->
</div><!--box box-success-->
@endsection
@section('after-scripts')
{{-- For DataTables --}}
@include('includes.datatables')
<script>
$(function() {
var dataTable = $('#menus-table').dataTable({
processing: true,
serverSide: true,
ajax: {
url: '{{ route("admin.menus.get") }}',
type: 'post'
},
columns: [
{data: 'name', name: '{{config('access.menus_table')}}.name'},
{data: 'type', name: '{{config('access.menus_table')}}.type'},
{data: 'created_at', name: '{{config('access.menus_table')}}.created_at'},
{data: 'actions', name: 'actions', searchable: false, sortable: false}
],
order: [[3, "asc"]],
searchDelay: 500,
dom: 'lBfrtip',
buttons: {
buttons: [
{ extend: 'copy', className: 'copyButton', exportOptions: {columns: [ 0, 1, 2, 3, 4 ] }},
{ extend: 'csv', className: 'csvButton', exportOptions: {columns: [ 0, 1, 2, 3, 4 ] }},
{ extend: 'excel', className: 'excelButton', exportOptions: {columns: [ 0, 1, 2, 3, 4 ] }},
{ extend: 'pdf', className: 'pdfButton', exportOptions: {columns: [ 0, 1, 2, 3, 4 ] }},
{ extend: 'print', className: 'printButton', exportOptions: {columns: [ 0, 1, 2, 3, 4 ] }}
]
}
});
Backend.DataTableSearch.init(dataTable);
});
</script>
@endsection
<!--Action Button-->
@if(Active::checkUriPattern('admin/menus'))
<div class="btn-group">
<button type="button" class="btn btn-warning btn-flat dropdown-toggle" data-toggle="dropdown">Export
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li id="copyButton"><a href="#"><i class="fa fa-clone"></i> Copy</a></li>
<li id="csvButton"><a href="#"><i class="fa fa-file-text-o"></i> CSV</a></li>
<li id="excelButton"><a href="#"><i class="fa fa-file-excel-o"></i> Excel</a></li>
<li id="pdfButton"><a href="#"><i class="fa fa-file-pdf-o"></i> PDF</a></li>
<li id="printButton"><a href="#"><i class="fa fa-print"></i> Print</a></li>
</ul>
</div>
@endif
<!--Action Button-->
<div class="btn-group">
<button type="button" class="btn btn-primary btn-flat dropdown-toggle" data-toggle="dropdown">Action
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="{{route('admin.menus.index')}}"><i class="fa fa-list-ul"></i> {{trans('menus.backend.menus.all')}}</a></li>
@permission('create-menu')
<li><a href="{{route('admin.menus.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.menus.create')}}</a></li>
@endauth
</ul>
</div>
<div class="clearfix"></div>
\ No newline at end of file
<div id="showMenuModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
<p>Something went wrong! Please try again later.</p>
</div>
</div>
</div>
</div>
\ No newline at end of file
screenshots/dashboard.png

52.1 KB | W: | H:

screenshots/dashboard.png

37.6 KB | W: | H:

screenshots/dashboard.png
screenshots/dashboard.png
screenshots/dashboard.png
screenshots/dashboard.png
  • 2-up
  • Swipe
  • Onion skin
screenshots/settings.png

80.4 KB | W: | H:

screenshots/settings.png

58.9 KB | W: | H:

screenshots/settings.png
screenshots/settings.png
screenshots/settings.png
screenshots/settings.png
  • 2-up
  • Swipe
  • Onion skin
screenshots/users.png

98.5 KB | W: | H:

screenshots/users.png

77 KB | W: | H:

screenshots/users.png
screenshots/users.png
screenshots/users.png
screenshots/users.png
  • 2-up
  • Swipe
  • Onion skin
<?php
namespace Tests\Feature;
use Tests\BrowserKitTestCase;
class AuthTest extends BrowserKitTestCase
{
/** @test */
public function login_page_loads_properly()
{
$this->visit('/login')
->see('Email')
->see('Password')
->see('Login')
->dontSee('You are logged in!');
}
/** @test */
public function login_failure_without_inputs()
{
$this->visit('/login')
->press('Login')
->seePageIs('/login')
->see('The email field is required.')
->see('The password field is required.');
}
/** @test */
/*public function test_login_failure_with_wrong_inputs()
{
$this->visit("/login")
->type('wrongusername@wrongpassword.com', 'email')
->type('wrongpassword', 'password')
->press('Login')
->seePageIs('/login')
->see('These credentials do not match our records.');
}*/
/** @test */
public function users_can_login()
{
//$this->createUser();
$this->visit('/login')
->type('user@user.com', 'email')
->type('1234', 'password')
//->press('Login')
->seePageIs('/login');
}
}
......@@ -15,6 +15,6 @@ class ExampleTest extends TestCase
{
$response = $this->get('/');
$response->assertStatus(200);
$response->assertSee('Laravel AdminPanel');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment