arthurvillar

arthurvillar

Member Since 2 Years Ago

Experience Points 38,410
Experience Level 8

1,590 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 239
Lessons
Completed
Best Reply Awards 22
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.

25 Apr
1 year ago

arthurvillar left a reply on Make A Foreach With A JSON Array

"Json Array" does not exist in the practical sense. Think of Json as just a string of text that looks like an object or array. For that reason, it is ready to be used as such when converted (decoded) into the language you want to use it with.

arthurvillar left a reply on Filtering Relationships By Other Relationships

Well, you are always fetching all the records in order to filter them after. It will drag if you have a large database.

23 Apr
1 year ago

arthurvillar left a reply on Filtering Relationships By Other Relationships

I would try something like this

class Category extends Model
{

    public function scopeProductsWithCategory($query, $category) {  
        $query->whereHas('products', function($query2) {
            $query2->whereHas('categories', function($query3) {
                return $query3->where('id', $category->id);
            });
        });
    }

}

// On a controller or view you could then use
$categoryOne->productsWithCategory($categoryTwo);
19 Mar
1 year ago

arthurvillar started a new conversation Campaign Monitor With TDD

Does anybody know if I can run tests for emails using Campaign Monitor? @bashy I saw that you have a Laravel wrapper for Campaign Monitor (which looks great!), is there a way to include emails sent through them in my tests?

16 Mar
1 year ago

arthurvillar left a reply on How To Update The Application After Updating Files?

@behnampmdg3 you have two good answers here. Please mark this discussion as solved.

arthurvillar left a reply on Trying To Get Property Of Non-object Sending Data To The View

The method find() only works with ids, not slugs (even if you specified to use it on the model class).

The only time you are trying to access a property (which the error says it's failing) is on $conf->id, so the problem is with your variable $conf which is null.

You can quickly resolve the issue by doing

$conf = Conf::where('slug', $slug)->get();

// or pass an actual id

$conf = Conf::find($id);

arthurvillar left a reply on Unable To Upload Video File

This code is never being reached, so you can't know if it causes errors or not. But by looking at it, I wonder where does the method move() comes from. Looks like $vid is an instance of your VideoStore class, so do you have that method created in there? If not this will fail for sure.

arthurvillar left a reply on Unable To Upload Video File

Try creating the form without using these helpers from Laravel. Create the actual tag with correct attributes and inputs. It will look like this

<form method="POST" action="/your-route-here" enctype="multipart/form-data">
    <input type="file" name="Upload_video">
    <input type="submit" value="Upload Video" name="submit">
</form>

ps: please use the proper format to post code here, it is very difficult to read it otherwise.

arthurvillar left a reply on Architecture For A Platform Like Shopify

This is a huge question you are asking. Architecture and process means pretty much the entire development of your project. I would recommend you many of the series in here. They cover almost everything you would need to get your project off the ground, but you do need to do your homework. Here are the ones I recommend:

arthurvillar left a reply on Unable To Upload Video File

This error is telling you exactly what is happening: the if($request->hasFile('Upload_video') returns false, so all the logic within it never runs. The next line that runs is $vid->save(), which is adding only the created_at and updated_at. Laravel adds those automatically behind the scenes every time you insert anything new into your table. This means there is no file coming from your form.

Looks like you don't have enctype="multipart/form-data" in your form tag on the view file. If you don't have that the file will never reach the controller. Your form tag should look like this

<form method="POST" action="/your-route-here" enctype="multipart/form-data">
11 Mar
1 year ago

arthurvillar left a reply on Would Love To Hear Your Tips For A Good Payment System

There are many online payment services out there, but you should really take into consideration how much documentation you will find to help implementing the service you choose.

Laravel provides integration with Braintree and Stripe out of the box. Take a look at the docs here.

I have never used Braitree, but I read that they charge an additional 1% for international currencies, while Stripe does not. You can find a full comparison article here.

Finally, the simple fact that there are great videos right here about implementing Stripe, I would definitely go with that option. Unless you have good experience working with these APIs, they can get tricky sometimes. You should checkout the course Stripe Checkout. This one is not only about subscriptions, but also about single payments, which is closer to what you need.

07 Mar
1 year ago

arthurvillar left a reply on Directly Loop A Relationship

When you run $Users = User::someCategory()->get(); you get a collection in return. Check here for the many helpers Laravel gives you to use with collections. You can use a simple each in this case

$Users->each(function($user){
    $user->transactions->each(function($transaction){
        // Your transaction is here
    });
});

arthurvillar left a reply on Redirect User When The Db Is Empty

This is solved by creating a custom middleware. It's very simple, just read the docs here.

04 Mar
1 year ago

arthurvillar left a reply on Custom Redirect To Validation Fail On A Registration Form

Thanks @Snapey , both are good ideas! Maybe I'm just being too picky about this.

arthurvillar left a reply on Pushing A View Section Onto Stack Once

What a great solution, I never thought of it! I will use this on my projects too.

arthurvillar left a reply on Custom Redirect To Validation Fail On A Registration Form

Problem solved! The issue was created because I have to use a modal for login and needed to redirect to a login page instead of back and show the modal. I overrode the $redirectTo to /login on validation exception and sure enough all validation fails were going there.

I just found this answer on StackOverflow that solved the problem. I now have $redirectTo pointing to /register and I added the sendFailedLoginResponse method on the LoginController to override the natural redirection.

Do you think this is a decent way of doing this, or am I creating a bigger issue here for no reason? The client wants the modal for login but I don't like to have the browser going back and automatically opening the modal for fails, it just feels weird.

arthurvillar left a reply on Pushing A View Section Onto Stack Once

I see! Yeah, I don't think your solution is possible because the @captcha directive will always load the @push and you can't have some @if statement in there.

The only solution I can think of is to save a Session with a unique id (one for every page load) and inside the directive you can check on that session to see if the script was loaded or not, but I don't think this is a very elegant way to go about it. I would just add the script manually in this case.

arthurvillar left a reply on Pushing A View Section Onto Stack Once

Why don't you include the <script src="https://www.google.com/recaptcha/api.js"></script> directly on the head of the main layout view? If you are using @extends on your views than you have a main layout view that can have that script at all times.

arthurvillar left a reply on Custom Redirect To Validation Fail On A Registration Form

It's a very recent built of Laravel 5.5. The validation on register redirects to /login, and I just want it to go back to the register view. If a login fails validation, it redirects to the login view, and that is what is expecetd.

The class Illuminate\Validation\ValidationException has the $redirectTo property set to /login. If I override that to /register it works but then when a login fails it now goes to the register view, which makes no sense. This seems like such a weird issue...

@snapey I use the standard route('register') to get to the register view and I am using the built in functionality and boilerplate you get when run the command php artisan make:auth.

arthurvillar left a reply on Custom Redirect To Validation Fail On A Registration Form

Thanks for the reply @yamin27 , but I still want to use the resources for registering a user that come with Laravel. I just don't want to create all the connections myself just to have a different redirect.

03 Mar
1 year ago

arthurvillar left a reply on Laracasts - Email On New Series?

@robm89 please mark this discussion as solved, thanks!

arthurvillar started a new conversation Custom Redirect To Validation Fail On A Registration Form

I just noticed that if a visitor fills out the registration form but the validation fails (the password is too short, for example), the app redirects to the login page. This seems to be quite a simple thing to fix, but I couldn't find a way to make the page go back to the registration view.

In short, I need to redirect back only when a registration fails. All other auth related fails should redirect back to the login page, as already is the case.

Any ideas?

26 Feb
1 year ago

arthurvillar left a reply on Globally Hide Super Users

I think you can find your answer here. This is how you can override the get(), select() and where() methods.

arthurvillar left a reply on Add A Object In Shopping Cart

I understand how the package is supposed to work, but I can't see what you missed because your code isn't here! We need to know what you did, not what the package developers do.

arthurvillar left a reply on Session Is Not Working As Expected

Looks like your post is not complete, as it is this makes no sense. What is your issue? What is your question? Where is the middleware?

arthurvillar left a reply on Fontawesome PHP Brand Icon Won't Load

Fontawesome recently merged to their new version 5 but installing them through package managers still pulls in the older version. You are probably using their current website to copy the icon html tags, but the code you have expects the old tags.

An easy way to check if this is the case is to install their CDN on the head of your page and see if the icons work.

<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>

Here is the documentation.

arthurvillar left a reply on Add A Object In Shopping Cart

We definitely need to see more code, there is no way of knowing why this doesn't work without seeing where it is coming from and where it is going to.

Please post the CartItem class (at least the __construct() method) and the add() method in the Cart class.

arthurvillar left a reply on Hinting Objects To Controller

Question 1 Objects injected on a controller method don't run before the method itself, they simply are available for you to use. No logic inside their classes runs until you actually call them. This only happens when you pass a model from the route, which leads to question 2.

Question 2

  • You can pass any model you want but in order to automatically access them from the controller you need to keep the same names. If you call Domains $id, for example, it will not work. $id will be an instance of the Domains class, not the single row you are expecting to get.

  • I think the answer above serves for this question. The row is determined by the id you passed into the route.

  • Laravel will expect an id to be passed into the route, but you can use any column you want. If, for example, you want to find a domain by its name and have the name on the route, just add this method the relevant model

// On Domains model
public function getRouteKeyName()
{
    return 'whatever-column-name-here';
}

You can check the docs here.

25 Feb
1 year ago

arthurvillar left a reply on How To Show Random Posts Using SortBy()?

The helper function shuffle() will do exactly what you need. Check the docs here.

arthurvillar left a reply on How To Pass A Variable From A Function To Another Function?

Take a look at your code. What is $data? You are passing into the method charge() an instance of the Request class as a variable called $request. The method charge() knows nothing about $data so it will tell you just that (undefined variable).

If I understand correctly, you first reach out to the route /validate, then go back to the browser and then go to the route /charge.

On /charge, if you do this instead

public function charge(Request $request)
{
    dd($request);
}

What do you get?

arthurvillar left a reply on Retrieve Multiple Tables

You really should watch the basic courses found here. Laravel 5.4 From Scratch is one you should definitely watch. Everything you ask about you will learn how to do in this series.

arthurvillar left a reply on Speed Up Query To Large Database Using Eloquent.

Install the Debugbar (go to the docs here). Import that database into your local machine and see how many queries Laravel is actually making behind the scenes (you will probably see tons of repeated or seemingly unnecessary queries). You can fix this using through many different ways, but you first need to know exactly what is going on.

24 Feb
1 year ago

arthurvillar left a reply on How Can I Include JS Links For Nested Html Files?

@cronix is absolutely right! I based my answer on the quickest way to get the problem to be solved. This is such a basic issue, so recommending mix seems a little premature. But nonetheless @Webiondev123 , if you don't mind spending some time to learn about mix, definitely go for it!

arthurvillar left a reply on How To Create Static Busines Web With Homepage Of Static Contents Like, About Us, What We Do, Our Services

A static website by definition means no database. Having a database implies dynamic content that changes based on the user. It is very easy to create a website like you described, and you should just build each page the way you want. I absolutely recommend you to stay away from databases, it will just make a simple project become complicated.

If you are familiar with Bootstrap, there are tons of templates you can download and adapt to your needs. Here is a collection of some beautiful ones.

The Bootstrap website also has some free templates that are quite nice, see here.

Any of these pages are very simple to create as long as you have basic understanding of html and css.

arthurvillar left a reply on How Can I Include JS Links For Nested Html Files?

Always use the asset() helper function to link to your css and js files. Like this

<link href="{{asset('css/plugins/toastr/toastr.min.css')}}" rel="stylesheet">

This method points to the public directory and Laravel will automatically locate the css folder on the right place, regardless of the view directory you call it from.

23 Feb
1 year ago

arthurvillar left a reply on Use Session

You can read the docs here regarding sessions in Laravel. The easiest way to go about it is to use the helper function session(). You will be able to use these three methods

// To create a new session
session()->put('session-name', 'session-value');

// To check if a session exists
session()->has('session-name');

// To get an existing session
session()->get('session-name');

// To delete a session
session()->pull('session-name');

arthurvillar left a reply on Creating A Custom Registration System For Guest Users

You used the get() method on the route, but your form's attribute method is set to POST. Just change the route to

// Use post instead of get
Route::post('check_username/{username}', '[email protected]');

arthurvillar left a reply on Url Response Code

getStatusCode() will always give you a status code, that is what this method is supposed to do. Regardless of the code, this will return it. There is no way to ask this method to not return a 200, or even if there is this would be a nonsensical thing to do.

arthurvillar left a reply on Use Session

What do you mean? Which config file? Where do you need to access the session, in the controller on on the view? Please elaborate more on your question.

arthurvillar left a reply on Confirm Box Only Deletes First Record

Last try, change the data-action from the icon into the <a> tag and add on this tag a new class. Make sure all <a> tags have this new class. Like this

<td class="text-center"><a href="#confirm-delete" class="delete-icon" data-toggle="modal" data-target="#confirm-delete" data-action="{{ route('task.delete', $task->id) }}"><i class="fas fa-trash-alt fa-lg"></i></a></td>

Then the JQuery will look like this

$('.delete-icon').on('click', function() {
    alert('Testing if this works');
    $action = $(this).attr('data-action');
    $('#confirm-delete form').attr('action', $action);
})

If you see the alert box it means everything is working. If not, there is still some weird issue going on there.

Quick tip: always load your JS related files at the end of the body tag, not in the head tag. This will let the browser load the page before it loads the JS. Otherwise the browser will be stuck loading the JS and your page will load slower than necessary.

arthurvillar left a reply on Confirm Box Only Deletes First Record

I just added these snippets here and it works. Do you have the JQuery snippet after the JQuery links you just posted? That snippet must be the very last thing on the page. If that is not the issue, than I have no idea because it works here. You should get the alert box showing when you click on the icon, which is what I get here.

arthurvillar left a reply on Confirm Box Only Deletes First Record

So there is the issue. Do you have JQuery running? If not this will not work.

arthurvillar left a reply on How To Save Field Values To Database As JSON

Why not use compact()? I just think it looks more organized.

$field1 = $request->input('field1');
$field2 = $request->input('field2');


$lead = Leads::created([
'additional_fields' => json_encode(compact("field1", "field2"));
]);

arthurvillar left a reply on Confirm Box Only Deletes First Record

The action method has not been filled, or it has been filled wrong.

It looks like it has been but the id was not passed to the route, so it is incomplete. MethodNotAllowedHttpException means the route doesn't exist.

Right click on the trash icon and click on inspect. You should see the html element on the browser console. Look at the data-action attribute on that icon and see if it is correct. If yes, than the issue is with the JS snippet.

If that is the case, debug by doing this

<script>
    $('.fa-trash-alt').on('click', function() {
        $action = $(this).attr('data-action');
    alert($action);
        $('#confirm-delete form').attr('action', $action);
    })
</script>

An alert box will open when you click on the icon. You should see there the correct action. If it is correct, than the issue is on passing it to the form.

Right click on the form, click on inspect and look at the action attribute on that form. By now you should be able to track down what went wrong.

22 Feb
1 year ago

arthurvillar left a reply on Confirm Box Only Deletes First Record

Not at all, the delete button will just trigger the form. You will only click on it once the modal is open, and at that point the action will already be filled. Inspect the element to see in the browser if that worked. If the form has no action attribute let me know, I must have missed something silly.

arthurvillar left a reply on Database Not Updating And No Error Thrown

@ryanborum if the problem is solved, please mark it solved by selecting the best answer.

arthurvillar left a reply on I Need To Make Pagination For Episode Like Animy

Are you trying to add pagination to the list of animes or the list of episodes?

arthurvillar left a reply on Confirm Box Only Deletes First Record

No problem, here is an idea:

1) On the trash icon insert an attribute called data-action, and put the route in there

<td class="text-center"><a href="#confirm-delete" data-toggle="modal" data-target="#confirm-delete"><i class="fas fa-trash-alt fa-lg" data-action="{{ route('task.delete', $task->id) }}"></i></a></td>

2) Inside the modal, remove the action attribute from the form

3) Now include this snippet in the bottom of your html (right before the closing of the body tag)

// Assuming you have JQuery running of course...

$('.fa-trash-alt').on('click', function() {
    $action = $(this).attr('data-action');
    $('#confirm-delete form').attr('action', $action);
})

That should do it! Before clicking on delete, check to see if the id is showing correctly.

And sure, my email is [email protected]