Skip to content

Commit 2713820

Browse files
committed
Repair status_id error
1 parent 67855f1 commit 2713820

File tree

4 files changed

+31
-10
lines changed

4 files changed

+31
-10
lines changed

coreui/src/views/notes/CreateNote.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default {
6262
title: '',
6363
content: '',
6464
applies_to_date: '',
65-
status_id: '',
65+
status_id: null,
6666
note_type: '',
6767
},
6868
statuses: [],
@@ -83,6 +83,13 @@ export default {
8383
self.note
8484
)
8585
.then(function (response) {
86+
self.note = {
87+
title: '',
88+
content: '',
89+
applies_to_date: '',
90+
status_id: null,
91+
note_type: '',
92+
};
8693
self.message = 'Successfully created note.';
8794
self.showAlert();
8895
}).catch(function (error) {

coreui/src/views/notes/Notes.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@dismiss-count-down="countDownChanged">
1313
({{dismissCountDown}}) {{ message }}
1414
</b-alert>
15-
<b-table :hover="hover" :striped="striped" :bordered="bordered" :small="small" :fixed="fixed" responsive="sm" :items="items" :fields="fields" :current-page="currentPage" :per-page="perPage">
15+
<b-table :hover="hover" :striped="striped" :bordered="bordered" :small="small" :fixed="fixed" responsive="lg" :items="items" :fields="fields" :current-page="currentPage" :per-page="perPage">
1616
<template slot="author" slot-scope="data">
1717
<strong>{{data.item.author}}</strong>
1818
</template>
@@ -32,11 +32,16 @@
3232
<strong>{{data.item.note_type}}</strong>
3333
</template>
3434

35-
<template slot="functions" slot-scope="data">
35+
<template slot="Show" slot-scope="data">
3636
<b-button variant="primary" @click="showNote( data.item.id )">Show</b-button>
37+
</template>
38+
<template slot="Edit" slot-scope="data">
3739
<b-button variant="primary" @click="editNote( data.item.id )">Edit</b-button>
40+
</template>
41+
<template slot="Delete" slot-scope="data">
3842
<b-button v-if="you!=data.item.id" variant="danger" @click="deleteNote( data.item.id )">Delete</b-button>
3943
</template>
44+
4045
</b-table>
4146
<nav>
4247
<b-pagination size="sm" :total-rows="getRowCount(items)" :per-page="perPage" v-model="currentPage" prev-text="Prev" next-text="Next" hide-goto-end-buttons/>
@@ -88,7 +93,9 @@ export default {
8893
{key: 'applies_to_date'},
8994
{key: 'status'},
9095
{key: 'note_type'},
91-
{key: 'functions'}
96+
{key: 'Show'},
97+
{key: 'Edit'},
98+
{key: 'Delete'}
9299
],
93100
currentPage: 1,
94101
perPage: 5,

coreui/src/views/users/Users.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@dismiss-count-down="countDownChanged">
1212
({{dismissCountDown}}) {{ message }}
1313
</b-alert>
14-
<b-table :hover="hover" :striped="striped" :bordered="bordered" :small="small" :fixed="fixed" responsive="sm" :items="items" :fields="fields" :current-page="currentPage" :per-page="perPage">
14+
<b-table :hover="hover" :striped="striped" :bordered="bordered" :small="small" :fixed="fixed" responsive="md" :items="items" :fields="fields" :current-page="currentPage" :per-page="perPage">
1515
<template slot="id" slot-scope="data">
1616
<strong>{{data.item.id}}</strong>
1717
</template>
@@ -21,9 +21,13 @@
2121
<template slot="status" slot-scope="data">
2222
<b-badge :variant="getBadge(data.item.status)">{{data.item.status}}</b-badge>
2323
</template>
24-
<template slot="functions" slot-scope="data">
24+
<template slot="show" slot-scope="data">
2525
<b-button variant="primary" @click="showUser( data.item.id )">Show</b-button>
26+
</template>
27+
<template slot="edit" slot-scope="data">
2628
<b-button variant="primary" @click="editUser( data.item.id )">Edit</b-button>
29+
</template>
30+
<template slot="delete" slot-scope="data">
2731
<b-button v-if="you!=data.item.id" variant="danger" @click="deleteUser( data.item.id )">Delete</b-button>
2832
</template>
2933
</b-table>
@@ -76,7 +80,9 @@ export default {
7680
{key: 'registered'},
7781
{key: 'roles'},
7882
{key: 'status'},
79-
{key: 'functions'}
83+
{key: 'show'},
84+
{key: 'edit'},
85+
{key: 'delete'}
8086
],
8187
currentPage: 1,
8288
perPage: 5,

laravel/app/Http/Controllers/NotesController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function index()
2828
{
2929
$notes = DB::table('notes')
3030
->join('users', 'users.id', '=', 'notes.users_id')
31-
->join('status', 'status.id', '=', 'notes.users_id')
31+
->join('status', 'status.id', '=', 'notes.status_id')
3232
->select('notes.*', 'users.name as author', 'status.name as status', 'status.class as status_class')
3333
->get();
3434
return response()->json( $notes );
@@ -60,13 +60,14 @@ public function store(Request $request)
6060
'applies_to_date' => 'required|date_format:Y-m-d',
6161
'note_type' => 'required|max:64'
6262
]);
63+
$user = auth()->userOrFail();
6364
$note = new Notes();
6465
$note->title = $request->input('title');
6566
$note->content = $request->input('content');
6667
$note->status_id = $request->input('status_id');
6768
$note->note_type = $request->input('note_type');
6869
$note->applies_to_date = $request->input('applies_to_date');
69-
$note->users_id = $request->get('user_id') ? $request->get('user_id') : $request->input('user_id');
70+
$note->users_id = $user->id;
7071
$note->save();
7172
return response()->json( ['status' => 'success'] );
7273
}
@@ -81,7 +82,7 @@ public function show($id)
8182
{
8283
$note = DB::table('notes')
8384
->join('users', 'users.id', '=', 'notes.users_id')
84-
->join('status', 'status.id', '=', 'notes.users_id')
85+
->join('status', 'status.id', '=', 'notes.status_id')
8586
->select('notes.*', 'users.name as author', 'status.name as status', 'status.class as status_class')
8687
->where('notes.id', '=', $id)
8788
->first();

0 commit comments

Comments
 (0)