JoaquinVilchez

JoaquinVilchez

Member Since 2 Years Ago

Venado Tuerto

Experience Points
5,160
Total
Experience

4,840 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,160 XP
Aug
29
1 month ago
Activity icon

Replied to Problem When Try Deploy My Laravel App To Heroku

@bobbybouwmann I did it! but I kept getting the same error. It also shows me the error in TelescopeApplicationServiceProvider but in config / app.php I can't find one that says exactly like this, but only TelescopeServiceProvider appears.

Can't deploy with Telescope installed?

Thank you

Activity icon

Started a new Conversation Problem When Try Deploy My Laravel App To Heroku

Hi!

Im trying to deploy my Laravel app to Heroku with this guide: https://devcenter.heroku.com/articles/getting-started-with-laravel

But when execute git push heroku master i have this problem in console:

remote:        Generating optimized autoload files
remote:        Deprecation Notice: Class App\restaurant located in ./app/Restaurant.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///tmp/build_bba94d0d/.heroku/php/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
remote:        > Illuminate\Foundation\ComposerScripts::postAutoloadDump
remote:        > @php artisan package:discover --ansi
remote:
remote:        In TelescopeServiceProvider.php line 10:
remote:
remote:          Class 'Laravel\Telescope\TelescopeApplicationServiceProvider' not found
remote:
remote:
remote:        Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
remote:  !     WARNING: There was a class not found error in your code
remote:
remote:  !     ERROR: Dependency installation failed!
remote:  !
remote:  !     The 'composer install' process failed with an error. The cause
remote:  !     may be the download or installation of packages, or a pre- or
remote:  !     post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
remote:  !     in your 'composer.json'.
remote:  !
remote:  !     Typical error cases are out-of-date or missing parts of code,
remote:  !     timeouts when making external connections, or memory limits.
remote:  !
remote:  !     Check the above error output closely to determine the cause of
remote:  !     the problem, ensure the code you're pushing is functioning
remote:  !     properly, and that all local changes are committed correctly.
remote:  !
remote:  !     For more information on builds for PHP on Heroku, refer to
remote:  !     https://devcenter.heroku.com/articles/php-support
remote:  !
remote:  !     REMINDER: the following warnings were emitted during the build;
remote:  !     check the details above, as they may be related to this error:
remote:  !     - Your 'composer.lock' is out of date!
remote:  !     - There was a class not found error in your code
remote:
remote:  !     Push rejected, failed to compile PHP app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to pedisimple.
remote:
To https://git.heroku.com/pedisimple.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/pedisimple.git'

im tryed to reinstall Telescope and Telescope Toolbar, or remove them because i saw that error, but no have solution...

its my first time to deploy a laravel app to heroku.

if you need some files from my project to detect the problem tell me

PD: In other forums they told me to run php artisan optimize on console, but it also shows me another error that I don't know how to fix. I don't know if it will affect the main problem. This is the error:

 php artisan optimize  
Configuration cache cleared!
Configuration cached successfully!
Route cache cleared!

   LogicException 

  Unable to prepare route [api/user] for serialization. Uses Closure.

  at D:\Users\Joaquin\Projects\pedisimple\vendor\laravel\framework\src\Illuminate\Routing\Route.php:1150
    1146|      */
    1147|     public function prepareForSerialization()
    1148|     {
    1149|         if ($this->action['uses'] instanceof Closure) {
  > 1150|             throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");
    1151|         }
    1152| 
    1153|         $this->compileRoute();
    1154| 

  1   D:\Users\Joaquin\Projects\pedisimple\vendor\laravel\framework\src\Illuminate\Foundation\Console\RouteCacheCommand.php:62
      Illuminate\Routing\Route::prepareForSerialization()

  2   D:\Users\Joaquin\Projects\pedisimple\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:37
      Illuminate\Foundation\Console\RouteCacheCommand::handle()

Thanks

Jul
17
3 months ago
Activity icon

Replied to Is This A Good Practice Or Not?

Thank you @mvd, probbably i will tried with second option!

Activity icon

Replied to Is This A Good Practice Or Not?

It is true! That solution had not occurred to me, I think it is much easier.

Thank you very much @briankidd, I will implement it this way

Activity icon

Started a new Conversation Is This A Good Practice Or Not?

Hello how are you? I wanted to ask you who have more experience than me if what I want to do is a good or bad practice in Laravel.

I am making an ordering app and in my database I have that a product has a certain price (one more field in the product table). But then I realized that when the price of the product one day changes, the price will also change in an old order, that is, the old order will adopt the new price of the product at this moment and not on the date when the order was placed, thus generating an information problem.

For that, I decided to create a new table that has the temporary prices, that is, if the price changes, that a new row is created in the database with the price on a certain date, but that the price it had in another is recorded. date.

Now, my question is ... How can I bring the current price of a product to that new table that I am creating, without the user intervening ... that is, migrate all the prices of each product to that new table. My idea was to create a function that goes through each product and that creates a new row in the prices table with the product id, the price and the current date. Once this function is created, run it through Tinker and that the user does not notice absolutely nothing, but that the system adopts the new price structure.

This is good? Is it a good practice or is there a better way to do it?

Thank you.

Jul
01
3 months 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
3 months 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
3 months 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
4 months 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
4 months 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
4 months 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
4 months 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
5 months 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
5 months 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
5 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!