File tree Expand file tree Collapse file tree 4 files changed +54
-1
lines changed Expand file tree Collapse file tree 4 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -19,10 +19,17 @@ window.Vue = Vue;
19
19
Vue . prototype . _ = _ ;
20
20
// id app
21
21
Vue . component ( 'front-page' , require ( './components/FrontPage.vue' ) . default ) ;
22
+
23
+ // id app
24
+ let categoriesCreate = Vue . component ( 'categories-create' , require ( './components/CategoriesCreate.vue' ) . default ) ;
25
+
22
26
// Load third party vue component `laravel-vue-pagination`
23
27
Vue . component ( 'pagination' , require ( 'laravel-vue-pagination' ) ) ;
24
28
25
29
// load the front component
26
30
new Vue ( {
27
- el : '#app'
31
+ el : '#app' ,
32
+ components : {
33
+ categoriesCreate : categoriesCreate
34
+ }
28
35
} ) ;
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div class =" container py-5" >
3
+ <div class =" row" >
4
+ <div class =" col-lg-12" >
5
+ <div class =" mb-3" >
6
+ <label for =" name" class =" form-label" >Name:</label >
7
+ <input type =" text" v-model =" name" name =" name" class =" form-control" id =" name" placeholder =" Category Name" autocomplete =" off" >
8
+ <input type =" button" class =" btn btn-primary mt-3" value =" Add Category" @click =" createCategory()" >
9
+ </div >
10
+ </div >
11
+ </div >
12
+ </div >
13
+ </template >
14
+
15
+ <script >
16
+ export default {
17
+ name: ' CategoriesCreate' ,
18
+ data : function (){
19
+ return {
20
+ name: ' '
21
+ }
22
+ },
23
+ methods: {
24
+ createCategory : function (){
25
+ console .log (' Creating Category...' );
26
+ axios .post (' /api/categories' , {
27
+ name: this .name
28
+ }).then ( function (response ) {
29
+ console .log (' New Category ID' , response .data .data .id );
30
+ }).catch (function (err ) {
31
+ console .log (' Category Route error Promise has been rejected!' , err);
32
+ });
33
+ }
34
+ }
35
+ }
36
+ </script >
Original file line number Diff line number Diff line change
1
+ @extends (' master' )
2
+
3
+ @section (' vue' )
4
+ <div id =" app" >
5
+ <categories-create ></categories-create >
6
+ </div >
7
+ @endsection
Original file line number Diff line number Diff line change 16
16
17
17
// Just load the Blade File
18
18
Route::view ('/ ' , 'home ' );
19
+
20
+ // Categories create.blade.php file for the form creation.
21
+ Route::view ('/categories/create ' , 'create ' )->name ('categories.create ' );
You can’t perform that action at this time.
0 commit comments