david001

david001

Member Since 3 Years Ago

Experience Points 9,980
Experience Level 2

20 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 2
Lessons
Completed
Best Reply Awards 1
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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.

17 Jul
1 day ago

david001 left a reply on Npm Error

silly mistake , Thanks @nakov for help

david001 left a reply on Npm Error

@nakov when i runnpm watch i didn't got any message. it does not compiled to css and js file

david001 started a new conversation Npm Error

I installed npm on Laravel 5.8 , but got following warning, Any idea about these warning. please help me


Ranj:blog ranje$ npm install

> [email protected] install /Users/ranjeetkarki/blog/node_modules/fsevents
> node install

node-pre-gyp WARN Using needle for node-pre-gyp https download 
[fsevents] Success: "/Users/ranjeetkarki/blog/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" is installed via remote

> [email protected] postinstall /Users/ranjeetkarki/blog/node_modules/core-js-pure
> node scripts/postinstall || echo "ignore"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

npm notice created a lockfile as package-lock.json. You should commit this file.
added 1072 packages from 499 contributors and audited 17142 packages in 29.956s
found 0 vulnerabilities

Ranj:blog ranjeetkarki$ npm watch

Usage: npm <command>

where <command> is one of:
    access, adduser, audit, bin, bugs, c, cache, ci, cit,
    completion, config, create, ddp, dedupe, deprecate,
    dist-tag, docs, doctor, edit, explore, get, help,
    help-search, hook, i, init, install, install-test, it, link,
    list, ln, login, logout, ls, outdated, owner, pack, ping,
    prefix, profile, prune, publish, rb, rebuild, repo, restart,
    root, run, run-script, s, se, search, set, shrinkwrap, star,
    stars, start, stop, t, team, test, token, tst, un,
    uninstall, unpublish, unstar, up, update, v, version, view,
    whoami

npm <command> -h  quick help on <command>
npm -l            display full usage info
npm help <term>   search for help on <term>
npm help npm      involved overview

Specify configs in the ini-formatted file:
    /Users/ranjeetkarki/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

[email protected] /usr/local/lib/node_modules/npm

david001 left a reply on Filter Based On Checkbox Clicked

@snapey i removed the array, but nothing happened

16 Jul
2 days ago

david001 left a reply on Filter Based On Checkbox Clicked

I have changed as you mentioned above, but still it's not working


<form action="{{route('filter')}}" method="GET"
>  

<div class="container">
    <div class="row">
        

         <div class="col-md-4">
            Search
        <input type="checkbox" name="category_id['samsung']" class="form-control" value="1" onChange="this.form.submit(){{ request()->filled('category_id.samsung') ? 'checked' :''}}">Samsung

        <input type="checkbox" name="category_id['android']" class="form-control" value="2"onChange="this.form.submit(){{ request()->filled('category_id.android') ? 'checked' :''}}" >Android

        <input type="checkbox" name="category_id['apple']" class="form-control" value="3" onChange="this.form.submit(){{ request()->filled('category_id.apple') ? 'checked' :''}}">Apple
        </div>
    </form>

my url is browser is: http://localhost:8000/?category_id%5B%27samsung%27%5D=1

the value is url is updated when i check another checkbox, actually i need to append it

david001 started a new conversation Filter

I want to filter the product based on user clicked checkbox. I want to append the checkbox value and show it in URL and filter products based on those value in URL. I used onChange="this.form.submit()" but everytime i check the checkbox it replaces old value with new in URL. How to append all these values and filter based on those values.


<h1>Filter category</h1>
<form action="{{route('search')}}" method="GET"
>  
      
  <input type="checkbox" name="category_id[]" class="form-control" value="1" onChange="this.form.submit()">Samsung

        <input type="checkbox" name="category_id[]" class="form-control" value="2"onChange="this.form.submit()" >Android

        <input type="checkbox" name="category_id[]" class="form-control" value="3" onChange="this.form.submit()">Apple
        </div>
    </form>

Route



Route::get('/','[email protected]');
Route::get('/','[email protected]')->name('filter');

controller:


 public function filter(Request $request){
        dd($request);
    }
14 Jul
4 days ago

david001 started a new conversation Filter Data By Checkbox

Hello developers, just wondering how can i convert below radio filter to checkbox filter. or any other way to filter data with checkbox. This code works perfectly but i need a filter through checkbox.

<!DOCTYPE html>
<html>
<head>
    <title> Web stores</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>

</head>
<body>
<div class="container" id="people">
    <div class="filter">
        <label><input type="radio" v-model="selectedCategory" value="All" /> All</label>
        <label><input type="radio" v-model="selectedCategory" value="Tech" /> Tech</label>
        <label><input type="radio" v-model="selectedCategory" value="Entertainment" /> Entertainment</label>
        <label><input type="radio" v-model="selectedCategory" value="Fictional" /> Fictional</label>

    </div>
    
    <ul class="people-list">
        <li v-for="person in filteredPeople">{{ person.name }}</li>
    </ul>
</div>

<script type="text/javascript">
    var app = new Vue({
    el:  "#people",
    data: {
        people: [
            { name: "Bill Gates", cat: "Tech" },
            { name: "Steve Jobs", cat: "Tech" },
            { name: "Jeff Bezos", cat: "Tech" },
            { name: "George Clooney", cat: "Entertainment" },
            { name: "Meryl Streep", cat: "Entertainment" },
            { name: "Amy Poehler", cat: "Entertainment" },
            { name: "Lady of Lórien", cat: "Fictional" },
            { name: "BB8", cat: "Fictional" },
            { name: "Michael Scott", cat: "Fictional" }
        ],
        selectedCategory: "All"
    },
    computed: {
        filteredPeople: function() {
            var app = this;
            var category = app.selectedCategory;
            //console.log(category);
            
            if(category === "All") {
                console.log(app.people);
                return app.people;
            } else {
                return app.people.filter(function(person) {
                    return person.cat === category;
                });
            }
        }
    }
});
</script>

Any help would be greatly appreciated.

28 Jun
2 weeks ago

david001 started a new conversation How To Remove Duplicate Data From Array

Hi, i have 3 queries and i used array_push() to push all three result in array for example:


$data = [ ];

$q1=Model::get()
array_push($data,$q1);

$q2=Model::get();
array_push($data,$q2);

$q3=Model::get();
array_push($data,$q3);

AND return $data gives following result


[
[
{
id: 1,
user_id: "14",
company_id: "6",
title: "Labore eum deleniti eum eaque dignissimos autem qui. Doloribus aperiam fuga quibusdam quia minus officia. Nulla nemo omnis fugiat tempore. Eos voluptates odio qui omnis repudiandae nulla.",
slug: "labore-eum-deleniti-eum-eaque-dignissimos-autem-qui-doloribus-aperiam-fuga-quibusdam-quia-minus-officia-nulla-nemo-omnis-fugiat-tempore-eos-voluptates-odio-qui-omnis-repudiandae-nulla",
description: "Qui ducimus vel commodi qui eaque. Totam placeat est et magni unde natus odit. Excepturi voluptate illum illo aut et rerum. Praesentium autem et magni cumque aut cumque debitis. Ad quidem est sed cumque. Et nemo rem non distinctio aperiam molestiae. Rerum quos nemo deserunt omnis vel architecto. Facilis quo ducimus officia consequatur. Est perferendis quod earum non vel ea.",
roles: "Asperiores ut consequatur non excepturi dicta saepe occaecati. Tempore et est ab alias voluptatem temporibus aut sit. Omnis autem aut rerum ullam est hic. Aut reprehenderit consequatur nisi a.",
category_id: 5,
position: "Pile-Driver Operator",
address: "813 Predovic Causeway Suite 699 Bodefort, AZ 84414-5340",
type: "fulltime",
status: 1,
last_date: "2019-08-13",
created_at: "2019-06-24 03:57:46",
updated_at: "2019-06-24 03:57:46",
number_of_vacancy: 6,
experience: 9,
gender: "male",
salary: "33537"
},
{
id: 4,
user_id: "5",
company_id: "10",
title: "Quis magni aliquid illum. Qui pariatur nisi corrupti maiores autem tempore. Nobis fugiat optio incidunt et dolorum. Amet eligendi ab non atque est.",
slug: "quis-magni-aliquid-illum-qui-pariatur-nisi-corrupti-maiores-autem-tempore-nobis-fugiat-optio-incidunt-et-dolorum-amet-eligendi-ab-non-atque-est",
description: "Ad similique quas inventore eum et delectus tempora. Perferendis fugiat voluptas quia voluptates sint eum libero repellat. Mollitia placeat alias similique. Quo quam dignissimos adipisci sint. Odit labore consequuntur saepe aut facilis sint iure.",
roles: "Voluptate vitae sed aliquam illo est. Beatae molestiae rem aut quas error sint ipsam ut. Iusto quae commodi et.",
category_id: 5,
position: "Stonemason",
address: "145 Velda Roads Apt. 687 Lake Jadon, AK 76310-7608",
type: "fulltime",
status: 0,
last_date: "2019-09-15",
created_at: "2019-06-24 03:57:46",
updated_at: "2019-06-24 03:57:46",
number_of_vacancy: 1,
experience: 8,
gender: "female",
salary: "22531"
}
],
[
{
id: 4,
user_id: "5",
company_id: "10",
title: "Quis magni aliquid illum. Qui pariatur nisi corrupti maiores autem tempore. Nobis fugiat optio incidunt et dolorum. Amet eligendi ab non atque est.",
slug: "quis-magni-aliquid-illum-qui-pariatur-nisi-corrupti-maiores-autem-tempore-nobis-fugiat-optio-incidunt-et-dolorum-amet-eligendi-ab-non-atque-est",
description: "Ad similique quas inventore eum et delectus tempora. Perferendis fugiat voluptas quia voluptates sint eum libero repellat. Mollitia placeat alias similique. Quo quam dignissimos adipisci sint. Odit labore consequuntur saepe aut facilis sint iure.",
roles: "Voluptate vitae sed aliquam illo est. Beatae molestiae rem aut quas error sint ipsam ut. Iusto quae commodi et.",
category_id: 5,
position: "Stonemason",
address: "145 Velda Roads Apt. 687 Lake Jadon, AK 76310-7608",
type: "fulltime",
status: 0,
last_date: "2019-09-15",
created_at: "2019-06-24 03:57:46",
updated_at: "2019-06-24 03:57:46",
number_of_vacancy: 1,
experience: 8,
gender: "female",
salary: "22531"
},
{
id: 9,
user_id: "4",
company_id: "10",
title: "Iste sequi perferendis repudiandae nihil. Veniam in consequuntur quo est dolorem aut. Deleniti ullam repellat numquam repudiandae qui repellat. Quis et nisi dignissimos inventore.",
slug: "iste-sequi-perferendis-repudiandae-nihil-veniam-in-consequuntur-quo-est-dolorem-aut-deleniti-ullam-repellat-numquam-repudiandae-qui-repellat-quis-et-nisi-dignissimos-inventore",
description: "Voluptas voluptatum vitae id ea sit dolores voluptatibus. Ipsa similique dignissimos dolorum consequatur dolor commodi. Odio enim quam ea earum dolorem natus non. Non recusandae velit nulla sunt possimus consequuntur.",
roles: "Nam quo sed est qui quia aliquid aliquid. Consequatur enim fuga autem a sunt. Sed molestias dolor tempora quasi accusamus minus et. Vel iure temporibus architecto.",
category_id: 5,
position: "Terrazzo Workes and Finisher",
address: "215 Juliana Pines Champlinside, MN 44728",
type: "fulltime",
status: 1,
last_date: "2019-09-15",
created_at: "2019-06-24 03:57:46",
updated_at: "2019-06-24 03:57:46",
number_of_vacancy: 10,
experience: 6,
gender: "male",
salary: "13582"
}
],
[
{
id: 1,
user_id: "14",
company_id: "6",
title: "Labore eum deleniti eum eaque dignissimos autem qui. Doloribus aperiam fuga quibusdam quia minus officia. Nulla nemo omnis fugiat tempore. Eos voluptates odio qui omnis repudiandae nulla.",
slug: "labore-eum-deleniti-eum-eaque-dignissimos-autem-qui-doloribus-aperiam-fuga-quibusdam-quia-minus-officia-nulla-nemo-omnis-fugiat-tempore-eos-voluptates-odio-qui-omnis-repudiandae-nulla",
description: "Qui ducimus vel commodi qui eaque. Totam placeat est et magni unde natus odit. Excepturi voluptate illum illo aut et rerum. Praesentium autem et magni cumque aut cumque debitis. Ad quidem est sed cumque. Et nemo rem non distinctio aperiam molestiae. Rerum quos nemo deserunt omnis vel architecto. Facilis quo ducimus officia consequatur. Est perferendis quod earum non vel ea.",
roles: "Asperiores ut consequatur non excepturi dicta saepe occaecati. Tempore et est ab alias voluptatem temporibus aut sit. Omnis autem aut rerum ullam est hic. Aut reprehenderit consequatur nisi a.",
category_id: 5,
position: "Pile-Driver Operator",
address: "813 Predovic Causeway Suite 699 Bodefort, AZ 84414-5340",
type: "fulltime",
status: 1,
last_date: "2019-08-13",
created_at: "2019-06-24 03:57:46",
updated_at: "2019-06-24 03:57:46",
number_of_vacancy: 6,
experience: 9,
gender: "male",
salary: "33537"
}
]
]

I used array_unique , but its not working. i can't filter array. i can't remove duplicate data in array. Please help me. Thanks

14 Jun
1 month ago

david001 started a new conversation Search Is Not Working Laravel 5.8

Hi, i have a multiple filed such as search by title, category,address and i used orWhere But each time i submit button i get same result even if i change value.

form

<form action="{{('route('search')}}" method="Get">
<input type ="text" name="title>
<select class="form-control" name="category">
                    <option value="">-select-</option>
                    <option value="fashion">fashion</option>
                    <option value="entertainment">entertainment</option>
                 
                </select>
<input type ="text" name="address>
            <button type="submit" class="btn btn-outline-success">Search</button>


</form>

and code is


    public function index(Request $request){
        
       $keyword = $request->get('title');
       $category = $request->get('category');
       $address = $request->get('address');
     
       if($keyword||$category||$address){
        $posts = Post::where('title','LIKE','%'.$keyword.'%')
                ->orWhere('address',$address)
                ->orWhere('category',$category)
                
                ->paginate(5);
                return view('home',compact('posts'));
       }else{

            $posts = Post::paginate(5);
            return view('home',compact('posts'));
    }

for example '; i don't have fashion in database and when i choose fashion and submit button still it shows the result. What's wrong here? Please help me. Thanks

21 May
1 month ago

david001 left a reply on Send Email Verification Link For Custom Registration

@GRENADECX - i do not want to customize verifcation process, just want to know how to send verification link for above code. The Registercontroller.php inside Auth folder sends verification link, as like that how can i make this code to send verification link

david001 started a new conversation Send Email Verification Link For Custom Registration

How can i send email verification link for custom registration in laravel 5.8 I have two type of users , so for one type of user i used default registration system and i did some mailtrap setup and it sends email verification link. it's all right

for second type of user, i have made a custom registration and it has different registration form and controller. controller code is given below

ClientregisterController.php

public function clientRegister(){ $user = User::create([ 'email' => request('email'), 'password' => Hash::make(request('password')), 'user_type' => request('user_type'), ]); Profile::create([ 'user_id' => $user->id,

        ]);

//now i need to send email verification link

Please help me to solve this problem. Thanks

30 Mar
3 months ago

david001 left a reply on How To Toggle Buton

Thanks it is working now, i marked it as best answer

david001 left a reply on How To Toggle Buton

@ftiersch everything is ok, but after success, one button need to be hidden and another button need to be displayed, which in my case is not working

david001 left a reply on How To Toggle Buton

yes i did

david001 left a reply on How To Toggle Buton

This button should be displayed after i click Application Completed

but it wont display

29 Mar
3 months ago

david001 started a new conversation How To Toggle Buton

I have two button , one is complete button and another is completed button , as soon as complete button is clicked and data is successfully send i want to display completed button and hide complete button. I am new to vue js , i need help. please help me.


<template>
    <div>
        <form
 @submit="formSubmit"> 
            <button v-if="show" type="submit" class="btn btn-success" style="width: 100%;">Complete</button>

            <button v-else type="submit" class="btn btn-outline-success" style="width: 100%;">Application Completed</button>
        </form>
    </div>
</template>

<script>
    export default {
        props:["id"],

        mounted() {
            console.log('Component mounted.')
        },

        data() {
            return {
                'show':true,
              
            };
        },
        methods: {
            formSubmit(e) {
                e.preventDefault();
                let currentObj = this;
                axios.post('/order/'+ this.id, {

                })
                .then(function (response) {
                    console.log(response);

                                this.show == false;// this is not working after success  another button(completed button) need to be display and complete button need to be hidden

                   alert('success');
                })
                .catch(function (error) {
                    
                    alert('error');
                });
            }
        }
    
    }
</script>
02 Mar
4 months ago

david001 started a new conversation Npm ERR! A Complete Log Of This Run Can Be Found In:

I have installed vue js in Laravel5.7 but when i run nmp run watch i got this errror


npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/devo/.npm/_logs/2019-03-02T05_28_54_802Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 2
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I'm using Mac

How can i slove this error, please help me
14 Jan
6 months ago

david001 left a reply on Vuejs Filter With Checkbox

@burlresearch Thank you very much

david001 left a reply on Vuejs Filter With Checkbox

i tried in this way but still not any output computed: { displayChoosen(){

        for( i=0; i<this.items.length; i++){
            //console.log(this.items[i]);
            if(this.items[i].name==this.selected){
                return this.items[i]

            }
        }
        
    }

}

13 Jan
6 months ago

david001 started a new conversation Vuejs Filter With Checkbox

Hi, i want to filter the certain products based on whether checkbox is clicked or not. i have three category, animal, fruit and clothes. if user checked only animal it should display animal on the page. if user clicked animal and fruit, it should filter only animals and fruits .But i don't know how to implement this.

index.html

<div id="app">

    <table class="table table-striped table-hover">
        <thead>
            <tr>
                <th>
                    <label class="form-checkbox">
  
<h3>Choose the category</h3>
                        <input type="checkbox" value="animal" v-model="selected">animal
                        <input type="checkbox" value="fruit" v-model="selected">fruit
                        <input type="checkbox" value="clothes" v-model="selected">clothes

  </label>
                </th>
                <th>id</th>
                <th>name</th>
                <th>description</th>
                <th>Category</th>
            </tr>
        </thead>
        <tbody>

            <tr v-for="i in items">
                <td>
                    <label class="form-checkbox">


                    <i class="form-icon"></i>
                    </label>
                </td>
                <td>{{i.id}}</td>
                <td>{{i.name}}</td>
                <td>{{i.description}}</td>
                <td>{{i.category}}</td>
            </tr>

        </tbody>
    </table>
    You have choosen:{{selected}}
</div>

<style>
body{
    padding: 50px
}
</style>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script>

new Vue({
    el: "#app",
    data: () => ({
        items: [
            {
                id: "1",
                name: "apple",
                description: "description about product",
                category:'fruit'
            },
            {
                id: "2",
                name: "mango",
                description: "description about product",
                category:'fruit'
            },
            {
                id: "3",
                name: "shoes",
                description: "description about product",
                category:'footwear'
            },
            {
                id: "4",
                name: "shirt",
                description: "description about product",
                category:'clothes'
            },
            {
                id: "5",
                name: "dog",
                description: "description about product",
                category:'animal'
            },
            {
                id: "6",
                name: "cat",
                description: "description about product",
                category:'animal'
            }
        ],
        selected: [],
        

    }),
    computed: {
        displayChoosen(){
            
        }
        
    }
    
});
</script>
02 Dec
7 months ago

david001 left a reply on Push Is Not A Function Vuejs

@mortens /list endpoints results like this [ { id: 1, name: "apple", description: "Quasi eaque autem quos. Quod sit perferendis quia debitis blanditiis. Repellat nulla sint iusto voluptatum voluptas accusamus explicabo iusto. Molestiae sunt consequatur ipsa velit molestiae perspiciatis sint.", price: 46, qty: 1, is_available: 1, created_at: "2018-11-04 01:11:29", updated_at: "2018-11-04 01:11:29" }, { id: 2, name: "mango", description: "Sed necessitatibus voluptatem culpa eos dolore nemo. Aspernatur consectetur distinctio in explicabo libero quo. Et reprehenderit sit qui corporis. Perferendis aut dolor est adipisci.", price: 27, qty: 1, is_available: 1, created_at: "2018-11-04 01:11:29", updated_at: "2018-11-04 01:11:29" } ]

david001 left a reply on Push Is Not A Function Vuejs

On first button clicked it gives error ,push is not a function. After first button clicked if I refresh the page it shows one product on page and If i click the button again to add more products it won't show that error ,it display products added to cart on the page.

david001 started a new conversation Push Is Not A Function Vuejs

I am getting a error, push is not a function when i clicked a add to cart button. please help me

productlist.vue

<template>
    <div class="col-md-7">
        

<div class="card" style="width: 18rem;">
  <div class="card-body">
    <h5 class="card-title">{{ product.name }}</h5>
    <p class="card-text">{{ product.price }}


    </p>
    
    <button class="btn btn-primary" @click="addProductToCart(product)">Add to cart</button>
  </div>
</div>

    </div>
</template>

<script type="text/javascript">
    export default{
        props:['product'],
        data(){
            return{
                lists:[],
                session:[]

            }
        },
        mounted(){

            axios.get('/list')
            .then((response)=>{
            this.lists= response.data
            });
        },
        methods:{
            addProductToCart(product){
                
                axios.post('/products/create',{
        
                    product : product
                }).then((response)=>{
                console.log(response)
                this.$emit('addedToCart',product)

            

            });
                
            }
        }
    }
</script>

cart.vue

<template>
    <div class="col-md-4">
        <li v-for="(item,index) in cart">
            {{ item.name }}-{{ item.price }}
            <button @click="removeitem(index)">Remove</button>
        </li>
    
    </div>
</template>

<script type="text/javascript">
    export default{
        props:['cart'],
        
        }
</script>

Main.vue

<template>
    <div>
        <div class="col-md-7" v-for="product in products">
            <Productlist :product="product" @addedToCart="addedToCart"></Productlist>
        </div>
        <Cart :cart="cart" ></Cart>
    </div>
</template>

<script type="text/javascript">
import Productlist from './Productlist';
import Cart from './Cart';

    export default{
        data(){
            return{
                products:[],
                cart: [ ]
            }
        },
        mounted() { 
//get all products and show in page
            axios.get('/products')
            .then((response)=>{
                this.products = response.data;
            });
// get only those products that are added to cart
            axios.get('/list')
            .then((response)=>{
                this.cart= response.data;
                console.log(response)
            });
        },
        methods:{
            addedToCart(product){
                
                
                this.cart.push(product)
            }
        },
        components:{Productlist,Cart}
    }
</script>
01 Dec
7 months ago

david001 left a reply on How To Install Vuex

What I do now? Do I need to make package.json file? Please help..

david001 started a new conversation How To Install Vuex

I installed vue cli and i tried to install vuex using npm npm install vuex --save it throws the following error. please help me to install vuex

npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\admin\Deskt
op\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\admin\Desktop\
package.json'
npm WARN Desktop No description
npm WARN Desktop No repository field.
npm WARN Desktop No README data
npm WARN Desktop No license field.

+ [email protected]
updated 1 package and audited 2 packages in 2.792s
found 0 vulnerabilities


C:\Users\admin\Desktop\vuexlearn>
26 Nov
7 months ago

david001 left a reply on How To Add Items In Session Vue Js And Laravel

@SIGNAR - I tried

    public function StoreInCart(Request $request){
      
         session(['product' => $request->product]);

         return session('product');
    }

    public function getProduct(Request $request){
//I visited this route- returns only one items though i addded many items in cart
        $product = \Session::get('product');
         return $product;
    }

After i clicked the add to cart button for many item and i visited /list route i got only one item but it should show all items stored in Session, not only one.

david001 left a reply on How To Add Items In Session Vue Js And Laravel

@AHMEDDABAK - i didn't got error, but i got empty array [ ], no items stored in session

25 Nov
7 months ago

david001 started a new conversation Get Data Without Page Refresh

I am not getting the data without page refresh. Whats wrong in my code please let me know. my data is saved in database without page refresh but its not shown in page without page refresh, i want to display without page refresh

I have 3 component , Timeline,vue, post.vue and PostForm.vue

Timeline.vue

<template>
    <div>
        
        <PostForm @postAdded="postAdded"></PostForm>

    
            <Post :posts="posts"></Post>
    
    </div>
</template>

<script type="text/javascript">
import Post from './Post';
import PostForm from './PostForm';
export default{
    data(){
        return{
            posts:[]
        }
    },
    mounted(){
            
                axios.get('/posts')
                .then(response=>this.posts=response.data);
            
        },
        components:{Post,PostForm},

        methods:{
            postAdded(post){
                this.posts.push(post)
            }
        }
}
</script>

PostFrom.vue

<template>
    <div>
        <form action="#" class="form-vertical">
            <div class="form-group">
                <textarea v-model="body" class="form-control" cols="10" rows="1"></textarea>
            </div>
            <div class="form-group">
                <button type="submit" @click="post"class="btn btn-primary">Save</button>
            </div>
        </form>
    </div>
</template>
<script type="text/javascript">
    export default{
        data(){
            return{
                body:''

            }
        },
        methods:{
            post(e){
                e.preventDefault(e)
                axios.post('/post-data',{body:this.body})
                    .then((response)=>{
                        this.$emit('postAdded', this.body)
                        this.body=''
                    });
            }
        }
    }
</script>

Post.vue

<template>
    <div class="media">
        <div class="media-left">
        </div>
        <div class="media-right">
            <p v-for="post in posts">
                {{ post.body }}
            </p>
        </div>
    </div>
</template>
<script type="text/javascript">
    export default{
        props:['posts']

    }
</script>
<style scoped>
    img {
    vertical-align: middle;
    border-style: none;
    padding-right: 10px;
}
</style>

controller:

public function post(){
        return view('post');
    }

    public function index(Request $request, Post $post)
    {
        return $post->with(['user'])->get();
    }

    public function store(Request $request)
    {
        $this->validate($request, [
            'body' => 'required'
        ]);

        $post = $request->user()->posts()->create([
            'body' => $request->body
        ]);

      //  broadcast(new PostWasCreated($post))->toOthers();

        return $post;
    }
24 Nov
7 months ago

david001 started a new conversation How To Add Items In Session Vue Js And Laravel

I want to store items in cart with laravel session and sending selected items from vue js to laravel and display them back in the page. Here i want to display the lists, but i got nothing. I want get the session items

{{ product.name }}

Some quick example text to build on the card title and make up the bulk of the card's content.

{{ lists }}//

<button class="btn btn-primary" @click="addProductToCart(product)">Add to cart</button>
</div>

<script type="text/javascript">
    export default{
        props:['product'],
        data(){
            return{
                lists:[],

            }
        },
        mounted(){
                        
            axios.get('/list')
            .then((response)=>{
            this.lists= response.data
            });
        },
        methods:{
            addProductToCart(product){
                
                axios.get('/store-in-cart',{
                    
                    product : product
                }).then((response)=>{
                console.log(response)
            });;
            
            }
        }
    }
</script>;

controller

public function StoreInCart(Request $request){
       $products = \Session::put('product',$request->product);
        return $products;
    }
    public function getProduct(Request $request){
        $product = \Session::get('product');
         return $product;
    }
28 Feb
1 year ago

david001 left a reply on Vue Component Not Displayed:Laravel5.4 And Vue.js2

restart server again and run npm run watch

11 Feb
1 year ago
10 Feb
1 year ago

david001 started a new conversation Communications Between Siblings (Vue+Laravel Form)

I have send statusand user_id as a props form parent to one sibling. Now i want to transfer samething to another sibling.

I Have simple 3 multistep form:form1, form2 and form3 In form1 i have login information,form2 consist personal information and form3 has career information.

i have 3 tables namely users to insert login information from form1, profiles table to store personal information from form2 and careers table to store careeer information.

In first step after completion of form1,i will grab his email,find id(user_id)last inserted id,hide form1, pass form2 status(true status) and user_id to form2 as props.

In step2 now form1 and form3 is hidden,form2 is display. Now i can save form2 information because i have user_id as props and my form2 status is true.

problem:After completion of form2, my form3 should be displayed.so i have to pass form3 status(true status) and user_id after successfull insertion of form2 data,probably raising an event. I did but my form3 is not displayed after form2 completion.

My first component is Employee.vue consist login information, 2nd is Employee2.vue consist personal info,3rd is Employee3.vue consist career info.

in index.blade.php i have

 <employee>     </employee>//first form

Employee.vue

<template>
    
//SENDING DATA to FORM2(employee2)
    <employee2 :form2="form2" :user_id="user_id" "></employee2>


    <form action="#" id="loginInfo" v-if="form1">
    

       <div class="form-group">
            <label for="username">Username:</label>
            <input type="text" name="username" v-model="loginUserInfo.username" class="form-control">
            <p v-if="error.username">
                <span v-for="err in error.username" class="label label-danger">{{ err }}
                </span>
        </p>
            
        </div>
        <div class="form-group">
            <label for="email">Email:</label>
            <input type="text" name="email" v-model="loginUserInfo.email" class="form-control">
            <p v-if="error.email">
                <span v-for="err in error.email" class="label label-danger">{{ err }}
            </span>
            </p>
        </div>
        <div class="form-group">
            <label for="password">Password:</label>
            <input type="password" name="password" v-model="loginUserInfo.password" class="form-control">
            <p v-if="error.password" class="list-unstyled">
                <span v-for="err in error.password" class="label label-danger">{{ err }}</span>
            </p>
        </div>
        <div class="form-group">
            <button type="submit" class="btn btn-success"@click.prevent="loginInfo">Continue</button>
        </div>
    </form>

    
    


        
    </div>
    <!--end of col-md-8-->

</template>


<script>
    export default{
        data(){
            return{
                error:[],
                
                success:false,
                form1:true,
                form2:false,
                form3:false,

                loginUserInfo:
                {
                    username:'',
                    email:'',
                    password:'',
                },
                
                user_id:'',

            
            }
        },
        methods:{
                loginInfo()
                {
                    axios.post('/employee/create',this.loginUserInfo)
                        .then((response)=>{
                            console.log(response.data);
                            this.user_id =  response.data;
                            this.form1 = false;//disaplying form1
                            this.form2 = true;//enabling form2

                            

                    }).catch(error=>{
                        this.error = error.response.data
                    });
                },

            }


    }
</script>

form2

Employee2.vue



<!--Form2-->
<template>


    <form action="#"  v-if="form2">

        
        <h1>Personal Information</h1>
        <small>The field marked with * refers to required information!</small>

        <div class="form-group">
            <div class="col-md-4">
            <label>First name *:</label>
                <input type="text" name="first_name" v-model="personalInfo.first_name" class="form-control">
                <p v-if="error.first_name" class="list-unstyled">
                    <span v-for="err in error.first_name" class="label label-danger">{{ err }}</span>
                </p>
            </div>
        </div>

            //..................

    <div class="form-group">
    
        <button class="btn btn-success" @click.prevent="personalInfoCreate">Continue</button>
    </div>

</form>

</template>
<script>
import Bus from '../../bus.js'
    export default{

        props:['form2','user_id'],
        data(){
            return{
                error:[],
                
                success:false,
            //  form3:false,
                
            

                
                personalInfo:
                {
                    first_name:'',
                    
                },
                

            }
        },
        methods:{
                
            personalInfoCreate(){

                axios.post('/employee/personalInfo/create/' + this.user_id,this.personalInfo) 
                       .then((response) => {
                    console.log(response)
                    this.form2 = false;//disabling form2
                    
                       this.form3 = true;//enabling form3

                    Bus.$emit('form3',this.form3)  //passing form3 status as event 

                 }).catch(error=>{
                    this.error = error.response.data
                 });
            },
            }


    }
</script>

Form3:

Employee3.vue
<template>
    <!--form3-->

      <form action="#" " v-if="form3">

        <div class="form-group">
            <label>Career Plan*</label>
            <textarea class="form-control" v-model="career.career_plan"></textarea>
        </div>

        

        <div class="form-group">
            <button type="submit" class="btn btn-success" @click.prevent="careerInfo">Continue</button>
        </div>


      </form>       

</template>
    
<script>
import Bus from '../../bus.js'

    export default{
        
        data(){
            return{
                error:[],
                
                
            
                career:
                {
                    career_plan:'',
                    
                }
            }
        },
        methods:{
                
        

            careerInfo() {
                
            },
            created(){
                    Bus.$on('form3',(data)=>{
                        this.form3=data;  // to enable form3 after completion of form2
                        
                    })
                }



    }
</script>

I havebus.jsin Components directory

import Vue from 'vue'

export default new Vue()

My question is how can i pass form3 status(true) and user_id from Employee2.vue(form2) to Employee3.vue(form3). I did like above it worked upto Employee2.vue but after completion of form2(Employee2.vue) form3 is not shown/invisible.

david001 left a reply on Simple Multistep Form

i have done something like that and it works fine.but i want to go in abit advance level. i pass form2 status(true) and user_id to from2 after completion of form1, it worked and again i emit event after successfull insertion of form2 data in db. I only emitted form3 status(true) from form2. But my form3 never displayed after form2

in index.blade.php //component Thanks for your suggestions

david001 left a reply on Simple Multistep Form

@Borisu what iam trying to do is that. i want to send form2 status(true) and user_id as a props to form2,so that after completion of form1 it would display form2 and with user_id from props i can insert data in another table. Again from form2 to reach form3 i should pass form 3 status(true) to display form3 after completion of form2 and user_id as event. I made bus.js


import Vue from 'vue'

export default new Vue()

in form 2:

//after success of form2 insetion
//.........
import Bus from '../../bus.js'
axios.post('', {})
    .then(response => {
......
 this.form3 = true;
 Bus.$emit('displayform3',this.form3)

});

in form 3:to display form3

import Bus from '../../bus.js'
mounted() {
            
            console.log('Component mounted.')

            Bus.$on('displayform3',(data)=>{
                        console.log(data)
                        data = this.form3;
                        
                    })

        }

My problem:after completion of form2, my form3 is not displayed

09 Feb
1 year ago

david001 left a reply on Simple Multistep Form

@Borisu can you please give me an idea,how can i make three different components for three different form. do i have to use BUS/Event for that. I want to make my code cleaner with different components.

david001 left a reply on Simple Multistep Form

edited

07 Feb
1 year ago

david001 left a reply on Simple Multistep Form

i have posted full questions but only half code is displayed.i dont know why this is happening

david001 started a new conversation Simple Multistep Form

Route:

Route::post('employee/create','[email protected]');
Route::post('employee/personalInfo/create','[email protected]');
06 Feb
1 year ago

david001 left a reply on Validation Not Working

If i do this:

 $this->validate($request, [
                'name123' => 'required',
            ]);

name123 is not my html field. it detect and gives error name123 field not existin console. however is does not work for my actual field

 $this->validate($request, [
                'name' => 'required',
            ]);

<input type="text" name="name" v-model="userInfo.name">
            <input type="file" name="image"  v-on:change="onFileChange">
            <button type="submit" class="btn btn-success"@click.prevent="attachmentCreate">Upload</button>

david001 left a reply on Validation Not Working

Laravel 5.5

david001 left a reply on Validation Not Working

yes i tried ,but it gave error method validate does not exist

david001 left a reply on Validation Not Working

@wilk_randall @VijayKadiyam If i do this:

 $this->validate($request, [
                'name123' => 'required',
            ]);

name123 is not my html field. it detect and gives error name123 field not existin console. however is does not work for my actual field

 $this->validate($request, [
                'name' => 'required',
            ]);

<input type="text" name="name" v-model="userInfo.name">
            <input type="file" name="image"  v-on:change="onFileChange">
            <button type="submit" class="btn btn-success"@click.prevent="attachmentCreate">Upload</button>

david001 started a new conversation Validation Not Working

I am trying to display validation error with vue js in laravel app. But my method ignores validation rule. i don't know why this is happening.

controller:

public function postStudent(Request $request)
    {
         $this->validate($request,[
            'name' => 'required',  
            'image'=>'required' 
          
        ]);


       if($request->hasFile('image')){
            $uplodedFile = $request->image;
            $fileName = $uplodedFile->store('public/images');
       
        $student = new Student;
        $student->name = $request->name;
        $student->image = $fileName;
        $student->save();
    }
        return "ok";

        
    }

Student.vue

<template>
    <div>
    
            <input type="text" name="name" v-model="userInfo.name">

            <input type="file" name="image"  v-on:change="onFileChange">

        <button type="submit" class="btn btn success"@click.prevent="attachmentCreate">Upload</button>
    
</div>
</template>

<script>
export default{
    data(){
        return{
            error:[],

            userInfo:
            {
                image:null,
                name:null,
            }

        }
    },
    methods:{
        onFileChange(event){
            this.userInfo.image = event.target.files[0]

        },
        attachmentCreate() {
            const form = new FormData();
            form.append('image',this.userInfo.image);
            form.append('name',this.userInfo.name);

            

            axios.post('step-1',form)
                    .then((data)=>{
                console.log("ok")
               
                }).catch(error => {
                   
                            this.error = error.response.data;
                            console.log(this.error);
                       
                    
                })
            }
     
    }
}

</script>

if i submit the form without the input ,it should show some error message in console(ie:name field is required),but i am not getting any error. i got ok response only . Please help me to display error message

16 Jan
1 year ago

david001 started a new conversation Route Not Working: Page Not Found L5.5

I have just downloaded Laravel5.5 and i have some error with routes I have routes in web.php

//working routes Route::get('/', '[email protected]')->name('home'); Route::get('{slug}','[email protected]')->name('show');

//not working routes Route::get('/home', '[email protected]')->name('home'); // Route::get('pro','[email protected]')->name('pro');

Route::get('/test', function () { return "ok"; });//this is not workig

Auth::routes();

when i open /test instead of returning OK it giver error Sorry, the page you are looking for could not be found.

09 Jan
1 year ago

david001 started a new conversation How To Convert To Eloquent

my victims table has column district_id,incident_type_id etc my districts table has column name my incidents table has column incident_type

I have a Sql Query like this

Route::get('/total', function () {
    $users = \DB::table('victims')
                    ->join('districts','victims.district_id','=','districts.id')
                    ->join('incidents','victims.incident_type_id','=','incidents.id')
                     ->select('districts.name','incidents.incident_type',\DB::raw('count(*) as total'))
                     ->groupBy('district_id','incident_type_id')
                     ->orderBy('district_id','ASC')
                     //->having('total','>',1)
                     ->get();
                   //  dd($users);
    foreach($users as $user){
        echo 'total' .ucfirst($user->incident_type). 'case in district'.'&nbsp;'.$user->name.'is'. '&nbsp;'.$user->total
        .'</br>';
    }
});

//its output is
total Rape case in district A is 2
total Murder case in district A is 2
total Rape case  in district B is 1
total Rape case  in district cis 3

i want similar output . so i have relationship like this

Victim.php

class Victim extends Model
{
    

    public function district(){
        return $this->hasOne(District::class,'id','district_id');
    }
    public function incident(){
        return $this->hasOne(Incident::class,'id','incident_type_id');
    }
   
    
}

District.php

class District extends Model
{
   
}

Incident.php

class Incident extends Model
{
   
  
}

//Here i want similar out put as above,but its not working

Route::get('/total', function () {
    $users = Victim::withCount('district.incident')
          ->groupBy('district_id','incident_type_id')->get();

          foreach($users as $user){
            echo 'total' .$user->incident->incident_type. 'case in district'.'&nbsp;'.$user-
                            >district->name.'is'. '&nbsp;'.'total'
        .'</br>';
          }
         
});

I am not getting above output.How can i get output as above

08 Jan
1 year ago

david001 started a new conversation Middleware Protecting Routes

How to protect routes with middleware for following conditions

i have users table and roles table

users table id name email role_id

roles table

id          name          slug
1           admin         admin
2          student      student
3          teacher      teacher

In User.php

 public function role()
 {
         return $this->hasOne(Role::class,'id','role_id');
 }

RoleGate.php

<?php
 
namespace App\Http\Middleware;
 
use Closure;
 
class RoleGate
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next,$role)
    {
        if ($request->user() && $request->user()->role && $request->user()->role->slug === $role) {
                return $next($request);
         }
        return redirect('/login');
    }
}

Route:

//for student
 Route::middleware(['role:student'])->group(function () {
    Route::get('student',function(){
        return"student";
    });
});

//for teacher
 Route::middleware(['role:teacher'])->group(function () {
    Route::get('teacher',function(){
        return"teacher";
    });
});

//for admin
 Route::middleware(['role:admin'])->group(function () {
    Route::get('admin',function(){
        return"admin";
    });
});

This works fine but i want to make student and teacher route visible to admin.Admin can view all route

How can i modify my logic inside handle() method