JoaquinVilchez

JoaquinVilchez

Member Since 1 Year Ago

Venado Tuerto

Experience Points
5,030
Total
Experience

4,970 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
43
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 2
5,030 XP
Jul
01
1 week ago
Activity icon

Awarded Best Reply on Relationship Many To Many Returns 1

Hello, I already solved the problem ... with changing the name of the function I reach ... you can see that it was being stepped on with some other function that was called the same ...

Thank you very much for caring!

The solution was to change

public function variants () {
//
}

by

public function getVariants () {
//
}
Activity icon

Replied to Relationship Many To Many Returns 1

Hello, I already solved the problem ... with changing the name of the function I reach ... you can see that it was being stepped on with some other function that was called the same ...

Thank you very much for caring!

The solution was to change

public function variants () {
//
}

by

public function getVariants () {
//
}
Activity icon

Replied to Relationship Many To Many Returns 1

Product.php


namespace App;

use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
use DB;

class Product extends Model
{
    protected $guarded = [];

    public function restaurant(){
        return $this->belongsTo(Restaurant::class);
    }

    public function category(){
        return $this->belongsTo(Category::class);
    }

    public function orders(){
        return $this->belongsToMany(Order::class);
    }

    public function lineItem(){
        return $this->hasMany(LineItem::class);
    }

    public function variants(){
        return $this->belongsToMany('App\Variant', 'products_variants');
    }
}
?>

Variant.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Variant extends Model
{
    protected $guarded = [];

    public function restaurant(){
        return $this->belongsTo(Restaurant::class);
    }

    public function products(){
        return $this->belongsToMany(Product::class, 'products_variants');
    }
}	
?>

Restaurant.php

<?php

namespace App;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;

class restaurant extends Model
{
    protected $guarded = [];

    public function user(){
        return $this->belongsTo(User::class);
    }

    public function orders(){
        return $this->hasMany(Order::class);
    }

    public function address(){
        return $this->hasOne(Address::class);
    }

    public function products(){
        return $this->hasMany(Product::class);
    }

    public function categories(){
        return $this->hasMany(Category::class);
    }

    public function restaurantCategories(){
        return $this->belongsToMany(RestaurantCategory::class, 'relation_restaurant_category', 'restaurant_id', 'category_restaurant_id');
    }

    public function variants(){
        return $this->hasMany(Variant::class);
    }
}
?>
Activity icon

Replied to Relationship Many To Many Returns 1

The problem is that I do not want to bring only the product with the id 1848 ... I want to bring the complete collection of products and show in each one its variants if it has ...

If I bring only one, yes, I get the variants, instead if I bring a collection of products, it returns a 1 if it has and a 0 if it does not have.

Jun
30
1 week ago
Activity icon

Replied to Relationship Many To Many Returns 1

If I do the command you indicated, it returns the product with its variants, but when I want to do $ product-> variants it returns the 1 I was saying.

https://ibb.co/51qBD4f

https://ibb.co/znhcqwx

Yes, I already tried to put the parameters of the column names in the pivot table, but it keeps showing me the same...

Activity icon

Replied to Relationship Many To Many Returns 1

This is the pivot table 'products_variants' exported in TXT from phpmyadmin. It has data with foreign keys to products and variants

===Database pedisimple

== Table structure for table products_variants

|------
|Column|Type|Null|Default
|------
|//**id**//|bigint(20)|No|
|product_id|bigint(20)|No|
|variant_id|bigint(20)|No|
|created_at|timestamp|Yes|NULL
|updated_at|timestamp|Yes|NULL
== Dumping data for table products_variants

|8|1848|11|NULL|NULL
|9|1848|12|NULL|NULL
|10|1848|13|NULL|NULL
|11|1848|14|NULL|NULL
|12|1848|15|NULL|NULL
|13|1848|16|NULL|NULL
|15|1849|11|NULL|NULL
|16|1849|12|NULL|NULL
|17|1849|13|NULL|NULL
|18|1849|14|NULL|NULL
|19|1849|15|NULL|NULL
|20|1849|16|NULL|NULL
Jun
29
1 week ago
Activity icon

Started a new Conversation Relationship Many To Many Returns 1

Hello, I am wanting to make a many to many relationship as I have always done but it only returns a 1 when I invoke it.

I followed the steps of the documentation but I could not get a result.

What I have are products that can have variants, such as 1kg of ice cream has different tastes and tastes can be in many products (Ice cream 500g, etc.)

I show you what I do:

In Product.php

class Product extends Model
{
    public function variants(){
        return $this->belongsToMany(Variant::class, 'products_variants');
    }
}

In Variant.php

class Variant extends Model
{
    public function products(){
        return $this->belongsToMany(Product::class, 'products_variants');
    }
}
 $products = $restaurant->products()->where('temporary',false)->where('state', '!=', 'removed')->orderBy('category_id', 'asc')->get();

        foreach($products as $product){
            dump($product->variants);
        }

	die();

Here it returns me, in case it has variants, a 1, if not I return 0.

On the other hand, if I want to show the products that are related to a particular variant, if it shows me the products objects.

$variant->products;

Thank You!

Jun
05
1 month ago
Activity icon

Replied to Pass Complete Object In Attribute Data- (Modal With A Lot Of Information )

Hello, I appreciate your contribution, I read it carefully, but in that code, what it does is show in the modal the values that are written in the row of the table, since I do not have those data in the row, I cannot access them. Instead, what I need is to access from the database or from the entire object that I pass from the HTML.

Thanks anyway for your contribution.

Activity icon

Started a new Conversation Pass Complete Object In Attribute Data- (Modal With A Lot Of Information )

Hello how are you?

I wanted to know if there is a way to pass an integer object to a modal through the data attribute and get its values directly in the modal.

My idea is to do the following: https://ibb.co/ySjkrmK

But if I have to pass data by data, I have a lot of data attributes left in the <a data-a="" data-b="" data-c="" data-d="" data-e="", data-...=""> </a> There is some way to pass the entire object and be able to consult it within the modal, such as doing a foreach to go through all the products of the order.

<a data-order="{{$order}}">Click</a>

Inside the modal:

$order->id
$order->code
$order->user->firstname

Thank you.

Activity icon

Awarded Best Reply on Blade - Conditional Does Not Work With Internal Parentheses.

I solved it by doing all ANDs, I hadn't really thought of it that way, but I tried and it worked.

@if(!\Cart::isEmpty() and Request::path()!="checkout" and Request::path()!="login" and Request::path()!="register")
<div class="alert alert-warning mb-0 text-center" role="alert">
Tienes un pedido pendiente. <a href="{{route('checkout.index')}}" class="alert-link">Finalizar pedido</a> 
</div>
@endif

Thanks for your time

Activity icon

Replied to Blade - Conditional Does Not Work With Internal Parentheses.

I solved it by doing all ANDs, I hadn't really thought of it that way, but I tried and it worked.

@if(!\Cart::isEmpty() and Request::path()!="checkout" and Request::path()!="login" and Request::path()!="register")
<div class="alert alert-warning mb-0 text-center" role="alert">
Tienes un pedido pendiente. <a href="{{route('checkout.index')}}" class="alert-link">Finalizar pedido</a> 
</div>
@endif

Thanks for your time

Activity icon

Replied to Blade - Conditional Does Not Work With Internal Parentheses.

No, I tried the @php directives like you told me, and it didn't work ... and I also opened the Tags as if it were a normal html and it also doesn't work ... weird.

If I remove the parentheses and leave the && it only works, but with the internal parentheses it doesn't.

Jun
04
1 month ago
Activity icon

Started a new Conversation Blade - Conditional Does Not Work With Internal Parentheses.

Hello I want to make an alert appear on all pages except some and only if the cart is not empty ...

@if(!\Cart::isEmpty() && (Request::path()!='checkout' || Request::path()!='login' || Request::path()!='register'))
            <div class="alert alert-warning mb-0 text-center" role="alert">
                Tienes un pedido pendiente. <a href="{{route('checkout.index')}}" class="alert-link">Finalizar pedido</a> 
            </div>
@endif

I try to do this but I have no results ... Can Blade do internal parentheses inside a codicional?

Thank you.

May
30
1 month ago
Activity icon

Replied to Redirect To Two Different Routes In The Controller At The Same Time (new Tab).

Thanks, I was able to solve it in a simple way. Use an onload = "window.open" if there is a session which you previously created in the controller as the article you passed me siangboon.

When I work with Vue I will improve it.

Thank you.

May
29
1 month ago
Activity icon

Started a new Conversation Redirect To Two Different Routes In The Controller At The Same Time (new Tab).

Hello how are you.

I wanted to know if there is any possibility of redirecting to two different routes at the same time.

I have an order system.

What I want to do is that when an order is confirmed, automatically, the order goes to an "Accepted" state and that it opens a URL to be able to contact the customer through WhatsApp (New tab that opens WhatsApp web with the WP API ) and at the same time return to the order page with back ()

I show you the controller I have so you can see how it would be.

public function accept(Request $request)
    {
        // dd($request->all());
        $order = Order::find($request->acceptorderid);
        $order->update([
            'state' => 'accepted'
        ]);
        
        // Searching the internet I thought I could do it this way, but I found no result.
        $newUrl='https://wa.me/'.str_replace('-', '', whatsappNumberCustomer($order)).'?text='.urlencode(whatsappMessageCustomer($order));
        session()->flash('newurl', $newUrl);
        // =============================================

        return back()->with('success_message', 'Pedido aceptado.');
    }

Thank you.

May
16
1 month ago
Activity icon

Replied to [HELP] Problems With Authenticated Users

Hi, how are you? Excuse the delay in answering, I was very busy.

The problem was that the server I had hired was missing a configuration for Laravel, and the sessions overlapped. The problem was solved for me from Server Support.

Thank you very much for caring anyway.

A greeting!

Activity icon

Replied to Message That Is Displayed Only Once To The User.

Excellent! Thank you very much as always.

I did not know about Laravel notifications or the Flash package, I will review it.

A greeting!!

May
15
1 month ago
Activity icon

Started a new Conversation Message That Is Displayed Only Once To The User.

Hello how are you?

I wanted to know if there is any way I can show a message only once ...

My idea is to show the user the new functions that the new version of the page has through a bootstrap modal ... what I want to achieve is for the user to log in and the web will show them only once, through a modal bootstrap, the new functionalities that the page has, and after seeing it, that modal to that user does not appear anymore.

Something like Visual Studio Code does when there is a new version of the app. It can be seen only once and then it does not appear anymore.

Thank you.

Apr
29
2 months ago
Activity icon

Replied to [HELP] Problems With Authenticated Users

thanks, I am going to review it ... but, that solves the change from one user to another also instantly? I mean, absolutely everything appears as if I had logged in with the other user ... that's why I suspect Auth::user();

Because I do not force the error by changing some parameters or tricking the app, but from one moment to the next, I appear as if I were the other user!

That's weird .. but hey I'll try to test that package

Activity icon

Started a new Conversation [HELP] Problems With Authenticated Users

Hello! How are they? I have a problem that I don't know how to solve ...

When I uploaded my application to a shared server, I started having a problem: When two users are logged in at the same time in my application, a bug appears, where (I still can't know when or why) I change to another user and I have access to all user data that is not mine ... that is:

User1 is logged in and is working, at the same time User2 is logged in and in a moment User1 instead of having access to their data, has access to User2's data and can add, edit or delete any data from User2 ...

I get the data depending on the authenticated user, with Auth :: user () ... but I don't know why this is happening, it shouldn't happen to me ... but this makes my app super insecure!