-
app/Http/Controllers/CompanyController.php
Open in GitHubuse Illuminate\Http\Request; class CompanyController extends Controller { public function store(Request $request) { $user = auth()->user(); $request->validate([ 'name' => ['required', 'unique:landlord.companies'], ]); return $user->Company()->create([ 'name' => $request->name, 'status' => 1, 'current_tenant' => 0, ]); } }
-
pages/company/create.vue
Open in GitHub<template> // </template> <script> // methods: { save() { this.$v.$touch(); if (this.$v.$invalid) { console.log("fail") } else { this.$axios.$post('/api/company', this.company) .then(response => (this.$router.push('/company'))) .catch(error => { }); } }, } } </script>
-
routes/api.php
Open in GitHubuse Illuminate\Support\Facades\Route; // Route::middleware('tenant')->group(function () { // Route::resource('company', 'CompanyController'); // });