Shiva

Shiva

Member Since 5 Years Ago

Experience Points
20,320
Total
Experience

4,680 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
0
Lessons
Completed
Best Reply Awards
0
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 5
20,320 XP
Jul
31
1 week ago
Activity icon

Replied to How To Get Vue Router To Go To Another Page

@maverickchan - cool I will look into that, but will that solve my problem because even if I change the path for example to my home page it still doesn't change

Jul
30
1 week ago
Activity icon

Replied to How To Get Vue Router To Go To Another Page

@maverickchan - but wouldn't it be called when I do this import Users from "../users/Users"; in my permissions.js

Activity icon

Replied to How To Get Vue Router To Go To Another Page

@topvillas - nope I don't get any errors

Activity icon

Started a new Conversation How To Get Vue Router To Go To Another Page

I have a laravel vue app and I'm trying to create a roles and permissions page that links to the users page.

The problem I'm having is that, when you're on the permissions page and you open up the users panel and you select a user and you decide you need to change their details and you click on their edit button and that should take you to the users page.

So far I've only managed to get the url to change but the page stays on the permissions page.

My permissions.vue

<template>
  <div>
    <h3>Users</h3>

    <div>
      <table>
        <thead>
          <tr>
            <th>Permission Name</th>
            <th style="width:240px;"></th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="permission in permissions">
            <td>{{permission.name}}</td>
            <td style="text-align: right;">
              <button class="btn btn-sm btn-outline-info" @click="users(permission)">
                Users
              </button>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</template>

<script>
  export default {
    props: ['emit', 'roles'],
    data() {
      return {

      }
    },
    computed: {

    },
    mounted() {

    },
    methods: {
      users(permission) {
        this.emit.$emit('edit-users', { permission: permission });
      }
    }
  }
</script>

this.emit.$emit('edit-users', { permission: permission }); then opens up the users panel on the permission page

<template>
  <div>
    <h3>Users in <strong>{{permission.name}}</strong></h3>

    <div>
      <table>
        <thead>
          <tr>
            <th>User</th>
            <th style="width:120px;"></th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="user in users">
            <td>{{user.name}}</td>
            <td style="text-align: right;">
              <button class="btn btn-sm btn-outline-info" @click="edit(user)">
                Edit
              </button>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</template>

<script>
  export default {
    props: ['emit', 'role'],
    data() {
      return {
        users: []
      }
    },
    computed: {

    },
    mounted() {
      this.getUsers();
    },
    watch: {

    },
    methods: {
      getUsers() {
        axios.get('/admin/permissions/'+this.permission.name+'/users').then(response => {
          this.users = response.data.users;
        });
      },
      edit(user) {
        this.$router.push({name: 'Users', params: {id: user.id}});
      }
    }
  }
</script>

in my permissions.js I have

import VueRouter from 'vue-router';
Vue.use(VueRouter);

import Users from "../users/Users";

const router = new VueRouter({
  mode: 'history',
  routes: [
    {
      path: '/admin/users/:id',
      name: 'Users',
      component: Users
    }
  ]
})

if (document.getElementById('permissions')) {
  const app = new Vue({
    el: "#permissions",
    router,
    data() {
      return {
        emit: new Vue(),
      }
    },
    methods: {

    },
    mounted() {

    }
  });
}
Jul
02
1 month ago
Activity icon

Replied to Schema::hasColumn Not Working Correctly

@deepu07 - I'm using DB::connection('second')->table('products)->where('category_id', $category_id);

Jul
01
1 month ago
Activity icon

Started a new Conversation Schema::hasColumn Not Working Correctly

I'm trying to find out if a column exists in a table. I tried doing this

if(Schema::hasColumn('products', 'category_id'))
{
    dd('has category_id');
}else{
    dd('doesnt have category_id');
}

the reason why I say it isn't working is because if I check my network tab I see that doesnt have category_id printed out and if I do check my products table then the category_id is there. So what is supposed to happen is that if category_id does exist then has category_id is supposed to be printed out.

Jun
30
1 month ago
Activity icon

Started a new Conversation ErrorException : Illegal Offset Type

I have a csv that looks like this

product,title,category,price\n
PR001,"Product Title 1","Category 1", 123\n
PR002,"Product Title 2","Category 2", 123\n
PR003,"Product Title 3","Category 3", 123\n
PR004,"Product Title 4","Category 4", 123\n
PR005,"Product Title 5","Category 5", 123\n

What I would like to do is get an array that looks like this

array:5 [
  "PR001" => "123"
  "PR002" => "123"
  "PR003" => "123"
  "PR004" => "123"
  "PR005" => "123"
]

When I run my code I get this error

 ErrorException  : Illegal offset type

Here is my code


$users = User::all();

$productArr = [];

foreach($users as $user)
{
	$csv = $user->getCsv();

	$lines = explode(PHP_EOL, $csv);
    $csvArray = [];

    foreach($lines as $line)
    {
        $csvArray[] = str_getcsv($line);
    }

    $keys = array_shift($csvArray);

    $result = array_combine($keys, array_map(null, ...$csvArray));

    $productArr[$result['product']] = $result['price'];
}

dd($role);
Mar
20
4 months ago
Activity icon

Started a new Conversation Getting My Saved Category To Show Up

I'm trying to get my selected options to show the option that was saved in the database. For example I have a product and that product belongs to a category so what I would like is for my selected options to display that saved category but also all the other categories. The problem I'm having is that I can't get my saved category to show up.

Here is my code

<select class="form-control" v-model="addNewCategory">
	<option :value="0">Choose Category</option>
	<option v-for="category in this.categories" :value="category.id" :selected="category.id === getCategoryId()">{{ category.name }}</option>
	<button @click="addCategory" class="btn btn-sm btn-success">Add</button>
</select>

<script>
	export default {
		props: ['product', 'categories'],
		data() {
            return {
                addNewCategory: null,
                category_id: ''
            }
        },
        mounted() {
            axios.get('/admin/products/'+this.product.id+'/category').then((response) => {
                this.category_id = response.data.category_id;
            });
        },
        methods: {
        	getCategoryId(){
        		return this.category_id;
        	},
        	addCategory() {
                if(this.addNewCategory > 0){
                    axios.put('/admin/products/'+this.product.id+'/category', {
                        selected_category: this.addNewCategory
                    }).then((response) => {
                
                    })
                }
            },
        },
	}
<\script>
Mar
19
4 months ago
Activity icon

Replied to Call To A Member Function Get() On Array When Doing A Query

Ok cool. But then how can I turn it into an eloquent object so that I can do $runs->id

Activity icon

Started a new Conversation Call To A Member Function Get() On Array When Doing A Query

I'm trying to get my data to be an eloquent object instead of an array. I'm using the DB::select()->get() but I get this error

Call to a member function get() on array

Here is my full code

$runs = DB::select("SELECT id FROM item_run WHERE
(EXTRACT(EPOCH FROM now()) - EXTRACT(EPOCH FROM started_at)) >= 300 AND started_at IS NOT NULL AND 
completed_at is NULL")->get();

I would like to be able to do $runs->id