nafeeur10

nafeeur10

Member Since 2 Years Ago

Experience Points
15,920
Total
Experience

4,080 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
47
Lessons
Completed
Best Reply Awards
2
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 4
15,920 XP
Oct
19
1 day ago
Activity icon

Started a new Conversation Vee-Validate Gives "not Valid" Error Against "required" Error!!

I am using vee-validate to validate my Form. I am using this Basic Example. Error is giving Perfectly but gives "not valid" error against "required" error!!

In app.js:

import { ValidationObserver, ValidationProvider, extend } from 'vee-validate';
import * as rules from 'vee-validate/dist/rules';

Object.keys(rules).forEach(rule => {
    extend(rule, rules[rule]);
});

// Register Validation Provider globally
Vue.component('ValidationObserver', ValidationObserver);
Vue.component('ValidationProvider', ValidationProvider);

AddCategory.vue:

<ValidationProvider name="Category Name" rules="required|alpha" v-slot="{ errors }">
    <input 
           v-model="category_name" 
            type="text" 
            placeholder="T-Shirt"
     >
    <span>{{ errors[0] }}</span>
</ValidationProvider>

data:

data() {
    return {
         category_name: '',
    }
},
Oct
14
6 days ago
Activity icon

Started a new Conversation How To Inherit Main App In Laravel Module (L8)

I am using Laravel Module Package (https://github.com/nWidart/laravel-modules)

Suppose, I have....

--------------------------------------------------------------
			navbar
--------------------------------------------------------------

Content

I wan to fixed the layout like `layout.blade.php and want to extend it in Every Modules. For example, I have Category, Content in Navbar. While I will click on Category, Category Module will work.

I want to use Vue. So, how inertiajs will work here??

Sep
25
3 weeks ago
Activity icon

Started a new Conversation Where Is The App Id In Laravel 8 And Jetstream?

I have installed Laravel 8 and Jetstream.

Here is the code in app.js

require('./bootstrap');

import Vue from 'vue';

import { InertiaApp } from '@inertiajs/inertia-vue';
import { InertiaForm } from 'laravel-jetstream';
import PortalVue from 'portal-vue';

Vue.use(InertiaApp);
Vue.use(InertiaForm);
Vue.use(PortalVue);

const app = document.getElementById('app');

new Vue({
    render: (h) =>
        h(InertiaApp, {
            props: {
                initialPage: JSON.parse(app.dataset.page),
                resolveComponent: (name) => require(`./Pages/${name}`).default,
            },
        }),
}).$mount(app);

But I am not getting any app id. Can you help me where it is and from where it is starting?

Sep
21
4 weeks ago
Activity icon

Replied to Home View Is Not Showing In SPA Laravel Vue

@rahulk,

You are right.

Thanks a lot. :-)

Activity icon

Awarded Best Reply on Home View Is Not Showing In SPA Laravel Vue

Got the answer.

Vue.component('home', require('./components/views/Home.vue').default);
Activity icon

Replied to Home View Is Not Showing In SPA Laravel Vue

Got the answer.

Vue.component('home', require('./components/views/Home.vue').default);
Activity icon

Replied to Home View Is Not Showing In SPA Laravel Vue

@rahulk,

I want to load my Component in that position. Not <router-view />

Giving me an error:

[Vue warn]: Failed to mount component: template or render function not defined.

Activity icon

Replied to Home View Is Not Showing In SPA Laravel Vue

@gymdone,

Laravel Version 7.

@rahulk,

I know it will work. But I don't want to do like this.

Activity icon

Replied to Home View Is Not Showing In SPA Laravel Vue

@sinnbeck,

It's a mistake in posting!

Activity icon

Started a new Conversation Home View Is Not Showing In SPA Laravel Vue

welcom.blade.php

<link href="{{ asset('css/app.css') }}" rel="stylesheet" />
.....
<div class="content w-100" id="app"></div>
....
<script src="{{ asset('js/app.js') }}" defer></script>

web.php:

Route::get('/', function () {
    return view('welcome');
});

app.js

window.Vue = require('vue');
import router from './router/index'


const app = new Vue({
    el: '#app',
    router
});

router/index.js

import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

import Home from '../components/views/Home'
import Cart from '../components/cart/Index'

const routes = [
    { 
        path: '/', 
        component: Home,
        name: 'Home'
    }
]

const router = new VueRouter({
    routes // short for `routes: routes`
})

export default router

Home.vue

<div id="content">
                <router-view></router-view>
</div>

What is the problem?

Sep
17
1 month ago
Activity icon

Replied to How To Work With Separately In Laravel

@automica,

See the entire folder structure of the Theme

https://ibb.co/ZV0Z1q9

Activity icon

Replied to How To Work With Separately In Laravel

@automica,

I didn't add that folder. I have this structured solution.

Activity icon

Replied to How To Work With Separately In Laravel

@automica,

Actually that is not my Question. Please see my example image. Theme is another folder besides Laravel regular Folders. I am finding the way.

Activity icon

Replied to How To Work With Separately In Laravel

@automica,

Not only Two Themes actually. For building Large scale Solution I just need to know the better way. Suppose, If I divide the whole solution into two parts (For Example) like StoreFront and Admin.

All MVC codes of Storefront will stay there and All MVC codes of Admin will stay in Admin Folder.

Something like this.

Activity icon

Replied to How To Work With Separately In Laravel

@automica,

Thank you for your reply. Here is an Example. Where "Theme" is a Folder where all StoreFront Code is situated.

Activity icon

Started a new Conversation How To Work With Separately In Laravel

https://ibb.co/T8xsdWD

I want to work separately. Suppose, I want to build an E-Commerce. Storefront will be SPA and Admin will have Vendor and others system.

What will be the better approach to do this type of development?

Sep
07
1 month ago
Activity icon

Replied to CSRF Token Mismatch In Dropzone.js

@jlrdw,

I saw that. But it is not solving my problem.

Thanks

Activity icon

Started a new Conversation CSRF Token Mismatch In Dropzone.js

I am trying to do an Ajax Request. Here, the above problem is showing!!

Route.php

Route::post('vendor/delete-product-image','[email protected]');

HTML:

<form action="{{url('vendor/add-product-images')}}/{{$prod_img_id}}" 
	method="POST"  
	enctype="multipart/form-data" 
	class="dropzone dropzone-area"
	id="dpz-single-file-p1"
>
	@csrf
	<input type="hidden" name="fileDropzone1" />
</form>

Js:

Dropzone.options.dpzSingleFileP1 = {
  paramName: "fileDropzone1", // The name that will be used to transfer the file
  maxFiles: 1,
  addRemoveLinks: false,
  headers: {
	'X-CSRF-TOKEN': $('meta[name="token"]').attr('content')
  },
  previewTemplate: 
	`<div class="dz-preview dz-complete dz-image-preview">
		<div class="dz-image">
			<img
			data-dz-thumbnail
			style="height: 188px;width: 178px;"
			>
		</div>
		<div class="dz-details">
			<div class="dz-size" data-dz-size></div>
			<div class="dz-filename">
			<span data-dz-name></span>
			</div>
		</div>
		<div class="dz-progress">
			<span class="dz-upload" data-dz-uploadprogress></span>
		</div>
		<div class="dz-error-message">
			<span data-dz-errormessage></span>
		</div>
		<a class="dz-set-default bg-danger" href="javascript:undefined;" data-dz-remove>
			<i class="fa fa-times"></i>
		</a>
	</div>`,
	init: function () {
		this.on("maxfilesexceeded", function (file) {
			this.removeAllFiles();
			this.addFile(file);
		});
	},
	success: function( file, response ) {
		obj = JSON.parse(response);
		$(file.previewTemplate).append("<span class='filenameofdropzone'>" + obj.filename + "</span>");
		console.log(obj.filename);
	},	
	removedfile: function(file) {
		var server_file = $(file.previewTemplate).children('.filenameofdropzone').text();
		var name = server_file; 
		//console.log(file);
		
		$.ajax({
			type: 'POST',
			dataType: 'JSON',
			url: 'vendor/delete-product-image',
			data: { name: name },
			success: function(data){
				console.log('success: ' + data);
			}, error: function(error) {
				console.log('Error: ', error.data);
			}
		});
		var _ref;
		return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
	}
};
Activity icon

Started a new Conversation How To Control Dropzone In Laravel

I have declared a dropzone in my system.

<form action="{{url('vendor/add-product-images')}}/{{$prod_img_id}}" 
	method="POST"  
	enctype="multipart/form-data" 
	class="dropzone dropzone-area" 
	id="dpz-single-file-p1" 
>  
	{{ csrf_field() }}
</form>

It is uploading perfectly, but how will I confirm it is complete.

My code: But not Working!!

dpzSingleFileP1.on("complete", function(file) {
	alert("Complete");
	dpzSingleFileP1.removeFile(file);
});
Sep
04
1 month ago
Activity icon

Started a new Conversation OnClick Passing Data From Parent Component To Child Component In Vuejs

I want to pass the edited id to my Modal Child. But it is not working!!

<template>
  <div class="container">
    <div class="container">

    <category-modal @category-saved="categorySaved" :edit="editedItem" ref="categorymodal" />

    <div class="card mt-5">
      <div class="card-header">
        <div class="d-flex w-100">
          <h3>List of Category</h3>
          <button
            type="button" 
            class="btn btn-primary ml-auto"
            @click="showModal"
          >
          Add New Category
          </button>
        </div>
      </div>

      <div class="card-body">
        <table class="table">
          <thead class="table-active">
            <tr>
              <th scope="col">Category Title</th>
              <th scope="col">Actions</th>
            </tr>
          </thead>
          <tbody>
            <tr v-for="(category, n) in categoryList" :key="n">
              <td>{{ category }}</td>
              <td>
                <button class="btn btn-info btn-sm mr-2" @click="editCat(n)">Edit</button>
                <button class="btn btn-danger btn-sm" @click="removeCat(n)">Delete</button>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
    
  </div>
  </div>
</template>
<script>
import $ from 'jquery'
import CategoryModal from '../partials/CategoryModal'
export default {
  data() {
    return {
      categoryList: [],
      editedItem: null
    }
  },
  name: 'Post',
  components: {
    CategoryModal
  },
  methods: {
    showModal() {
      let element = this.$refs.categorymodal.$el
      $(element).modal('show')
    },

    removeCat(n) {
      this.categoryList.splice(n, 1);
      this.saveInLocalStorage();
    },

    categorySaved(value) {
      console.log("Category Saved: ", value);
      this.getCategory();
    },

    saveInLocalStorage() {
      // Save category in LocalStorage
      const parsedCategory = JSON.stringify(this.categoryList);
      localStorage.setItem('categories', parsedCategory);
    },

    editCat(n) {
      this.editedItem = n;
      console.log(this.editedItem);
      this.showModal();
    },

    getCategory() {
      if(localStorage.getItem('categories')) {
      try {
        this.categoryList = JSON.parse(localStorage.getItem('categories'));
      } catch(e) {
        localStorage.removeItem('categories');
      }
    }
    }
  },
  mounted() {
    this.getCategory();
  }
}
</script>

Child Modal:

<template id="category-modal">
    <div class="modal fade" id="categoryModalCenter" tabindex="-1" role="dialog" aria-labelledby="categoryModalCenterTitle" aria-hidden="true" ref="vuemodal">
      <div class="modal-dialog modal-dialog-centered" role="document">

        <form @submit.prevent="saveCategory" class="w-100">

          <div class="modal-content">
            <div class="modal-header">
              <h5 class="modal-title">{{ edit }}</h5>
              <h5 class="modal-title">{{ categoryModalTitle }}</h5>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body">
              
                  <div class="form-group">
                      <label for="categoryTitle">Category Title *</label>
                      <input type="text" class="form-control" placeholder="Enter Category Title" v-model="categoryTitle" required>
                  </div>
              
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
              <button type="button" class="btn btn-primary" @click.prevent="saveCategory">Save changes</button>
            </div>
          </div>

        </form>

      </div>
    </div>
</template>
<script>
import $ from 'jquery'
export default {
  props: ['edit'],
  data() {
      return {
          categoryModalTitle: 'Add Category',
          categoryData: [],
          categoryTitle: ''
      }
  },
  methods: {
    saveCategory() {

      // Store Category in Array
      if(!this.categoryTitle) {
        return;
      }

      this.categoryData.push(this.categoryTitle);
      this.categoryTitle = '';

      this.saveInLocalStorage();

      $("#categoryModalCenter").modal('hide');
    },

    saveInLocalStorage() {
      // Save category in LocalStorage
      const parsedCategory = JSON.stringify(this.categoryData);
      localStorage.setItem('categories', parsedCategory);
      this.$emit('category-saved', 1);
    },

    getCategory() {
      if(localStorage.getItem('categories')) {
        try {
          this.categoryData = JSON.parse(localStorage.getItem('categories'));
        } catch(e) {
          localStorage.removeItem('categories');
        }
      }
    }
  },

  mounted() {
    this.getCategory();
  },

  created() {
    console.log("Edit: ", this.edit);
  }
}
</script>

Aug
31
1 month ago
Activity icon

Replied to JSON String Data Button Click Is Not Working In Vuejs

@piljac1,

Okay. But we have to Find a way to solve this problem.

Activity icon

Started a new Conversation JSON String Data Button Click Is Not Working In Vuejs

"element": [
  {
   "value": "<button @click='changeTheme()' class='theme-link btn btn-light'>Default</button>",
   "class": "text-success"
  }
]

I have bind the JSON data with Vue Component like the below:

<p v-else v-html="element[0].value"></p>

Now, I am trying to call this method. But it's not firing!

methods: {
  changeTheme() {
     alert("Y");
  }
}
Activity icon

Replied to JSON Parsing: Vuejs

@bobbybouwmann,

<template>
    <div>
        <div v-for="(element, index) in elements" :class="element.element" :key="index">
            <div v-if="element.element==='img'">
                <img :src="'/icons/' + element.value">
            </div>
            <p v-else v-html="element.value"></p>
        </div>
    </div>

</template>

<script>

export default {
    props: ['elements'],
    methods: {
        changeTheme(self) {
            alert("Y");
        }
    }
}

</script>

This is my component and my JSON is given to the Question. I have just parsed the JSON in various Components.

Aug
29
1 month ago
Activity icon

Replied to JSON Parsing: Vuejs

@bobbybouwmann,

Yes. I have checked the Console. No Error. No Result.

Activity icon

Replied to JSON Parsing: Vuejs

@bobbybouwmann,

I want to pass the data-theme with changeTheme() method.

I have declared this method:

methods: {
        changeTheme(self) {
            alert("Y");
        }
}

But function is not calling. May be functions are conflicting with other buttons.

Activity icon

Replied to JSON Parsing: Vuejs

@bobbybouwmann,

Thank you.

Facing another problem is, The button @click="changeTheme(this)" is not working. I have changed the onclick to @click but it's not firing!!

Activity icon

Replied to JSON Parsing: Vuejs

@bobbybouwmann,

Thank you for your answer. Just I need a query.

Here element.element is the html element. I need to make this HTML element then I will put value to that element with element.value

Can you give me some instruction about it?

Aug
28
1 month ago
Activity icon

Started a new Conversation JSON Parsing: Vuejs

"elements":[
                  {
                     "element":".dyno-text",
                     "value":"This would not be in a real course. I just thought it might be useful/fun here.<br> <button type='button' onclick='changeTheme(this)' data-theme='sketchy' class='theme-link btn btn-light'>Sketchy</button><button type='button' onclick='changeTheme(this)' data-theme='simplex' class='theme-link btn btn-light'>Simplex</button><button type='button' onclick='changeTheme(this)' data-theme='spacelab' class='theme-link btn btn-light'>Spacelab</button><br><button type='button' onclick='changeTheme(this)' data-theme='united' class='theme-link btn btn-light'>United</button><button type='button' onclick='changeTheme(this)' data-theme='superhero' class='theme-link btn btn-light'>Superhero</button><button type='button' onclick='changeTheme(this)' data-theme='default' class='theme-link btn btn-light'>Default</button>",
                     "class":"text-success"
                  }
               ]

This is my json data. How will I parse this value to HTML. Is there any easiest way?

Aug
12
2 months ago
Activity icon

Replied to Column Not Found: 1054 Unknown Column '0' In 'where Clause'

@michaloravec You are the BEST Answer. I remembered your FIRST ANSWER. so didn't give Best Answer. However...........................

Activity icon

Replied to Column Not Found: 1054 Unknown Column '0' In 'where Clause'

@sinnbeck and @michaloravec both are Best Answer. But I think @sinnbeck answer is better to me. :-)

Activity icon

Replied to Column Not Found: 1054 Unknown Column '0' In 'where Clause'

@sinnbeck ,

Giving me Success but not updating my data!!!

Activity icon

Replied to Column Not Found: 1054 Unknown Column '0' In 'where Clause'

After that data is not updating!!!!!

try {

            $clientId = Auth::id();
            $idOftheRow = $request->id;
            $this->validate($request, [
                'name' => 'required',
                'image' => 'required',
                'email' => 'required',
                'phone_number' => 'required',
                'email' => ['required', 'email', Rule::unique('instructors')->where(function ($query) use ($clientId, $idOftheRow) {
                    $query->where('client_id', $clientId)->where('id', '<>', $idOftheRow);
                })],
            ]);


            //$data = $request->Instructor;

            $instructor = Instructor::find($request->id);
            $instructor->name = $request->name;
            $instructor->image = $request->image;
            $instructor->email = $request->email;
            $instructor->phone_number = $request->phone_number;
            $instructor->client_id = Auth::id();
            $instructor->save();
            return response()->json([
                'status' => 'success',
                'message' => 'Instructor Updated Successfully!'
            ]);

        } catch(ValidationException $exception) {
            return response()->json([
                'status' => 'error',
                'errors' => $exception->errors()
            ]);
        }
Activity icon

Started a new Conversation Column Not Found: 1054 Unknown Column '0' In 'where Clause'

I am trying to validate my data during update. A client will not be able to insert save email in the table and it will just check in the other field except his own..

$clientId = Auth::id();
$idOftheRow = $request->id;
$this->validate($request, [
        'name' => 'required',
        'image' => 'required',
        'email' => 'required',
        'phone_number' => 'required',
        'email' => ['required', 'email', Rule::unique('instructors')->where(function ($query) use ($clientId, $idOftheRow) {
             $query->where(
               ['client_id', '=', $clientId],
              ['id', '<>', $idOftheRow]
             );
      })],
]);

Giving me the above error. What is the problem with my Query?

Aug
10
2 months ago
Activity icon

Started a new Conversation How To Validate Two Combined Unique Column In Laravel Controller

What I want:

I have multiple Client. One client has multiple Customers. One customer can be customer of multiple Clients.

But one Client can't add same email

Suppose,

----------------------------------------------------------
Client ID                         Customer Email
----------------------------------------------------------
1.                                   [email protected]
2.                                   [email protected]
----------------------------------------------------------

But Client 1 will not be able to add again [email protected]

In my migration file, I gave them two columns in unique

Schema::create('customers', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('email');
            $table->integer('client_id');
            $table->unique(['client_id', 'email']);
            $table->timestamps();
 });

It is working.

But how will I validate this in Controller?

I have tried like this:

$this->validate($request, [
        'email' => 'required|email|unique:customers',
]);

But it is just checking the Email is Unique

How can I do that?

Activity icon

Replied to V-slot:no-data Is Not Showing Anything!

@bobbybouwmann,

But I don't know why my Table Header is absent and The message of NO Data is.

While NO DATA. There is no HEADER and Message also.

<v-data-table 
                    class="elevation-1"
                    :headers="customerHeaders"
                    :items="customers"
                    :footer-props="{
                      'items-per-page-options': [5, 10, 20, 25, 30, 40, 50, 100, -1]
                    }"
                    :items-per-page="25"
                    :loading = loader
                  >
                  <template v-slot:item.actions="{ item }">
                      <v-icon
                        small
                        class="mr-2"
                        @click="editItem(item)"
                      >
                        mdi-pencil
                      </v-icon>
                      <v-icon
                        small
                        @click="deleteItem(item)"
                      >
                        mdi-delete
                      </v-icon>
                  </template>

                  <template v-slot:no-data>
                    <v-btn color="primary" @click="initialize">Reset</v-btn>
                  </template>


</v-data-table>

Data Properties:

customerHeaders: [
          {
            text: 'Customer Name',
            value: 'customer_name',
          },
          { text: 'Company Name', value: 'company_name' },
          { text: 'Address', value: 'address' },
          { text: 'Email', value: 'email' },
          { text: 'Phone', value: 'phone' },
          { text: 'Actions', value: 'actions' },
],
customers: []

Strange Problem!!!

Aug
09
2 months ago
Activity icon

Started a new Conversation V-slot:no-data Is Not Showing Anything!

<template v-if="customers != null && customers.length > 0">
      <v-data-table 
          class="mb-4"
          :headers="customerHeaders"
          :items="customers"
          :items-per-page="15"
          :loading = loader
      >
      <template v-slot:no-data>
          <p>The Table is Empty. Please insert data with the above Button.</p>
      </template>
     </v-data-table>
</template>

While table is empty v-slot:no-data is not showing his message. What is the problem? There is no ERROR!

VUETIFY!

Activity icon

Replied to JSON Exception Is Taking To Login Page But Need To Show The Errors In Modal

@sinnbeck,

Console is giving me this ERROR! But taking me in Login page.

POST http://localhost:8000/api/data/user/storeCustomer 422 (Unprocessable Entity)
Activity icon

Replied to JSON Exception Is Taking To Login Page But Need To Show The Errors In Modal

use Illuminate\Validation\ValidationException;

I have import it.

And Validation is catching in Network tab.

Activity icon

Started a new Conversation JSON Exception Is Taking To Login Page But Need To Show The Errors In Modal

I am using Laravel and Vuejs. I want to Store Data in Database. I am validating my data like this:

try {
            
            $this->validate($request, [
                'customer_name' => 'required'
            ]);
    
            return response()->json([
                'status' => 'success',
                'msg'    => 'Okay',
            ], 200);
        }
        catch(ValidationException $exception) {
            return response()->json([
                'status' => 'error',
                'msg'    => 'Error',
                'errors' => $exception->errors(),
            ], 422);
        }

Exception is giving Correctly. But it's taking me to login page!!

Axios Request to do the action:

saveCustomerInDB(customer) {
        axios.post('/api/data/user/storeCustomer', 
        {
          customer_name: customer.customer_name

        }).then( (response) => {
            console.log(response);
        }).catch( (error) => {
            console.log("Error", error);
        });
 },

I just want to show the error. Not any redirection. How will I do that??

Aug
03
2 months ago
Activity icon

Started a new Conversation [Vue Warn]: Error In V-on Handler: "SyntaxError: Unexpected Token , In JSON At Position 76"

While I am trying to add this JSON data into Database then it is giving me the above Error!

var tax_setting = '{ "total_tax_settings":  { "charge_tax": ' + this.taxInfoRadioButton + 
	', "tax_settings" : [' +
	'{ "tax_name": ' + this.taxName + 
	', "tax_rate": ' + this.taxRate +
	', "tax_included_in_price": ' + this.taxIncludeInPrice + ' } ]}}';

Radio Button of this JSON:

<v-radio-group v-model="taxInfoRadioButton">
    <v-radio color="primary" label="Do not charge tax on purchases" value="1"></v-radio>
    <v-radio color="primary" label="Charge tax on purchase" value="2"></v-radio>
</v-radio-group>

data() {
  return {
     taxInfoRadioButton: '1'
  }
}

Text Field:

<v-text-field name="taxName" label="Tax Name" id="taxName" v-model="taxName"></v-text-field>
data() {
  return {
     taxName: ''
  }
}

Tax Rate is also same as above.

Select Option in JSON:

<v-select  hide-details v-bind:items="willTaxInclude"  v-model="taxIncludeInPrice"  label="Select"  single-line  menu-props="bottom" ></v-select>
data() {
  return {
     willTaxInclude: [
        { text: "Yes", value: 1 },
	{ text: "No", value: 0 }
    ],
    taxIncludeInPrice: '0',
  }
}
Aug
02
2 months ago
Activity icon

Replied to How To Store Array In DB: Array To String Conversion Error!

@sergiu17 ,

All are coming NULL in Database.

Activity icon

Started a new Conversation How To Store Array In DB: Array To String Conversion Error!

I want to store an array in my Database. But what will be the right approach?

I am trying like this:

var settings = {
	serial: 1,
	customer_payment_option: [
		cash=> this.cash,
		online=> this.online,
		bank_transfer=> this.bankTransfer
	]
}

Controller:

function save(Request $request) 
    {
        $obj= new Setting();
        $obj->setting_option_id = $request->settings['serial'];
        $obj->value = $request->settings['customer_payment_option'];

        $obj->save();

        return response()->json([
            'message' => 'Settings Added Successfully!'
        ]);
    }
Jul
30
2 months ago
Activity icon

Started a new Conversation Giving Me [Object Object] While Using Axios: Laravel + Vuejs

Trying to Delete an Item using Axios from Vuejs.

Axios.post('/api/data/user/deleteInstructors', {
    id: this.selectItemToDelete['id']
}).then((res) => {
   console.log('Deleted Successfully' + res);
}).catch((err) => {
    console.log("Something Wrong");
})

api.php

Route::post('/user/deleteInstructors', '[email protected]');

UserSettingController:

function deleteInstructors(Request $request) {
        return $request->all();
}
Jul
29
2 months ago
Activity icon

Started a new Conversation Getting [Object Object] For Axios Request.

I want to update my data with axios.

Axios.post('/api/data/user/updateInstructor', {
	id: editInstructor[index].id,
	name: editInstructor[index].name,
	email: editInstructor[index].email,
	phone_number: editInstructor[index].phone_number,
	country: editInstructor[index].country
	}).then((res)=>{
		console.log("Updated!" + res);
	}).catch((err)=>{
		console.log("Problem");
});

But while I am just return the $request it is giving me error!!

function instructorUpdate(Request $request) {
        return $request;
    }

This is giving Updated![object Object]. What is the problem?

Jul
27
2 months ago
Activity icon

Replied to How To Test Get Request Using Postman For Laravel API

@tykus,

You are correct. But after hitting your given url it is showing me the above Response:

"response": {
        "api_status": 0,
        "code": 400,
        "message": "Your HTTP method is not correct."
    }
Activity icon

Replied to How To Test Get Request Using Postman For Laravel API

@tykus,,

I got the URL. But it's giving me this Message in Postman:

"response": {
        "api_status": 0,
        "code": 400,
        "message": "Your HTTP method is not correct."
    }
Activity icon

Started a new Conversation How To Test Get Request Using Postman For Laravel API

I am new in Laravel API.

Route::group([
    'prefix' => 'data',
], function () {
    Route::get('stripeKeyStore', '[email protected]');
});

This is my api.php route.

public function stripeKeyStore()
{
      return "GET WORKING";
      //response()->json([$request->all()]);
}

This is the Function.

Now I am trying to Access this using Postman. But giving this Result!!!

https://ibb.co/1KLGsH6 Image of PostMan

Jul
25
2 months ago
Activity icon

Started a new Conversation Blocked By CORS Policy Is Not Solving! Laravel + Vuejs

Access to XMLHttpRequest at 'http://phplaravel-421708-1325291.cloudwaysapps.com/api/data/testimonials' from origin 'http://localhost:8000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I am using Laravel and Vuejs.

Getting the above ERROR!!

I have installed this package: https://github.com/spatie/laravel-cors#laravel

I have done before "Creating your own CORS profile"

In bootstrap/app.php

I added

header('Access-Control-Allow-Origin', '*');
header('Access-Control-Allow-Methods', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS');
header('Access-Control-Allow-Headers', 'Content-Type, Authorization');

But Still Problem has.... What I have to do now?