Coder Social home page Coder Social logo

thecodeholic / laravel-vue-survey Goto Github PK

View Code? Open in Web Editor NEW
319.0 7.0 175.0 242 KB

This is a full stack application of Vue 3 with Tailwindcss 3 and Laravel 8

Home Page: https://yoursurveys.xyz

Shell 0.51% PHP 59.77% Blade 9.91% HTML 0.21% Vue 29.60%
laravel vue vue3 tailwindcss vuex vuejs

laravel-vue-survey's Introduction

Survey Full Stack Application

Built with these technologies for YouTube Video

Requirements

You need to have PHP version 8.0 or above. Node.js version 12.0 or above.

Demo

https://yoursurveys.xyz

Installation

Backend

  1. Clone the project
  2. Go to the project root directory
  3. Run composer install
  4. Create database
  5. Copy .env.example into .env file and adjust parameters
  6. Run php artisan serve to start the project at http://localhost:8000

Frontend

  1. Navigate to vue folder using terminal
  2. Run npm install to install vue.js project dependencies
  3. Copy vue/.env.example into vue/.env and specify API URL
  4. Start frontend by running npm run dev
  5. Open http://localhost:3000

License

The project is open-sourced software licensed under the MIT license.

laravel-vue-survey's People

Contributors

isharonov avatar thecodeholic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-vue-survey's Issues

Logout not working in front end but working the backend

in front end get error "Unauthenticated."
but when test the logout on the postman work successfully

axios.js file

import axios from 'axios';
import store from './store';

const axiosClient  = axios.create({
  baseURL : ' http://127.0.0.1:8000/api'
})

axiosClient.interceptors.request.use( (config) => {
  config.headers.Authrization = `Bearer ${store.state.user.token}`;
  return config;
})  export default axiosClient;

defaultlayout .vue

<!-- This example requires Tailwind CSS v2.0+ -->
<template>
  <!--
    This example requires updating your template:
    ```
    <html class="h-full bg-gray-100">
    <body class="h-full">
    ```
  -->
  <div class="min-h-full">
    <Disclosure as="nav" class="bg-gray-800" v-slot="{ open }">
      <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <div class="flex items-center justify-between h-16">
          <div class="flex items-center">
            <div class="flex-shrink-0">
              <img class="h-8 w-8" src="https://tailwindui.com/img/logos/workflow-mark-indigo-500.svg" alt="Workflow" />
            </div>
            <div class="hidden md:block">
              <div class="ml-10 flex items-baseline space-x-4">
                <router-link v-for="item in navigation"
                :key="item.name"
                :to="item.to"
                :class="[
                    this.$route.name === item.to.name
                      ? 'text-white'
                      : 'text-gray-300 hover:bg-gray-700 hover:text-white',
                    'px-3 py-2 rounded-md text-sm font-medium',
                  ]">
                {{ item.name }}</router-link>
              </div>
            </div>
          </div>
          <div class="hidden md:block">
            <div class="ml-4 flex items-center md:ml-6">
              <button type="button" class="bg-gray-800 p-1 rounded-full text-gray-400 hover:text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-800 focus:ring-white">
                <span class="sr-only">View notifications</span>
                <BellIcon class="h-6 w-6" aria-hidden="true" />
              </button>

              <!-- Profile dropdown -->
              <Menu as="div" class="ml-3 relative">
                <div>
                  <MenuButton class="max-w-xs bg-gray-800 rounded-full flex items-center text-sm focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-800 focus:ring-white">
                    <span class="sr-only">Open user menu</span>
                    <img class="h-8 w-8 rounded-full" :src="user.imageUrl" alt="" />
                  </MenuButton>
                </div>
                <transition enter-active-class="transition ease-out duration-100" enter-from-class="transform opacity-0 scale-95" enter-to-class="transform opacity-100 scale-100" leave-active-class="transition ease-in duration-75" leave-from-class="transform opacity-100 scale-100" leave-to-class="transform opacity-0 scale-95">
                  <MenuItems class="origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg py-1 bg-white ring-1 ring-black ring-opacity-5 focus:outline-none">
                    <MenuItem  active-class="bg-gray-900 text-white">
                      <a
                      @click="logout"  :class="['block cursor-pointer  px-4 py-2 text-sm text-gray-700']">Sign out</a>
                    </MenuItem>
                  </MenuItems>
                </transition>
              </Menu>
            </div>
          </div>
          <div class="-mr-2 flex md:hidden">
            <!-- Mobile menu button -->
            <DisclosureButton class="bg-gray-800 inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-800 focus:ring-white">
              <span class="sr-only">Open main menu</span>
              <MenuIcon v-if="!open" class="block h-6 w-6" aria-hidden="true" />
              <XIcon v-else class="block h-6 w-6" aria-hidden="true" />
            </DisclosureButton>
          </div>
        </div>
      </div>

      <DisclosurePanel class="md:hidden">
        <div class="px-2 pt-2 pb-3 space-y-1 sm:px-3">

   <router-link
            v-for="item in navigation"
            :key="item.name"
            :to="item.to"
            active-class="bg-gray-900 text-white"
            :class="[
              this.$route.name === item.to.name
                ? 'text-white'
                : 'text-gray-300 hover:bg-gray-700 hover:text-white',
              'block px-3 py-2 rounded-md text-base font-medium',
            ]"
            >{{ item.name }}
          </router-link>
                </div>
        <div class="pt-4 pb-3 border-t border-gray-700">
          <div class="flex items-center px-5">
            <div class="flex-shrink-0">
              <img class="h-10 w-10 rounded-full" :src="user.imageUrl" alt="" />
            </div>
            <div class="ml-3">
              <div class="text-base font-medium leading-none text-white">{{ user.name }}</div>
              <div class="text-sm font-medium leading-none text-gray-400">{{ user.email }}</div>
            </div>
            <button type="button" class="ml-auto bg-gray-800 flex-shrink-0 p-1 rounded-full text-gray-400 hover:text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-800 focus:ring-white">
              <span class="sr-only">View notifications</span>
              <BellIcon class="h-6 w-6" aria-hidden="true" />
            </button>
          </div>
          <div class="mt-3 px-2 space-y-1">
            <DisclosureButton
            @click="logout"
            class="block px-3 py-2 rounded-md text-base cursor-pointer font-medium text-gray-400 hover:text-white hover:bg-gray-700">{{ item.name }}</DisclosureButton>
          </div>
        </div>
      </DisclosurePanel>
    </Disclosure>

    <router-view></router-view>
  </div>
</template>

<script>
import { Disclosure, DisclosureButton, DisclosurePanel, Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue'
import { BellIcon, MenuIcon, XIcon } from '@heroicons/vue/outline'
import { useStore } from 'vuex'
import {computed}  from 'vue'
import {useRouter } from 'vue-router'
const user = {
  name: 'Tom Cook',
  email: '[email protected]',
  imageUrl:
    'https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80',
}
const navigation = [
  { name: 'Dashboard',to : {name:'Dashboard'} },
  { name: 'Surveys', to : {name: 'Surveys'} },
]

export default {
  components: {
    Disclosure,
    DisclosureButton,
    DisclosurePanel,
    Menu,
    MenuButton,
    MenuItem,
    MenuItems,
    BellIcon,
    MenuIcon,
    XIcon,
  },
  setup() {

    const store = useStore();
    const router = useRouter();

    function logout() {
      store.dispatch("logout")
        .then(() => {
          router.push({
            name: "Login",
          });
        });
    }
    return {
      user : computed( () => store.state.user.data),
      navigation,
      logout
    }
  },
}
</script>

store / index.js


import {createStore} from 'vuex';
import axiosClient from '../axios';

const store = createStore({
    state: {
        user: {
            data: {},
            token: sessionStorage.getItem('TOKEN')
        }
    },
    getters: {},
    actions: {
      register({commit}, user) {
        axiosClient.defaults.headers.common['Authorization'] = `${access_token}`
        return axiosClient.post('/register', user)
          .then(({data}) => {
            commit('setUser', data);
            return data;
          })
      },
      login({commit}, user) {
        return axiosClient.post('/login', user)
          .then(({data}) => {
            commit('setUser', data);
            return data;
          })
      },
      logout({commit}) {
        return axiosClient.post('/logout')
          .then(response => {
            commit('logout')
            return response;
          })
      }
    },
    mutations: {
      logout: (state) => {
        state.user.token = null;
        state.user.data = {};
        sessionStorage.removeItem('TOKEN');
      },
      setUser: (state, userData) => {
        state.user.token = userData.token;
        state.user.data = userData.user;
        sessionStorage.setItem('TOKEN', userData.token);
      }
    },
    modules: {}
});

export default store;

how can i fix this issue ?

error loading the index.css file

I follow all each step to install vite, vue and tailwindcss; but when I run with the login template from tailwindcssui, I got this error:

In main.js I import the tailwinds.css
imagen

the tailwinds.css file has:
imagen

I wrote on tailwinds.config.js
imagen

in HelloWorld.vue component has:
imagen

And me error showed is:
imagen

What am I doing wrong?

Nothing happens on the page after registration

After filling in all the fields and clicking on the sign up button on the registration page, visually nothing happens. An error appears in the console.
Screenshot 2022-07-15 at 2 33 54 PM

However, the user is stored in the database
Screenshot 2022-07-15 at 2 34 43 PM

No images displayed

Wonderfull tutorial codeholic its been really helpful but iam facing a challenge displaying the images any assistance will be greatly appreciated
Capture

SurveyController not saving checkbox type answers.

Steps to reproduce:

  1. Clone and setup project.
  2. Create a survey with multiple options of type checkbox.
  3. Fill in the survey.
  4. View survey answers in database.

Result:

No answers for that type are being saved.

Thank you for an awesome tut on YT. I liked and subscribed. I watched the whole thing from scratch โค๏ธ Thanks for your time.

cannot npm run dev

Pre-bundling dependencies:
vue
(this will be run only when your dependencies or config have changed)
X [ERROR] Failed to write to output file: open C:...\laravel-vue-survey\vue\node_modules.vite\vue.js.map: The system cannot find the file specified.

X [ERROR] Failed to write to output file: open C:...\laravel-vue-survey\vue\node_modules.vite\vue.js: The system cannot find the file specified.

$ npm -v
8.3.1

$ node -v
v16.14.0

There is error when npm run dev, been searching for solution. but still got the same error..

After login -- Page not found (404)

I followed your instructions.. after getting the localhost:300 login and logging in i get a 404?

Please advise how to solve this?
Thank you

image
image

Cross origin resource sharing issue

Hi ๐Ÿ‘‹ theCodeholic, thanks for sharing a very helping content, I am currently running through an issue related to cross origin resource sharing, when I tried to create new survey, after implementing the code you, showed in the video, I have been having this same issue over and over for couple of weeks, I have tried different ways, just to see that I'm able to remove the errors, but all effort proved abortive, I don't know if you can help me on what to do to solve this problem, I would appreciate if you would drop a video, regarding this issue... Thanks alot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.