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;
1919Vue . prototype . _ = _ ;
2020// id app
2121Vue . 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+
2226// Load third party vue component `laravel-vue-pagination`
2327Vue . component ( 'pagination' , require ( 'laravel-vue-pagination' ) ) ;
2428
2529// load the front component
2630new Vue ( {
27- el : '#app'
31+ el : '#app' ,
32+ components : {
33+ categoriesCreate : categoriesCreate
34+ }
2835} ) ;
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 1616
1717// Just load the Blade File
1818Route::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