NightM4re

NightM4re

Member Since 3 Years Ago

Experience Points
7,210
Total
Experience

2,790 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
69
Lessons
Completed
Best Reply Awards
0
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.

Level 2
7,210 XP
Nov
23
1 year ago
Activity icon

Started a new conversation Scope Problem In User Model

Hi everyone, I have problem making a scope in Laravel.

User.php

<?php

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'nombre', 'apellidos', 'rut', 'direccion', 'comuna' ,'ciudad', 'region', 'telefono', 'tipo', 'puntos', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    public function getNombreCompletoAttribute()
    {
        return $this->nombre . ' ' . $this->apellidos;
    }

    public function scopeNombre($query, $nombre)
    {
        if ($nombre != "") {
            $query->where('nombre', $nombre);
        }
    }
}

VentaController.php

public function usuarios(Request $request){
        $users = User::nombre($request->nombre)->paginate(20);
        return view('admin.usuarios', compact('users'));
    }

And I received this error

BadMethodCallException in Builder.php line 2405: Call to undefined method Illuminate\Database\Query\Builder::nombre()

Please Help, I use the same method for scoped other model and works great but with the user model I cant make work.

Jul
23
3 years ago
Activity icon

Replied to Middleware & Commas - 5.2

If you see laravel documentation, your middleware name need to be the same that middleware that you call in your route or controller. Your middleware name is Checkroles, but you call the middleware like roles. In laravel documentation the middlewarename is RoleMiddleware, I recommend to you to try to puch checkroles in your route or middleware or change your middlewarename to roles Tell me if you can solve this

Jul
05
3 years ago
Activity icon

Replied to Problem With V-show

Solved, I am comparing string and not numbers!, only I need to do this

Stock: function(cantidad, existe){
            if(Number(cantidad) > Number(existe)){
                return true
            }
            return false
        }
Activity icon

Started a new conversation Problem With V-show

I want to show a message warning when the quantity that one people want to buy of some product is more bigger than my quantity available of that product. I am doing this with this line of code

<p v-show="Stock(product.cantidad, product.product.cantidad)" style="color:#ff6a00">No hay suficiente Stock</p>

and my function Stock is

Stock: function(cantidad, existe){
            if(cantidad > existe){
                return true
            }
            return false
        }

The problem is when existe variable is 5 and cantidad variable 6, return true and always is ok, but if cantidad variable is 10 return true again, this mean 6 > 5 is true (correct) 6 > 8 is false (correct) 6 > 10 is true (incorrect) and go on until 6> 59 is true (incorrect) 6> 61 is false (correct)

Is like 6 is greater than 10 because then represent only 1 and not then. Please help because I don't know how to solve this

Jun
05
3 years ago
Activity icon

Replied to Problem With Scope

Solved

public function scopeApellidos($query, $apellidos) {
        if ($apellidos != "") {
            return $query->where(\DB::raw("CONCAT(nombres, ' ', apellidos)"), 'LIKE', "%$apellidos%");
        }
        return $query;
    }
Activity icon

Started a new conversation Problem With Scope

Hi everyone, I am trying to use scope for find a user with a search form. In this search I want to put first_name (nombres) and last_name (apellidos) and the scoope can find what user I want. Here is my scoope and my controller Scope

public function scopeApellidos($query, $apellidos) {
        if ($apellidos != "") {
            return $query->where(\DB::raw("CONCAT(nombres, ' ', apellidos)"), $apellidos);
        }
        return $query;
    }

Controller

$users = User::orderBy('apellidos')->email($request->email)->apellidos($request->apellidos)->type($request->type)->get();

The problem is that debugbar say

select * from users where CONCAT(nombres, ' ', apellidos) = 'cabrera' order by apellidos asc

but I dont recieve any user in my usertable but I have one that have last_name (apellidos) cabrera Thanks for help me

May
27
3 years ago
Activity icon

Replied to Vue Resource Problem With Get

Solved!!!! . Only I need to put the CDN in header with vue.js and not before body tag. Thanks all

Activity icon

Replied to Vue Resource Problem With Get

How I can to solve that? that load first the vue-resource and after main.js? Thanks for help me, but I am new in this.

Activity icon

Replied to Vue Resource Problem With Get

I am including vue resource with Cdn but continue doesn't work. And chrome said that I am including correctly. So I am not understand what happened

Activity icon

Started a new conversation Vue Resource Problem With Get

Hi everyone, this is my first post here in Laracast and I am so exiting learning laravel with vue.js. I am trying to make ajax request with vue resource but I have some problem. I hope you can help me to solve this because I really want to use this plugin. Here is my error " main.js:14 Uncaught TypeError: Cannot read property 'get' of undefined "

And my code is in main.je

Vue.config.debug = true; Vue.config.devtools = true;

var urlAPI = 'http://api.randomuser.me/?results=5'; new Vue({ el: '#app',

created: function() { this.consultarAPI(); },

methods: { consultarAPI: function(){ this.$http.get(urlAPI).then(function (response){ console.log('Bien'); }, function(response) { console.log('Mal'); }); } } });

and my code in index.html

<div class="container" style="margin-top:100px;">
    <div id="app">
          <div class="row">
            <div class="col s12 m2 l3"><p></p></div>
            <div class="col s12 m8 l6">
                <p>
                    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat eius consectetur aspernatur doloribus libero modi, facere culpa! Tenetur soluta omnis perferendis ipsa esse, voluptates excepturi repellendus aperiam corporis vel vitae?
                </p>
            </div>
            <div class="col s12 m2 l3"></div>
          </div>
    </div>
</div>

And when I try to use the normal call

methods: { consultarAPI: function(){ this.$http({url: urlAPI, method: 'GET'}).then(function (response){ console.log('Bien'); }, function(response) { console.log('Mal'); }); } }

I receive this message

"main.js:14 Uncaught TypeError: this.$http is not a function"

Thanks so much for help me.