Рубрики
Laravel+Vue3 project Vue.js Vue компоненты Laravel

Vue Создать запись в БД

Функции контроллера Laravel

App\Http\Controllers\ElementsController.php
контроллер работает с моделью Elements, включая создание записей

Роутер Laravel
обращение к методу создания

routes\api.php

<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\ElementsController;


Route::get('/all',[ElementsController::class, 'index']);
Route::post('/create', [ElementsController::class, 'store']);

Регистрация глобальная компонентов

  • MyButton
  • MyDialog
  • RowCreate

resources\js\app.js

require('./bootstrap');

import axios from "axios";
import { createApp } from 'vue';

import MyButton from './components/UI/MyButton.vue';
import MyDialog from './components/UI/MyDialog.vue';

import MyApp from './components/MyApp.vue';
import RowItem from './components/row/RowItem.vue';
import RowList from './components/row/RowList.vue';
import RowCreate from './components/row/create/RowCreate.vue';

const app=createApp({});
app.component('my-app',MyApp);
app.component('my-button',MyButton);
app.component('my-dialog',MyDialog);
app.component('row-item',RowItem);
app.component('row-list',RowList);
app.component('row-create',RowCreate);
app.mount('#app');

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *