12 changed files with 0 additions and 418 deletions
-
79app/Http/Controllers/MastersController.php
-
32app/Http/Requests/Masters/CreateRequest.php
-
31app/Http/Requests/Masters/DeleteRequest.php
-
32app/Http/Requests/Masters/UpdateRequest.php
-
32app/Http/Requests/Users/Permissions/CreateRequest.php
-
31app/Http/Requests/Users/Permissions/DeleteRequest.php
-
32app/Http/Requests/Users/Permissions/UpdateRequest.php
-
24resources/views/masters/create.blade.php
-
28resources/views/masters/delete.blade.php
-
26resources/views/masters/edit.blade.php
-
45resources/views/masters/index.blade.php
-
26resources/views/masters/show.blade.php
@ -1,79 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Http\Controllers; |
|
||||
|
|
||||
use App\Http\Requests\Masters\CreateRequest; |
|
||||
use App\Http\Requests\Masters\UpdateRequest; |
|
||||
use App\Http\Requests\Masters\DeleteRequest; |
|
||||
use App\Http\Controllers\Controller; |
|
||||
use App\Entities\Masters\MastersRepository; |
|
||||
|
|
||||
use Illuminate\Http\Request; |
|
||||
|
|
||||
class MastersController extends Controller { |
|
||||
|
|
||||
private $repo; |
|
||||
|
|
||||
public function __construct(MastersRepository $repo) |
|
||||
{ |
|
||||
$this->repo = $repo; |
|
||||
$this->middleware('auth'); |
|
||||
} |
|
||||
|
|
||||
public function index(Request $req) |
|
||||
{ |
|
||||
$masters = $this->repo->getAll($req->get('q')); |
|
||||
return view('masters.index',compact('masters')); |
|
||||
} |
|
||||
|
|
||||
public function create() |
|
||||
{ |
|
||||
return view('masters.create'); |
|
||||
} |
|
||||
|
|
||||
public function store(CreateRequest $req) |
|
||||
{ |
|
||||
$master = $this->repo->create($req->except('_token')); |
|
||||
flash()->success(trans('master.created')); |
|
||||
return redirect()->route('masters.edit', $master->id); |
|
||||
} |
|
||||
|
|
||||
public function show($masterId) |
|
||||
{ |
|
||||
$master = $this->repo->requireById($masterId); |
|
||||
return view('masters.show', compact('master')); |
|
||||
} |
|
||||
|
|
||||
public function edit($masterId) |
|
||||
{ |
|
||||
$master = $this->repo->requireById($masterId); |
|
||||
return view('masters.edit',compact('master')); |
|
||||
} |
|
||||
|
|
||||
public function update(UpdateRequest $req, $masterId) |
|
||||
{ |
|
||||
$master = $this->repo->update($req->except(['_method','_token']), $masterId); |
|
||||
flash()->success(trans('master.updated')); |
|
||||
return redirect()->route('masters.edit', $masterId); |
|
||||
} |
|
||||
|
|
||||
public function delete($masterId) |
|
||||
{ |
|
||||
$master = $this->repo->requireById($masterId); |
|
||||
return view('masters.delete', compact('master')); |
|
||||
} |
|
||||
|
|
||||
public function destroy(DeleteRequest $req, $masterId) |
|
||||
{ |
|
||||
if ($masterId == $req->get('master_id')) |
|
||||
{ |
|
||||
$this->repo->delete($masterId); |
|
||||
flash()->success(trans('master.deleted')); |
|
||||
} |
|
||||
else |
|
||||
flash()->error(trans('master.undeleted')); |
|
||||
|
|
||||
return redirect()->route('masters.index'); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,32 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Http\Requests\Masters; |
|
||||
|
|
||||
use App\Http\Requests\Request; |
|
||||
|
|
||||
class CreateRequest extends Request { |
|
||||
|
|
||||
/** |
|
||||
* Determine if the user is authorized to make this request. |
|
||||
* |
|
||||
* @return bool |
|
||||
*/ |
|
||||
public function authorize() |
|
||||
{ |
|
||||
return auth()->user()->can('manage_masters'); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Get the validation rules that apply to the request. |
|
||||
* |
|
||||
* @return array |
|
||||
*/ |
|
||||
public function rules() |
|
||||
{ |
|
||||
return [ |
|
||||
'name' => 'required|max:60|unique:masters,name', |
|
||||
'description' => 'max:255' |
|
||||
]; |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,31 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Http\Requests\Masters; |
|
||||
|
|
||||
use App\Http\Requests\Request; |
|
||||
|
|
||||
class DeleteRequest extends Request { |
|
||||
|
|
||||
/** |
|
||||
* Determine if the user is authorized to make this request. |
|
||||
* |
|
||||
* @return bool |
|
||||
*/ |
|
||||
public function authorize() |
|
||||
{ |
|
||||
return auth()->user()->can('manage_masters'); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Get the validation rules that apply to the request. |
|
||||
* |
|
||||
* @return array |
|
||||
*/ |
|
||||
public function rules() |
|
||||
{ |
|
||||
return [ |
|
||||
'master_id' => 'required' |
|
||||
]; |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,32 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Http\Requests\Masters; |
|
||||
|
|
||||
use App\Http\Requests\Request; |
|
||||
|
|
||||
class UpdateRequest extends Request { |
|
||||
|
|
||||
/** |
|
||||
* Determine if the user is authorized to make this request. |
|
||||
* |
|
||||
* @return bool |
|
||||
*/ |
|
||||
public function authorize() |
|
||||
{ |
|
||||
return auth()->user()->can('manage_masters'); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Get the validation rules that apply to the request. |
|
||||
* |
|
||||
* @return array |
|
||||
*/ |
|
||||
public function rules() |
|
||||
{ |
|
||||
return [ |
|
||||
'name' => 'required|max:60|unique:masters,name,' . $this->segment(2), |
|
||||
'description' => 'max:255' |
|
||||
]; |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,32 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Http\Requests\Users\Permissions; |
|
||||
|
|
||||
use App\Http\Requests\Request; |
|
||||
|
|
||||
class CreateRequest extends Request { |
|
||||
|
|
||||
/** |
|
||||
* Determine if the user is authorized to make this request. |
|
||||
* |
|
||||
* @return bool |
|
||||
*/ |
|
||||
public function authorize() |
|
||||
{ |
|
||||
return auth()->user()->can('manage_role_permissions'); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Get the validation rules that apply to the request. |
|
||||
* |
|
||||
* @return array |
|
||||
*/ |
|
||||
public function rules() |
|
||||
{ |
|
||||
return [ |
|
||||
'name' => 'required|max:60|unique:roles_permissions,name', |
|
||||
'label' => 'required|max:60', |
|
||||
]; |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,31 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Http\Requests\Users\Permissions; |
|
||||
|
|
||||
use App\Http\Requests\Request; |
|
||||
|
|
||||
class DeleteRequest extends Request { |
|
||||
|
|
||||
/** |
|
||||
* Determine if the user is authorized to make this request. |
|
||||
* |
|
||||
* @return bool |
|
||||
*/ |
|
||||
public function authorize() |
|
||||
{ |
|
||||
return auth()->user()->can('manage_role_permissions'); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Get the validation rules that apply to the request. |
|
||||
* |
|
||||
* @return array |
|
||||
*/ |
|
||||
public function rules() |
|
||||
{ |
|
||||
return [ |
|
||||
'permission_id' => 'required' |
|
||||
]; |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,32 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Http\Requests\Users\Permissions; |
|
||||
|
|
||||
use App\Http\Requests\Request; |
|
||||
|
|
||||
class UpdateRequest extends Request { |
|
||||
|
|
||||
/** |
|
||||
* Determine if the user is authorized to make this request. |
|
||||
* |
|
||||
* @return bool |
|
||||
*/ |
|
||||
public function authorize() |
|
||||
{ |
|
||||
return auth()->user()->can('manage_role_permissions'); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Get the validation rules that apply to the request. |
|
||||
* |
|
||||
* @return array |
|
||||
*/ |
|
||||
public function rules() |
|
||||
{ |
|
||||
return [ |
|
||||
'name' => 'required|max:60|unique:roles_permissions,name,' . $this->segment(2), |
|
||||
'label' => 'required|max:60', |
|
||||
]; |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,24 +0,0 @@ |
|||||
@extends('layouts.app') |
|
||||
|
|
||||
@section('title', trans('master.create')) |
|
||||
|
|
||||
@section('content') |
|
||||
<div class="row"><br> |
|
||||
<div class="col-md-4"> |
|
||||
{!! Form::open(['route'=>'masters.store']) !!} |
|
||||
<div class="panel panel-default"> |
|
||||
<div class="panel-heading"><h3 class="panel-title">{{ trans('master.create') }}</h3></div> |
|
||||
<div class="panel-body"> |
|
||||
{!! FormField::text('name',['label'=> trans('app.name')]) !!} |
|
||||
{!! FormField::textarea('description',['label'=> trans('app.description')]) !!} |
|
||||
</div> |
|
||||
|
|
||||
<div class="panel-footer"> |
|
||||
{!! Form::submit(trans('master.create'), ['class'=>'btn btn-primary']) !!} |
|
||||
{!! link_to_route('masters.index', trans('app.cancel'), [], ['class'=>'btn btn-default']) !!} |
|
||||
</div> |
|
||||
</div> |
|
||||
{!! Form::close() !!} |
|
||||
</div> |
|
||||
</div> |
|
||||
@endsection |
|
||||
@ -1,28 +0,0 @@ |
|||||
@extends('layouts.app') |
|
||||
|
|
||||
@section('title', trans('master.delete')) |
|
||||
|
|
||||
@section('content') |
|
||||
<h1 class="page-header"> |
|
||||
<div class="pull-right"> |
|
||||
{!! FormField::delete(['route'=>['masters.destroy',$master->id]], trans('app.delete_confirm_button'), ['class'=>'btn btn-danger'], ['master_id'=>$master->id]) !!} |
|
||||
</div> |
|
||||
{{ trans('app.delete_confirm') }} |
|
||||
{!! link_to_route('masters.show', trans('app.cancel'), [$master->id], ['class' => 'btn btn-default']) !!} |
|
||||
</h1> |
|
||||
<div class="row"> |
|
||||
<div class="col-md-4"> |
|
||||
<div class="panel panel-info"> |
|
||||
<div class="panel-heading"><h3 class="panel-title">{{ trans('master.show') }}</h3></div> |
|
||||
<div class="panel-body"> |
|
||||
<table class="table table-condensed"> |
|
||||
<tbody> |
|
||||
<tr><th>{{ trans('master.name') }}</th><td>{{ $master->name }}</td></tr> |
|
||||
<tr><th>{{ trans('app.description') }}</th><td>{{ $master->description }}</td></tr> |
|
||||
</tbody> |
|
||||
</table> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
@endsection |
|
||||
@ -1,26 +0,0 @@ |
|||||
@extends('layouts.app') |
|
||||
|
|
||||
@section('title', trans('master.edit')) |
|
||||
|
|
||||
@section('content') |
|
||||
<div class="row"><br> |
|
||||
<div class="col-md-4"> |
|
||||
{!! Form::model($master, ['route'=>['masters.update', $master->id], 'method' => 'patch']) !!} |
|
||||
<div class="panel panel-default"> |
|
||||
<div class="panel-heading"><h3 class="panel-title">{{ $master->name }} <small>{{ trans('master.edit') }}</small></h3></div> |
|
||||
<div class="panel-body"> |
|
||||
{!! FormField::text('name',['label'=> trans('app.name')]) !!} |
|
||||
{!! FormField::textarea('description',['label'=> trans('app.description')]) !!} |
|
||||
</div> |
|
||||
|
|
||||
<div class="panel-footer"> |
|
||||
{!! Form::submit(trans('master.update'), ['class'=>'btn btn-primary']) !!} |
|
||||
{!! link_to_route('masters.show', trans('app.show'), [$master->id], ['class' => 'btn btn-info']) !!} |
|
||||
{!! link_to_route('masters.index', trans('master.back_to_index'), [], ['class' => 'btn btn-default']) !!} |
|
||||
{!! link_to_route('masters.delete', trans('app.delete'), [$master->id], ['class'=>'btn btn-danger pull-right']) !!} |
|
||||
</div> |
|
||||
</div> |
|
||||
{!! Form::close() !!} |
|
||||
</div> |
|
||||
</div> |
|
||||
@endsection |
|
||||
@ -1,45 +0,0 @@ |
|||||
@extends('layouts.app') |
|
||||
|
|
||||
@section('title', trans('master.masters')) |
|
||||
|
|
||||
@section('content') |
|
||||
<h1 class="page-header"> |
|
||||
{!! link_to_route('masters.create', trans('master.create'), [], ['class'=>'btn btn-success pull-right']) !!} |
|
||||
{{ trans('master.masters') }} <small>{{ $masters->total() }} {{ trans('master.found') }}</small> |
|
||||
</h1> |
|
||||
<div class="well well-sm"> |
|
||||
{!! Form::open(['method'=>'get','class'=>'form-inline']) !!} |
|
||||
{!! Form::text('q', Request::get('q'), ['class'=>'form-control index-search-field','placeholder'=>trans('master.search'),'style' => 'width:350px']) !!} |
|
||||
{!! Form::submit(trans('master.search'), ['class' => 'btn btn-info btn-sm']) !!} |
|
||||
{!! link_to_route('masters.index','Reset',[],['class' => 'btn btn-default btn-sm']) !!} |
|
||||
{!! Form::close() !!} |
|
||||
</div> |
|
||||
<table class="table table-condensed"> |
|
||||
<thead> |
|
||||
<th>{{ trans('app.table_no') }}</th> |
|
||||
<th>{{ trans('app.name') }}</th> |
|
||||
<th>{{ trans('app.description') }}</th> |
|
||||
<th>{{ trans('app.created_at') }}</th> |
|
||||
<th>{{ trans('app.action') }}</th> |
|
||||
</thead> |
|
||||
<tbody> |
|
||||
@forelse($masters as $key => $master) |
|
||||
<tr> |
|
||||
<td>{{ $masters->firstItem() + $key }}</td> |
|
||||
<td>{{ $master->name }}</td> |
|
||||
<td>{{ $master->description }}</td> |
|
||||
<td>{{ $master->created_at }}</td> |
|
||||
<td> |
|
||||
{!! link_to_route('masters.show',trans('app.show'),[$master->id],['class'=>'btn btn-info btn-xs']) !!} |
|
||||
{!! link_to_route('masters.edit',trans('app.edit'),[$master->id],['class'=>'btn btn-warning btn-xs']) !!} |
|
||||
</td> |
|
||||
</tr> |
|
||||
@empty |
|
||||
<tr> |
|
||||
<td colspan="5">{{ trans('master.not_found') }}</td> |
|
||||
</tr> |
|
||||
@endforelse |
|
||||
</tbody> |
|
||||
</table> |
|
||||
{!! str_replace('/?', '?', $masters->appends(Request::except('page'))->render()) !!} |
|
||||
@endsection |
|
||||
@ -1,26 +0,0 @@ |
|||||
@extends('layouts.app') |
|
||||
|
|
||||
@section('title', trans('master.show')) |
|
||||
|
|
||||
@section('content') |
|
||||
<h1 class="page-header">{{ $master->name }} <small>{{ trans('master.show') }}</small></h1> |
|
||||
<div class="row"> |
|
||||
<div class="col-md-4"> |
|
||||
<div class="panel panel-default"> |
|
||||
<div class="panel-heading"><h3 class="panel-title">{{ trans('master.show') }}</h3></div> |
|
||||
<div class="panel-body"> |
|
||||
<table class="table table-condensed"> |
|
||||
<tbody> |
|
||||
<tr><th>{{ trans('master.name') }}</th><td>{{ $master->name }}</td></tr> |
|
||||
<tr><th>{{ trans('app.description') }}</th><td>{{ $master->description }}</td></tr> |
|
||||
</tbody> |
|
||||
</table> |
|
||||
</div> |
|
||||
<div class="panel-footer"> |
|
||||
{!! link_to_route('masters.edit', trans('app.edit'), [$master->id], ['class' => 'btn btn-warning']) !!} |
|
||||
{!! link_to_route('masters.index', trans('master.back_to_index'), [], ['class' => 'btn btn-default']) !!} |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
@endsection |
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue