Commit 66aec1e9 authored by Vipul Basapati's avatar Vipul Basapati

removed generator resources/vendor files

parent 01853adf
<?php
namespace AttributeNamespace;
/**
* Class AttributeClass.
*/
trait AttributeClass
{
// Make your attributes functions here
// Further, see the documentation : https://laravel.com/docs/5.4/eloquent-mutators#defining-an-accessor
/**
* Action Button Attribute to show in grid
* @return string
*/
public function getActionButtonsAttribute()
{
return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute("editPermission", "editRoute").'
'.$this->getDeleteButtonAttribute("deletePermission", "deleteRoute").'
</div>';
}
}
<?php
Breadcrumbs::register('admin.dummy_small_plural_model.index', function ($breadcrumbs) {
$breadcrumbs->parent('admin.dashboard');
$breadcrumbs->push(trans('menus.backend.dummy_small_plural_model.management'), route('admin.dummy_small_plural_model.index'));
});
Breadcrumbs::register('admin.dummy_small_plural_model.create', function ($breadcrumbs) {
$breadcrumbs->parent('admin.dummy_small_plural_model.index');
$breadcrumbs->push(trans('menus.backend.dummy_small_plural_model.create'), route('admin.dummy_small_plural_model.create'));
});
Breadcrumbs::register('admin.dummy_small_plural_model.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.dummy_small_plural_model.index');
$breadcrumbs->push(trans('menus.backend.dummy_small_plural_model.edit'), route('admin.dummy_small_plural_model.edit', $id));
});
<?php
namespace DummyNamespace;
use DummyModelNamespace;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DummyRepositoryNamespace;
use DummyManageRequestNamespace;
@Namespaces
/**
* DummyController
*/
class DummyController extends Controller
{
/**
* variable to store the repository object
* @var dummy_repository
*/
protected $repository;
/**
* contructor to initialize repository object
* @param dummy_repository $repository;
*/
public function __construct(dummy_repository $repository)
{
$this->repository = $repository;
}
/**
* Display a listing of the resource.
*
* @param DummyManageRequestNamespace $request
* @return \Illuminate\Http\Response
*/
public function index(DummyManageRequest $request)
{
return view('backend.dummy_small_plural_model.index');
}
@startCreate/**
* Show the form for creating a new resource.
*
* @param DummyCreateRequestNamespace $request
* @return \Illuminate\Http\Response
*/
public function create(DummyCreateRequest $request)
{
return view('backend.dummy_small_plural_model.create');
}
/**
* Store a newly created resource in storage.
*
* @param DummyStoreRequestNamespace $request
* @return \Illuminate\Http\Response
*/
public function store(DummyStoreRequest $request)
{
//Input received from the request
$input = $request->except(['_token']);
//Create the model using repository create method
$this->repository->create($input);
//return with successfull message
return redirect()->route('admin.dummy_small_plural_model.index')->withFlashSuccess(trans('alerts.backend.dummy_small_plural_model.created'));
}
@endCreate@startEdit/**
* Show the form for editing the specified resource.
*
* @param DummyModelNamespace $DummyArgumentName
* @param DummyEditRequestNamespace $request
* @return \Illuminate\Http\Response
*/
public function edit(DummyModel $DummyArgumentName, DummyEditRequest $request)
{
return view('backend.dummy_small_plural_model.edit', compact('DummyArgumentName'));
}
/**
* Update the specified resource in storage.
*
* @param DummyUpdateRequestNamespace $request
* @param DummyModelNamespace $DummyArgumentName
* @return \Illuminate\Http\Response
*/
public function update(DummyUpdateRequest $request, DummyModel $DummyArgumentName)
{
//Input received from the request
$input = $request->except(['_token']);
//Update the model using repository update method
$this->repository->update( $DummyArgumentName, $input );
//return with successfull message
return redirect()->route('admin.dummy_small_plural_model.index')->withFlashSuccess(trans('alerts.backend.dummy_small_plural_model.updated'));
}
@endEdit@startDelete/**
* Remove the specified resource from storage.
*
* @param DummyDeleteRequestNamespace $request
* @param DummyModelNamespace $DummyArgumentName
* @return \Illuminate\Http\Response
*/
public function destroy(DummyModel $DummyArgumentName, DummyDeleteRequest $request)
{
//Calling the delete method on repository
$this->repository->delete($DummyArgumentName);
//returning with successfull message
return redirect()->route('admin.dummy_small_plural_model.index')->withFlashSuccess(trans('alerts.backend.dummy_small_plural_model.deleted'));
}
@endDelete
}
<?php
namespace DummyNamespace;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use DummyAttribute;
use DummyRelationship;
class DummyModel extends Model
{
use ModelTrait,
AttributeName,
RelationshipName {
// AttributeName::getEditButtonAttribute insteadof ModelTrait;
}
/**
* NOTE : If you want to implement Soft Deletes in this model,
* then follow the steps here : https://laravel.com/docs/5.4/eloquent#soft-deleting
*/
/**
* The database table used by the model.
* @var string
*/
protected $table = 'table_name';
/**
* Mass Assignable fields of model
* @var array
*/
protected $fillable = [
];
/**
* Default values for model fields
* @var array
*/
protected $attributes = [
];
/**
* Dates
* @var array
*/
protected $dates = [
'created_at',
'updated_at'
];
/**
* Guarded fields of model
* @var array
*/
protected $guarded = [
'id'
];
/**
* Constructor of Model
* @param array $attributes
*/
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
}
}
<?php
namespace RelationshipNamespace;
/**
* Class RelationshipClass
*/
trait RelationshipClass
{
/*
* put you model relationships here
* Take below example for reference
*/
/*
public function users() {
//Note that the below will only work if user is represented as user_id in your table
//otherwise you have to provide the column name as a parameter
//see the documentation here : https://laravel.com/docs/5.4/eloquent-relationships
$this->belongsTo(User::class);
}
*/
}
<?php
namespace DummyNamespace;
use DB;
use Carbon\Carbon;
use DummyModelNamespace;
use App\Exceptions\GeneralException;
use App\Repositories\BaseRepository;
use Illuminate\Database\Eloquent\Model;
/**
* Class DummyRepoName.
*/
class DummyRepoName extends BaseRepository
{
/**
* Associated Repository Model.
*/
const MODEL = dummy_model_name::class;
/**
* This method is used by Table Controller
* For getting the table data to show in
* the grid
* @return mixed
*/
public function getForDataTable()
{
return $this->query()
->select([
config('module.model_small_plural.table').'.id',
config('module.model_small_plural.table').'.created_at',
config('module.model_small_plural.table').'.updated_at',
]);
}
@startCreate
/**
* For Creating the respective model in storage
*
* @param array $input
* @throws GeneralException
* @return bool
*/
public function create(array $input)
{
$dummy_small_model_name = self::MODEL;
$dummy_small_model_name = new $dummy_small_model_name();
if ($dummy_small_model_name->save($input)) {
return true;
}
throw new GeneralException(trans('exceptions.backend.dummy_small_plural_model_name.create_error'));
}
@endCreate@startEdit
/**
* For updating the respective Model in storage
*
* @param dummy_model_name $dummy_small_model_name
* @param $input
* @throws GeneralException
* return bool
*/
public function update(dummy_model_name $dummy_small_model_name, array $input)
{
if ($dummy_small_model_name->update($input))
return true;
throw new GeneralException(trans('exceptions.backend.dummy_small_plural_model_name.update_error'));
}
@endEdit@startDelete
/**
* For deleting the respective model from storage
*
* @param dummy_model_name $dummy_small_model_name
* @throws GeneralException
* @return bool
*/
public function delete(dummy_model_name $dummy_small_model_name)
{
if ($dummy_small_model_name->delete()) {
return true;
}
throw new GeneralException(trans('exceptions.backend.dummy_small_plural_model_name.delete_error'));
}@endDelete
}
<?php
namespace DummyNamespace;
use Illuminate\Foundation\Http\FormRequest;
class DummyClass extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('permission');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//Put your rules for the request in here
//For Example : 'title' => 'required'
//Further, see the documentation : https://laravel.com/docs/5.4/validation#creating-form-requests
];
}
public function messages()
{
return [
//The Custom messages would go in here
//For Example : 'title.required' => 'You need to fill in the title field.'
//Further, see the documentation : https://laravel.com/docs/5.4/validation#customizing-the-error-messages
];
}
}
<?php
namespace DummyNamespace;
use Carbon\Carbon;
use App\Http\Controllers\Controller;
use Yajra\DataTables\Facades\DataTables;
use DummyRepositoryNamespace;
use DummyManageRequestNamespace;
/**
* Class DummyTableController.
*/
class DummyTableController extends Controller
{
/**
* variable to store the repository object
* @var dummy_repository
*/
protected $dummy_small_repo_name;
/**
* contructor to initialize repository object
* @param dummy_repository $dummy_small_repo_name;
*/
public function __construct(dummy_repository $dummy_small_repo_name)
{
$this->dummy_small_repo_name = $dummy_small_repo_name;
}
/**
* This method return the data of the model
* @param dummy_manage_request_name $request
*
* @return mixed
*/
public function __invoke(dummy_manage_request_name $request)
{
return Datatables::of($this->dummy_small_repo_name->getForDataTable())
->escapeColumns(['id'])
->addColumn('created_at', function ($dummy_small_repo_name) {
return Carbon::parse($dummy_small_repo_name->created_at)->toDateString();
})
->addColumn('actions', function ($dummy_small_repo_name) {
return $dummy_small_repo_name->action_buttons;
})
->make(true);
}
}
@extends ('backend.layouts.app')
@section ('title', trans('labels.backend.dummy_small_plural_model.management') . ' | ' . trans('labels.backend.dummy_small_plural_model.create'))
@section('page-header')
<h1>
{{ trans('labels.backend.dummy_small_plural_model.management') }}
<small>{{ trans('labels.backend.dummy_small_plural_model.create') }}</small>
</h1>
@endsection
@section('content')
{{ Form::open(['route' => 'admin.dummy_small_plural_model.store', 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'post', 'id' => 'create-dummy_small_model']) }}
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('labels.backend.dummy_small_plural_model.create') }}</h3>
<div class="box-tools pull-right">
@include('backend.dummy_small_plural_model.partials.dummy_small_plural_model-header-buttons')
</div><!--box-tools pull-right-->
</div><!--box-header with-border-->
<div class="box-body">
<div class="form-group">
{{-- Including Form blade file --}}
@include("backend.dummy_small_plural_model.form")
<div class="edit-form-btn">
{{ link_to_route('admin.dummy_small_plural_model.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><!--edit-form-btn-->
</div><!-- form-group -->
</div><!--box-body-->
</div><!--box box-success-->
{{ Form::close() }}
@endsection
@extends ('backend.layouts.app')
@section ('title', trans('labels.backend.dummy_small_plural_model.management') . ' | ' . trans('labels.backend.dummy_small_plural_model.edit'))
@section('page-header')
<h1>
{{ trans('labels.backend.dummy_small_plural_model.management') }}
<small>{{ trans('labels.backend.dummy_small_plural_model.edit') }}</small>
</h1>
@endsection
@section('content')
{{ Form::model($dummy_small_model, ['route' => ['admin.dummy_small_plural_model.update', $dummy_small_model], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH', 'id' => 'edit-dummy_small_model']) }}
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('labels.backend.dummy_small_plural_model.edit') }}</h3>
<div class="box-tools pull-right">
@include('backend.dummy_small_plural_model.partials.dummy_small_plural_model-header-buttons')
</div><!--box-tools pull-right-->
</div><!--box-header with-border-->
<div class="box-body">
<div class="form-group">
{{-- Including Form blade file --}}
@include("backend.dummy_small_plural_model.form")
<div class="edit-form-btn">
{{ link_to_route('admin.dummy_small_plural_model.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><!--edit-form-btn-->
</div><!--form-group-->
</div><!--box-body-->
</div><!--box box-success -->
{{ Form::close() }}
@endsection
<div class="box-body">
<div class="form-group">
<!-- Create Your Field Label Here -->
<!-- Look Below Example for reference -->
{{-- {{ Form::label('name', trans('labels.backend.blogs.title'), ['class' => 'col-lg-2 control-label required']) }} --}}
<div class="col-lg-10">
<!-- Create Your Input Field Here -->
<!-- Look Below Example for reference -->
{{-- {{ Form::text('name', null, ['class' => 'form-control box-size', 'placeholder' => trans('labels.backend.blogs.title'), 'required' => 'required']) }} --}}
</div><!--col-lg-10-->
</div><!--form-group-->
</div><!--box-body-->
@section("after-scripts")
<script type="text/javascript">
//Put your javascript needs in here.
//Don't forget to put `@`parent exactly after `@`section("after-scripts"),
//if your create or edit blade contains javascript of its own
$( document ).ready( function() {
//Everything in here would execute after the DOM is ready to manipulated.
});
</script>
@endsection
<!--Action Button-->
@if( Active::checkUriPattern( 'admin/dummy_small_plural_model' ) )
<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.dummy_small_plural_model.index' ) }}">
<i class="fa fa-list-ul"></i> {{ trans( 'menus.backend.dummy_small_plural_model.all' ) }}
</a>
</li>
@create@permission( 'create-dummy_small_model' )
<li>
<a href="{{ route( 'admin.dummy_small_plural_model.create' ) }}">
<i class="fa fa-plus"></i> {{ trans( 'menus.backend.dummy_small_plural_model.create' ) }}
</a>
</li>
@endauth@endCreate
</ul>
</div>
<div class="clearfix"></div>
@extends ('backend.layouts.app')
@section ('title', trans('labels.backend.dummy_small_plural_model.management'))
@section('page-header')
<h1>{{ trans('labels.backend.dummy_small_plural_model.management') }}</h1>
@endsection
@section('content')
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('labels.backend.dummy_small_plural_model.management') }}</h3>
<div class="box-tools pull-right">
@include('backend.dummy_small_plural_model.partials.dummy_small_plural_model-header-buttons')
</div>
</div><!--box-header with-border-->
<div class="box-body">
<div class="table-responsive data-table-wrapper">
<table id="dummy_small_plural_model-table" class="table table-condensed table-hover table-bordered">
<thead>
<tr>
<th>{{ trans('labels.backend.dummy_small_plural_model.table.id') }}</th>
<th>{{ trans('labels.backend.dummy_small_plural_model.table.createdat') }}</th>
<th>{{ trans('labels.general.actions') }}</th>
</tr>
</thead>
<thead class="transparent-bg">
<tr>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
</table>
</div><!--table-responsive-->
</div><!-- /.box-body -->
</div><!--box-->
@endsection
@section('after-scripts')
{{-- For DataTables --}}
{{ Html::script(mix('js/dataTable.js')) }}
<script>
//Below written line is short form of writing $(document).ready(function() { })
$(function() {
var dataTable = $('#dummy_small_plural_model-table').dataTable({
processing: true,
serverSide: true,
ajax: {
url: '{{ route("admin.dummy_small_plural_model.get") }}',
type: 'post'
},
columns: [
{data: 'id', name: '{{config('module.dummy_small_plural_model.table')}}.id'},
{data: 'created_at', name: '{{config('module.dummy_small_plural_model.table')}}.created_at'},
{data: 'actions', name: 'actions', searchable: false, sortable: false}
],
order: [[0, "asc"]],
searchDelay: 500,
dom: 'lBfrtip',
buttons: {
buttons: [
{ extend: 'copy', className: 'copyButton', exportOptions: {columns: [ 0, 1 ] }},
{ extend: 'csv', className: 'csvButton', exportOptions: {columns: [ 0, 1 ] }},
{ extend: 'excel', className: 'excelButton', exportOptions: {columns: [ 0, 1 ] }},
{ extend: 'pdf', className: 'pdfButton', exportOptions: {columns: [ 0, 1 ] }},
{ extend: 'print', className: 'printButton', exportOptions: {columns: [ 0, 1 ] }}
]
}
});
FinBuilders.DataTableSearch.init(dataTable);
});
</script>
@endsection
<?php
/**
* DummyModuleName
*
*/
Route::group(['namespace' => 'route_namespace', 'prefix' => 'admin', 'as' => 'admin.', 'middleware' => 'admin'], function () {
@startNamespace
Route::group( ['namespace' => 'DummyModel'], function () {
Route::resource('dummy_name', 'DummyController');
//For Datatable
Route::post('dummy_name/get', 'DummyTableController')->name('dummy_name.get');
});
@endNamespace@startWithoutNamespace
Route::resource('dummy_name', 'DummyController');
//For Datatable
Route::post('dummy_name/get', 'DummyTableController')->name('dummy_name.get');
@endWithoutNamespace
});
\ No newline at end of file
<?php
/**
* Routes for : DummyModuleName
*/
Route::group(['namespace' => 'route_namespace', 'prefix' => 'admin', 'as' => 'admin.', 'middleware' => 'admin'], function () {
@startNamespace
Route::group( ['namespace' => 'DummyModel'], function () {
Route::get('dummy_name', 'DummyController@index')->name('dummy_name.index');
@startCreateRoute::get('dummy_name/create', 'DummyController@create')->name('dummy_name.create');
Route::post('dummy_name', 'DummyController@store')->name('dummy_name.store');@endCreate
@startEditRoute::get('dummy_name/{dummy_argument_name}/edit', 'DummyController@edit')->name('dummy_name.edit');
Route::patch('dummy_name/{dummy_argument_name}', 'DummyController@update')->name('dummy_name.update');@endEdit
@startDeleteRoute::delete('dummy_name/{dummy_argument_name}', 'DummyController@destroy')->name('dummy_name.destroy');@endDelete
//For Datatable
Route::post('dummy_name/get', 'DummyTableController')->name('dummy_name.get');
});
@endNamespace@startWithoutNamespace
Route::get('dummy_name', 'DummyController@index')->name('dummy_name.index');
@startCreateRoute::get('dummy_name/create', 'DummyController@create')->name('dummy_name.create');
Route::post('dummy_name', 'DummyController@store')->name('dummy_name.store');@endCreate
@startEditRoute::get('dummy_name/{dummy_argument_name}/edit', 'DummyController@edit')->name('dummy_name.edit');
Route::patch('dummy_name/{dummy_argument_name}', 'DummyController@update')->name('dummy_name.update');@endEdit
@startDeleteRoute::delete('dummy_name/{dummy_argument_name}', 'DummyController@destroy')->name('dummy_name.destroy');@endDelete
//For Datatable
Route::post('dummy_name/get', 'DummyTableController')->name('dummy_name.get');
@endWithoutNamespace
});
\ No newline at end of file
@extends ('backend.layouts.app')
@section ('title', trans('generator::labels.modules.management') . ' | ' . trans('generator::labels.modules.create'))
@section('page-header')
<h1>
{{ trans('generator::labels.modules.management') }}
<small>{{ trans('generator::labels.modules.create') }}</small>
</h1>
@endsection
@section('content')
{{ Form::open(['route' => 'admin.modules.store', 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'post', 'id' => 'create-module', 'files' => true]) }}
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('generator::labels.modules.create') }}</h3>
<div class="box-tools pull-right">
@include('generator::partials.modules-header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
{{-- Including Form blade file --}}
<div class="box-body">
<div class="form-group">
@include("generator::form")
<div class="edit-form-btn">
{{ link_to_route('admin.modules.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() }}
@endsection
@extends ('backend.layouts.app')
@section ('title', trans('generator::labels.modules.management') . ' | ' . trans('generator::labels.modules.edit'))
@section('page-header')
<h1>
{{ trans('generator::labels.modules.management') }}
<small>{{ trans('generator::labels.modules.edit') }}</small>
</h1>
@endsection
@section('content')
{{ Form::model($module, ['route' => ['admin.modules.update', $module], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH', 'id' => 'edit-module', 'files' => true]) }}
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('generator::labels.modules.edit') }}</h3>
<div class="box-tools pull-right">
@include('generator::partials.modules-header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
{{-- Including Form blade file --}}
<div class="box-body">
<div class="form-group">
@include("backend.modules.form")
<div class="edit-form-btn">
{{ link_to_route('admin.modules.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() }}
@endsection
\ No newline at end of file
<div class="box-body">
<div class="form-group">
<div class="col-lg-10 col-lg-offset-1">
<div class="alert alert-warning">
Note : You need to have 0777 permission to all folders of the project.
</div>
</div>
</div>
<!-- Module Name -->
<div class="form-group">
{{ Form::label('name', trans('generator::labels.modules.form.name'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog', 'required' => 'required']) }}
</div><!--col-lg-10-->
</div>
<!-- Directory -->
<div class="form-group">
{{ Form::label('directory_name', trans('generator::labels.modules.form.directory_name'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('directory_name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog', 'required' => true]) }}
</div><!--col-lg-10-->
</div>
<!-- End Directory -->
<!-- Model Name -->
<div class="form-group">
{{ Form::label('model_name', trans('generator::labels.modules.form.model_name'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('model_name', null, ['class' => 'form-control box-size only-text', 'placeholder' => 'e.g., Blog', 'required' => true]) }}
<div class="model-messages"></div>
</div>
</div>
<!-- End Model Name -->
<!-- Table Name -->
<div class="form-group">
{{ Form::label('table_name', trans('generator::labels.modules.form.table_name'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10">
{{ Form::text('table_name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog']) }}
<div class="table-messages"></div>
</div><!--col-lg-10-->
</div>
<!-- End Table Name -->
<!-- Crud Operations Create/Edit/Delete to be added to the field (Read operation is given by default)-->
<div class="form-group">
{{ Form::label('operations', 'CRUD Operations', ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-8">
<label class="control control--checkbox">
<!-- For Create Operation of CRUD -->
{{ Form::checkbox('model_create', '1', false) }}Create
<div class="control__indicator"></div>
</label>
<label class="control control--checkbox">
<!-- For Edit Operation of CRUD -->
{{ Form::checkbox('model_edit', '1', false) }}Edit
<div class="control__indicator"></div>
</label>
<label class="control control--checkbox">
<!-- For Delete Operation of CRUD -->
{{ Form::checkbox('model_delete', '1', false) }}Delete
<div class="control__indicator"></div>
</label>
</div>
</div>
<!-- End Crud Operations -->
<div class="box-header text-center">
<hr width=60%/>
<h3 class="box-title"> Optional </h3>
<hr width=60%/>
</div><!-- /.box-header -->
<!-- Events -->
<div class="events-div">
<div class="form-group event clearfix">
{{ Form::label('event[]', trans('generator::labels.modules.form.event'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-6">
{{ Form::text('event[]', null, ['class' => 'form-control box-size', 'placeholder' => trans('generator::labels.modules.form.event'), 'style' => 'width:100%']) }}
</div><!--col-lg-10-->
<a href="#" class="btn btn-danger btn-md remove-field hidden">Remove Event</a>
<a href="#" class="btn btn-primary btn-md add-field">Add Event</a>
</div><!--form control-->
</div>
<div class="el-messages">
</div>
<!-- End Events -->
<!-- To Show the generated File -->
<div class="box-body">
<!--All Files -->
<div class="form-group">
<label class="col-lg-2 control-label">Files To Be Generated</label>
<div class="col-lg-10">
<textarea class="form-control box-size files" contenteditable="true" rows=15 readonly="">
</textarea>
</div>
</div>
<!-- All Files -->
</div>
<!-- End The File Generated Textbox -->
<!-- Override CheckBox -->
<div class="form-group">
<div class="col-lg-2"></div>
<div class="col-lg-10">
<p><strong>Note : </strong> The Files would be overwritten, if already exists. Please look at files (and their respective paths) carefully before creating.</p>
</div><!--form control-->
</div>
<!-- end Override Checkbox -->
</div>
@section("after-scripts")
{!! Html::script('js/backend/pluralize.js') !!}
<script type="text/javascript">
//When the DOM is ready to be manipulated
$(document).ready(function(){
model_ns = {!! json_encode($model_namespace) !!};
controller_ns = {!! json_encode($controller_namespace) !!};
event_ns = {!! json_encode($event_namespace) !!};
request_ns = {!! json_encode($request_namespace) !!};
repo_ns = {!! json_encode($repo_namespace) !!};
route_path = {!! json_encode($route_path) !!};
view_path = {!! json_encode($view_path) !!};
//If any errors occured
handleAllCheckboxes();
//events and listeners checkbox change event
$("input[name=el]").on('change', function(e){
handleCheckBox($(this), $(".el"));
});
//Add field in event panel
$(document).on('click', ".add-field", function(e){
e.preventDefault();
clone = $(".event").first().clone();
clone.find(".remove-field").removeClass('hidden');
clone.appendTo(".events-div");
});
//remove field in event panel
$(document).on('click', ".remove-field", function(e){
e.preventDefault();
$(this).parent('div').remove();
});
//model name on blur event
$(document).on('blur', "input[name=model_name]", function(e){
getFilesGenerated();
table = pluralize($(this).val());
$("input[name=table_name]").val(table.toLowerCase());
});
//Directory name blur event
$(document).on('blur', "input[name=directory_name]", function(e){
getFilesGenerated();
});
//Model Create Checkbox change event
$(document).on('change', "input[name=model_create]", function(e){
getFilesGenerated();
});
//Model Edit Checkbox change event
$(document).on('change', "input[name=model_edit]", function(e){
getFilesGenerated();
});
//Model Delete Checkbox change event
$(document).on('change', "input[name=model_delete]", function(e){
getFilesGenerated();
});
//table name on blur event
$(document).on('blur', "input[name=table_name]", function(e){
checkTableExists($(this));
});
//Events Change Event
$(document).on('change', "input[name='event[]']", function(e){
getFilesGenerated();
});
});
function checkModelExists(model) {
if(model.val()) {
path = getPath( model_ns, $("input[name=model_namespace]").val(), model.val());
checkPath(path, 'model');
} else {
throwMessages('error', 'Please provide some input.', "model");
}
}
function checkTableExists(table) {
if(table.val()){
$.post( "{{ route('admin.modules.check.table') }}", { 'table' : table.val()} )
.done( function( data ) {
throwMessages(data.type, data.message, "table");
});
} else {
throwMessages('error', "Please provide some input.", "table");
}
}
function checkEventExists(event) {
if(event.val() && $("input[name=event_namespace]").val()) {
path = getPath( event_ns, $("input[name=event_namespace]").val(), event.val());
checkPath(path, 'el');
} else {
throwMessages('error', 'Please provide some input.', "el");
}
}
function getPath(ns, namespace, model) {
if(dir = $("input[name=directory_name]").val()) {
return ns + namespace + "\\" + dir + "\\" + model;
} else {
return ns + namespace + "\\" + model;
}
}
function checkPath(path, element) {
$.post( "{{ route('admin.modules.check.namespace') }}", { 'path' : path} )
.done( function( data ) {
throwMessages(data.type, data.message, element);
});
}
function throwMessages(type, message, element) {
appendMessage = '';
switch(type) {
case 'warning' :
appendMessage = "<span class='"+ element +"-warning'><i class='fa fa-exclamation-triangle' aria-hidden='true'></i>&nbsp; "+ message +"</span>";
break;
case 'error' :
appendMessage = "<span class='"+ element +"-error'><i class='fa fa-exclamation-circle' aria-hidden='true'></i>&nbsp; "+ message +"</span>";
break;
case 'success' :
appendMessage = "<span class='"+ element +"-success'><i class='fa fa-check' aria-hidden='true'></i>&nbsp; "+ message +"</span>";
}
$("."+element+"-messages").html(appendMessage);
}
function getFilesGenerated() {
model = $("input[name=model_name]").val();
if(model) {
separator = "" ;
if(dir = $("input[name=directory_name]").val()) {
model_nspace = model_ns + dir;
controller_nspace = controller_ns + dir;
request_nspace = request_ns + dir;
repo_nspace = repo_ns + dir;
event_nspace = event_ns + dir;
views_path = view_path + pluralize(dir.toLowerCase());
separator = "\\";
}
else {
model_nspace = model_ns;
controller_nspace = controller_ns;
request_nspace = request_ns;
repo_nspace = repo_ns;
event_nspace = event_ns;
views_path = view_path;
}
list_nspace = event_nspace.replace("Events", "Listeners");
directory_separator = "\\";
files = [];
model_plural = pluralize(model);
files.push(model_nspace + separator + model + ".php\n");
files.push(model_nspace + separator + "Traits" + directory_separator + model_plural + "Attribute.php\n");
files.push(model_nspace + separator + "Traits" + directory_separator + model_plural + "Relationship.php\n");
files.push("\n" + controller_nspace + separator +model_plural + "Controller.php\n");
files.push(controller_nspace + separator +model_plural + "TableController.php\n");
create = $("input[name=model_create]").prop('checked');
edit = $("input[name=model_edit]").prop('checked');
del = $("input[name=model_delete]").prop('checked');
files.push("\n");
if(create) {
files.push(request_nspace + separator + "Create" + model_plural + "Request.php\n");
files.push(request_nspace + separator + "Store" + model_plural + "Request.php\n");
}
if(edit) {
files.push(request_nspace + separator + "Edit" + model_plural + "Request.php\n");
files.push(request_nspace + separator + "Update" + model_plural + "Request.php\n");
}
if(del) {
files.push(request_nspace + separator + "Delete" + model_plural + "Request.php\n");
}
files.push("\n" + views_path + separator + "index.blade.php\n");
if(create) {
files.push(views_path + separator + "create.blade.php\n");
}
if(edit) {
files.push(views_path + separator + "edit.blade.php\n");
}
if(create || edit) {
files.push(views_path + separator + "form.blade.php\n");
}
files.push("\n");
files.push(route_path + model + ".php\n");
files.push("\n");
files.push(repo_nspace + separator + model_plural + "Repository.php\n");
files.push("\n");
$(document).find('input[name="event[]"]').each(function(){
if(e = $(this).val()) {
files.push(event_nspace + separator + e + ".php\n");
files.push(list_nspace + separator + e + "Listener.php\n");
}
});
files = files.toString().replace (/,/g, "");
$(".files").val(files);
}
}
//If any errors occured,
//the panels should automatically be opened
//which were opened before
function handleAllCheckboxes() {
handleCheckBox($("input[name=model]"), $(".model"));
handleCheckBox($("input[name=controller]"), $(".controller"));
handleCheckBox($("input[name=table_controller]"), $(".table_controller"));
handleCheckBox($("input[name=table]"), $(".table"));
handleCheckBox($("input[name=route]"), $(".route"));
handleCheckBox($("input[name=views]"), $(".views"));
handleCheckBox($("input[name=el]"), $(".el"));
handleCheckBox($("input[name=repository]"), $(".repository"));
throwMessages('warning', 'The table name can only contain characters and digits and underscores[_].', 'table');
throwMessages('warning', 'The files with the same name would be overwritten.', 'views');
}
//Handle the checkbox event for that element
function handleCheckBox(checkbox, element){
checkboxValue = checkbox.prop('checked');
if($("."+checkbox.attr('name')+"-messages").children().length == 0) {
$("."+checkbox.attr('name')+"-messages").empty();
}
if(checkboxValue) {
element.removeClass('hidden', 3000);
}
else {
element.addClass('hidden', 3000);
}
//calling required field handler functions
switch (checkbox.attr('name')) {
case 'model' : handleModelRequiredFields(checkboxValue);
break;
case 'controller' : handleControllerRequiredFields(checkboxValue);
break;
case 'table' : handleTableRequiredFields(checkboxValue);
break;
case 'route' : handleRouteRequiredFields(checkboxValue);
break;
case 'repository' : handleRepoRequiredFields(checkboxValue);
break;
case 'el' : handleEventRequiredFields(checkboxValue);
break;
}
}
//Events Required fields if that panel is open
function handleEventRequiredFields(check) {
$("input[name=event_namespace]").attr('required', check);
$("input[name='event[]']").attr('required', check);
}
//For changing namespace
// function changeNamespace(val, ns, element) {
// if(!val) {
// val = ns.replace('/\\\\/g', '');
// } else {
// val = ns + "\\" + val + "\\";
// }
// element.text(val);
// }
//For only characters
$( document ).on('keyup', ".only-text", function(e) {
var val = $(this).val();
if (val.match(/[^a-zA-Z]/g)) {
$(this).val(val.replace(/[^a-zA-Z]/g, ''));
}
});
</script>
@endsection
@extends ('backend.layouts.app')
@section ('title', trans('labels.backend.modules.management'))
@section('page-header')
<h1>{{ trans('labels.backend.modules.management') }}</h1>
@endsection
@section('content')
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('labels.backend.modules.management') }}</h3>
<div class="box-tools pull-right">
@include('generator::partials.modules-header-buttons')
</div>
</div><!-- /.box-header -->
<div class="box-body">
<div class="table-responsive data-table-wrapper">
<table id="modules-table" class="table table-condensed table-hover table-bordered">
<thead>
<tr>
<th>{{ trans('labels.backend.modules.table.name') }}</th>
<th>{{ trans('labels.backend.modules.table.view_permission_id') }}</th>
<th>{{ trans('labels.backend.modules.table.url') }}</th>
<th>{{ trans('labels.backend.modules.table.created_by') }}</th>
</tr>
</thead>
<thead class="transparent-bg">
<tr>
<th>
{!! Form::text('name', null, ["class" => "search-input-text form-control", "data-column" => 0, "placeholder" => trans('labels.backend.modules.table.name')]) !!}
<a class="reset-data" href="javascript:void(0)"><i class="fa fa-times"></i></a>
</th>
<th>
{!! Form::text('permission', null, ["class" => "search-input-text form-control", "data-column" => 1, "placeholder" => trans('labels.backend.modules.table.view_permission_id')]) !!}
<a class="reset-data" href="javascript:void(0)"><i class="fa fa-times"></i></a>
</th>
<th>
{!! Form::text('route', null, ["class" => "search-input-text form-control", "data-column" => 2, "placeholder" => trans('labels.backend.modules.table.url')]) !!}
<a class="reset-data" href="javascript:void(0)"><i class="fa fa-times"></i></a>
</th>
<th>
{!! Form::text('created_by', null, ["class" => "search-input-text form-control", "data-column" => 3, "placeholder" => trans('labels.backend.modules.table.created_by')]) !!}
<a class="reset-data" href="javascript:void(0)"><i class="fa fa-times"></i></a>
</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 --}}
{{ Html::script(mix('js/dataTable.js')) }}
<script>
$(function() {
var dataTable = $('#modules-table').dataTable({
processing: true,
serverSide: true,
ajax: {
url: '{{ route("admin.modules.get") }}',
type: 'post'
},
columns: [
{data: 'name', name: '{{config('module.table')}}.name'},
{data: 'view_permission_id', name: '{{config('module.table')}}.view_permission_id'},
{data: 'url', name: '{{config('module.table')}}.url'},
{data: 'created_by', name: '{{config('access.users_table')}}.first_name'}
],
order: [[0, "asc"]],
searchDelay: 500,
dom: 'lBfrtip',
buttons: {
buttons: [
{ extend: 'copy', className: 'copyButton', exportOptions: {columns: [ 0, 1, 2, 3 ] }},
{ extend: 'csv', className: 'csvButton', exportOptions: {columns: [ 0, 1, 2, 3 ] }},
{ extend: 'excel', className: 'excelButton', exportOptions: {columns: [ 0, 1, 2, 3 ] }},
{ extend: 'pdf', className: 'pdfButton', exportOptions: {columns: [ 0, 1, 2, 3 ] }},
{ extend: 'print', className: 'printButton', exportOptions: {columns: [ 0, 1, 2, 3 ] }}
]
}
});
Backend.DataTableSearch.init(dataTable);
});
</script>
@endsection
<!--Action Button-->
@if(Active::checkUriPattern('admin/modules'))
<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.modules.index')}}"><i class="fa fa-list-ul"></i> {{trans('menus.backend.modules.all')}}</a></li>
<li><a href="{{route('admin.modules.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.modules.create')}}</a></li>
</ul>
</div>
<div class="clearfix"></div>
\ No newline at end of file
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