Skip to content

Commit

Permalink
Enhancements:
Browse files Browse the repository at this point in the history
- Added permission blade directives around the index generator
- Minor fix: Corrected the model title in the CRUD returned message
  • Loading branch information
coolsam726 committed Aug 13, 2020
1 parent bbf285d commit 03c8184
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 4 additions & 4 deletions resources/views/api-controller.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function store(Store{{$modelBaseName}} $request)
@endif
@endif{{PHP_EOL}}
${{$modelVariableName}}->saveOrFail();
return $this->api->success()->message('{{$modelBaseName}} Created')->payload(${{$modelVariableName}})->send();
return $this->api->success()->message('{{$modelTitle}} Created')->payload(${{$modelVariableName}})->send();
} catch (\Throwable $exception) {
\Log::error($exception);
return $this->api->failed()->message($exception->getMessage())->payload([])->code(500)->send();
Expand Down Expand Up @@ -114,7 +114,7 @@ public function show(Request $request, {{$modelBaseName}} ${{$modelVariableName}
]);
@endif
@endif
return $this->api->success()->message("{{$modelBaseName}} ${{$modelVariableName}}->id")->payload(${{$modelVariableName}})->send();
return $this->api->success()->message("{{$modelTitle}} ${{$modelVariableName}}->id")->payload(${{$modelVariableName}})->send();
} catch (\Throwable $exception) {
return $this->api->failed()->message($exception->getMessage())->send();
}
Expand Down Expand Up @@ -153,7 +153,7 @@ public function update(Update{{$modelBaseName}} $request, {{$modelBaseName}} ${{
@endif
@endif{{PHP_EOL}}
${{$modelVariableName}}->saveOrFail();
return $this->api->success()->message("{{$modelBaseName}} has been updated")->payload(${{$modelVariableName}})->code(200)->send();
return $this->api->success()->message("{{$modelTitle}} has been updated")->payload(${{$modelVariableName}})->code(200)->send();
} catch (\Throwable $exception) {
\Log::error($exception);
return $this->api->failed()->code(400)->message($exception->getMessage())->send();
Expand All @@ -170,7 +170,7 @@ public function update(Update{{$modelBaseName}} $request, {{$modelBaseName}} ${{
public function destroy({{$modelBaseName}} ${{$modelVariableName}})
{
${{$modelVariableName}}->delete();
return $this->api->success()->message("{{$modelBaseName}} has been deleted")->payload(${{$modelVariableName}})->code(200)->send();
return $this->api->success()->message("{{$modelTitle}} has been deleted")->payload(${{$modelVariableName}})->code(200)->send();
}

@if($export)
Expand Down
11 changes: 10 additions & 1 deletion resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
<b-col>
<b-card title="{{\Illuminate\Support\Str::pluralStudly($modelTitle)}} List">
<div class="text-right mb-2">
<b-button v-on:click="showFormDialog()" variant="primary"><i class="mdi mdi-plus"></i> New {{$modelTitle}}</b-button>
{{'@'}}can('{{$modelRouteAndViewName}}.create')<b-button v-on:click="showFormDialog()" variant="primary"><i class="mdi mdi-plus"></i> New {{$modelTitle}}</b-button>
{{'@'}}endcan
</div>
{{'@'}}can('{{$modelRouteAndViewName}}.index')
<dt-component table-id="{{$modelRouteAndViewName}}-dt"
@php
echo 'ajax-url="{{route(\'api.'.$modelRouteAndViewName.'.dt\')}}"'
Expand All @@ -34,7 +36,9 @@
v-on:show-{{str_singular($modelRouteAndViewName)}}="showDetailsDialog"
v-on:delete-{{str_singular($modelRouteAndViewName)}}="showDeleteDialog"
></dt-component>
{{'@'}}endcan
</b-card>
{{'@'}}canany(['{{$modelRouteAndViewName}}.create','{{$modelRouteAndViewName}}.edit'])
<b-modal size="lg" v-if="form" v-on:ok.prevent="onFormSubmit" no-close-on-backdrop v-cloak ref="{{$modelVariableName}}FormDialog">
<template v-slot:modal-title>
<h4 v-if="form.id" class="font-weight-bolder">Edit {{$modelTitle}} @@{{ form.id }}</h4>
Expand All @@ -44,9 +48,13 @@
{{"@"}}include("backend.{{$modelJSName}}.form")
</template>
</b-modal>
{{'@'}}endcanany
{{'@'}}can('{{$modelRouteAndViewName}}.show')
<b-modal size="lg" v-if="form" scrollable v-cloak ref="{{$modelVariableName}}DetailsDialog">
{{"@"}}include('backend.{{$modelJSName}}.show')
</b-modal>
{{'@'}}endcan
{{'@'}}can('{{$modelRouteAndViewName}}.delete')
<b-modal size="sm" v-on:ok.prevent="deleteItem" hide-footer hide-header body-bg-variant="danger" body-text-variant="light" centered v-if="form" scrollable v-cloak ref="{{$modelVariableName}}DeleteDialog">
<template v-slot:default="{ok,hide}">
Are you sure you want to delete this {{$modelTitle}}?
Expand All @@ -56,6 +64,7 @@
</div>
</template>
</b-modal>
{{'@'}}endcan
</b-col>
</b-row>
</{{$modelJSName}}-component>
Expand Down

0 comments on commit 03c8184

Please sign in to comment.