jcmargentina

jcmargentina

Member Since 1 Year Ago

Experience Points 37,760
Experience
Level
Lessons Completed 202
Lessons
Completed
Best Reply Awards 23
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

27 Nov
1 month ago

jcmargentina started a new conversation PHP7 + SWOOLE Breaks The Performance Wall

This is absolutely amazing.

SWOOLE (https://www.swoole.co.uk) is changing the game and putting PHP at the head of the STACK.

SWOOLE .... a Production-Grade Async programming Framework for PHP, is breaking almost all benchmarks in the web putting PHP at the same level than C ... Java ... Golang .... in terms of performance.

Please refer to this extension and give it a read.

Also ... there is an extension for laravel ... GREAT!

https://github.com/swooletw/laravel-swoole

Guys Please refer to this benchmark ... the results are amazing.

https://www.techempower.com/benchmarks/#section=data-r17&hw=ph&test=fortune&a=2

10 Sep
4 months ago

jcmargentina started a new conversation PHP Node-like Async Programming

I wanted to share this ....

https://www.swoole.co.uk/

I am really happy.

PD: there is a package for Laravel and Lumen in order to auto-use Swolle.

04 Sep
4 months ago

jcmargentina left a reply on Sample

@Cruorzy , LOL

jcmargentina left a reply on Issue : Multiple Sessions File Created Every Time In Session Folder

we may need more info here to help you out.

is there any chance you can share code with us ?

03 Sep
4 months ago

jcmargentina left a reply on Structuring Code In Controller - Best Practice Advice

check the vídeos about design patterns ... fue solid principles. ... whipe montrous code.

they will help you for sure.

at beginning takes a little effort to think in this "new terms of coding " but. ... its an every day exercise.

jcmargentina left a reply on Difficult To Contribute To Laravel

totally agree with you.

jcmargentina left a reply on Difficult To Contribute To Laravel

@wilburpowery , maybe the right expresion is not pissed off, but its anoying.

Pulling new features or improvements are not the only way to collaborate.

bug-fixing is the start point for most of the people that start to collaborate in an open source project.

The problem mixin Issues with a Regular Forum ... with the massive project like this one, is that 10 out of 11 are real issues, the rest are newbie questions and programmers errors or miss understandings ... and not framework issues per se. (Clarifying ... that is all right to have doubts and make mistakes) ... all this makes real difficult to collaborate, because first you need to purge the actual issues.

for example:

right now ... like an hour ago ... check this

at the repo : https://github.com/laravel/framework/issues/25433

at laracasts: https://laracasts.com/discuss/channels/laravel/is-it-possible-to-know-if-the-next-job-in-the-queue-is-of-a-given-type

this is right now ... just in time to give you an example.

Again, I do also make mistakes and have questions, etc --- but maybe there is a cleaner way to collaborate to Laravel and some of you can help me out here

jcmargentina left a reply on Structuring Code In Controller - Best Practice Advice

Dont worry , WE ALL DO THE SAME at the beggining.

Lucky for us ... there are a series of videos here at Laracast (under the PHP topic) that will guide you in order to write cleaner code.

jcmargentina started a new conversation Difficult To Contribute To Laravel

I am a little bit pissed off, because now I feel confident in order to contribute to the framework.

I went to the github repo ... and ... under issues ... wow ... Issues = Forum/Debate.

Basically ... there are more questions tehre than real issues.

To the ones that actually contibute to the framework, whats your "modus operandi" ?

jcmargentina left a reply on Downloading A Large File (~500 Mb) To Local Storage From FTP, Without Breaking The Server

Seems that you sould write the buffer for every chunk of file you are downlading.

Try to use pure PHP for this. Is not complicated at all.

Avoid the "readfile()" function, use fopen and fread instead for this.

give your self the right to solve this issue by youself

jcmargentina left a reply on How To Handle Multi Tabbed Modal Form Validation ?

It wont work.

What you have to do , is to get everything you need to send .... by using JavaScript and not HTML forms.

Then you manually post your form using AJAX (filled with the data you gattered using JavaScript).

And process the response.

01 Sep
4 months ago

jcmargentina left a reply on SOLID Principle In Laravel With Repository Pattern

LOL, yes I know my friend. BUT .... Is never too late to add some light to the tunnel

31 Aug
4 months ago

jcmargentina left a reply on SOLID Principle In Laravel With Repository Pattern

I think that this part of your code can be handled using a Factory (check the factory Design Pattern) in order to create the proper Repository to be used in your controller.

I refear to this part:

if($inputs['type']=='user'){
   $repo = new UserRepository;
   $repo->save($inputs);
} elseif($inputs['type']=='admin'){
   $repo = new AdminRepository;
   $repo->save($inputs); 
}

If you use a Factory then in your controller you could have something like this:


public function store(Request $request) {

    $repo = new UserRepositoryFactory($request->type)->create();

    $repo->save();

}
´´´

pretty clean a? I know I know ... I not giving you the code of the Factory ... because you will have to find it out by yourself, in the laracasts videos you will find the answer.

The good thing is ... that piece of code ... will be as it is even if you need another type of user in the future, because teh Factory will be in charge of creating the right one for the controller. 

In fact, the only piece of code you will have to modify, is the factory, and thats it.

jcmargentina started a new conversation SublimeText Plugins ... Suggestion?

Hey there, I am wondering how to improve the coding experience using the SublimeText editor. What plugins, etc, do you people suggest me to install? (Of course ... PHP/laravel is used)

22 Jul
5 months ago

jcmargentina started a new conversation AngularJS + Interceptor - Cannot Access Authorization Header But Is There In Chrome Dev Tools!

I am totally lost with this issue. I have being struggling with it since 5 hours ago. I dont know what is going on.

I have an angularJS app. The app uses JWT tokens in order to authenticate.

The token gets refreshed in every single request it makes to the backend.

The token gets attached in the header of the response or request.

So when a request goes out to the backend, the response has the new token in the header.

The issue ,.....

I cann perfectly see the new token from Chrome Developer tools under the network tab. But in my angularJS ... the authorization header is not there.

I leave here the codes I am using and also some screenshots from my browser.

Any help is welcome.

Screenshots:

here we can see the actual request sent to the server. Under the "request headers" I succesfully attach the TOKEN saved in my localStorage.

And under the "Response headers" we can successfully see the new token sent by the Backend ... BUT! I cannot update the token in my local storage with the new one, because it looks like angularJS does not "see" the authorization header or somethin like that.

request header response header

My interceptor:

app.config( function ($httpProvider) {

    $httpProvider.interceptors.push(["$q", "$location", function ($q, $location) {

        return {

            "request": function (config) {
                config.headers = config.headers || {};

                var token = window.localStorage.getItem("_token");

                if (token) {
                    config.headers.Authorization = "Bearer " + token;
                }

                return config;
            },

            "response" : function (response) {
                /* Aqui debo sacar el token del header y guardarlo en el localstorage */

                console.log("Response", response);

                let token = null;

                if (response && response.data && response.data.access_token) {

                    token = response.data.access_token;

                } else if (response && response.config && response.config.headers && response.config.headers.Authorization) {

                    token = response.config.headers.Authorization;

                    if (token) {
                        token = token.split(" ")[1];
                    }

                } else {

                    console.log("ERROR FATAL");
                    token = null;
                }

                if (token) {

                    window.localStorage.setItem("_token", token);

                    response.config.headers.Authorization = "Bearer " + token;
                }

                return response;
            },

            "reponseError": function (response) {

                if (response.status == 401 || response.status == 403) {

                    window.localStorage.removeItem("_token");

                    //$location.path("/login");
                }

                $q.reject(response);
            } 

        };

    }]);

});
01 Jul
6 months ago

jcmargentina left a reply on Too Few Argument Problem In Laravel 5.6

sorry. your code was ok then.

jcmargentina left a reply on Too Few Argument Problem In Laravel 5.6

mmm wait ... are you using the default RegisterController.php file laravel gives you ? or you wrote your own ?

jcmargentina left a reply on Data Showing As "undefined" When Printing Values Into Blade

can you try this?

var linked_entry;
    
    var sliders_row = '<tr> \
    <td> %id </td> \
    <td>%title</td> \
    <td>%description</td> \
    <td>%image</td> \
    <td>%isVisible</td> \
    <td class="entry_table_options_container"> \
    <i class="fa fas fa-pencil-alt" data-id="%id" data-title="%title" data-content="%description" data-image="%image" title="Editar" style="background-color:#5BC0DE;"></i> \
    <i class="fa far fa-trash-alt" data-id="%id" data-title="%title" data-content="%description" data-image="%image" title="Borrar" style="background-color:#D9534F;"></i> \
    </td> \
    </tr>';
    
    var csrf = $('meta[name=csrf-token]').attr('content');
    console.log(csrf);
    
    $('.sidebar_entry_container').click(function(e){
        e.preventDefault();
        linked_entry = $(this).attr("data-link");
        $('.entry_container').removeClass('visible');
        $('.entry_container[data-link=' + linked_entry + ']').addClass('visible');
        console.log(linked_entry);
        
        
        
        $.ajaxSetup({
        headers: { 'X-CSRF-Token' : $('meta[name=csrf-token]').attr('content') }
        });
        
        
        $.ajax({
            type: 'GET',
            url:  '/' + linked_entry + '',
            
            success: function(data) {
                console.log(data);
                $.each(data, function () {
                    
                    newRow = sliders_row;
                    newRow = newRow.replace(/%id/g,data.id);
                    newRow = newRow.replace(/%title/g,data.id);
                    newRow = newRow.replace(/%description/g,data.id);
                    newRow = newRow.replace(/%image/g,data.id);
                    newRow = newRow.replace(/%isVisible/g,data.id);

                    $('.entry_table_container[data-link=' + linked_entry + ']').append(newRow);
                });
                
            },
            
            error: function(data) {
                
                alert('Something failed');              
            }
        });   
    });

check if I have some syntax errors by the way. I know you will get the main idea of the code

jcmargentina left a reply on Too Few Argument Problem In Laravel 5.6

can we try something ?

change your controller like this.

add at the top the following

use Illuminate\Http\Request;

then change your create method for

 public function create(Request $request)
    {
    $validData = $this->validate($request, [
            'email' => 'required|string|email|max:255|unique:users',
            'password' => 'required|string|min:6|confirmed',
        ]);

        return User::create([
            'email' => $validData['email'],
            'password' => Hash::make($validData['password']),
        ]);
    }

please check for typeo errors, as I am not in my computer and probably I missed out some characters.

good luck

jcmargentina left a reply on Is Laravel 'faster' Than Ruby On Rails?

ok 2 things

  1. Comparing RoR vs Laravel, should be a comparison of features, or learning curve , something like that.

Because, every framework is designed with some gold in mind. That is why the metric should not be performance ... at least not the only one.

  1. RoR relies on Ruby and Laravel on PHP, Ruby vs PHP sounds like a more reasonable performance comparison... in that case you can find that PHP7 has a better performance than RUBY.

For example, check this out:

https://benchmarksgame-team.pages.debian.net/benchmarksgame/faster/php-yarv.html

At least this is my opinion, hope it helps

30 Jun
6 months ago

jcmargentina left a reply on Is Laravel 'faster' Than Ruby On Rails?

laravel is not only faster ... also with an stable performance.

this is the most serious benchmark i found out there

https://www.techempower.com/benchmarks/#section=data-r16&hw=ph&test=fortune

please do not confuse yourself. you will see some ruby at the top of laravel .... but its because they are using other frames in ruby.

also .... php is over ruby in the general view.

RoR does not even appear in the ranking due to the low performance.

jcmargentina left a reply on Route [users.index] Not Defined

just edited my answer

jcmargentina left a reply on Route [users.index] Not Defined

@Msoft .... fix your html

with an "href" mm ????? thats wrong

use this

Post Your Ad Here!

jcmargentina left a reply on Redirect User To Same Page With "#myRegistrations" Active

i would like to know what do you actually want to achieve. hoy want to clear the session or want to set #myRegistrations active?

sounds stupid but you depending en your answer. ... are the choices we have

29 Jun
6 months ago

jcmargentina left a reply on Single Page Application - Techniques

@RoboRobok , there is not an absolute formula that tells you that an SPA is better than a classical approach.

You need to use these "techniques" according your project needs.

2 cases.

  1. You need a SEO friendly website, for your institutional website (i.e restaurant site), then ... go with classical http back and fordward approach, what is the problem? LOL

  2. You dont care about SEO, lets say ... and admin panel , something like that, where you have a high rate of interaction ... choose SPA or hybrid approach.

these are just examples, not mandatory at all.

I think the secret here is to understand and use what is better in every single situation , I mean a situation not only the type of project ... but also ... the time you have to do it ... the money ... your team ... etc.

PD:

Guys lets debate, in peace. Some day in the future we will hang out together in a LaraCon afterparty ... all drunk like brothers and sisters.

Cheers!

jcmargentina left a reply on Single Page Application - Techniques

oh mama! hot topic today. I will read this as soon as I get home

28 Jun
6 months ago

jcmargentina left a reply on Relation Definition With Multiple Fields

as far as I know, relationships are declared between 2 fields only (origin and destiny)

your problem can be solved with the actual eloquent relationship model schema.

go for it!

jcmargentina left a reply on Password: Reset() Method Issue

are you handling errors in the page you are redirected ? in order to see if laravel si sending you some.

just add something like

 @if ($errors->any())

                <ul>
                @foreach($errors->all() as $error)
                  <li>{{ $error }}</li>
                @endforeach
                </ul>
          @endif

in the blade template you get after reset is execute, in order to see if you actually get some errors there.

I will asumme you have a /home declared.

jcmargentina left a reply on Dynamically Choose Database

you are welcome my friend

jcmargentina left a reply on How To Show Json On Error 419 (csrf) On Laravel?

even though the answer is correct i wonder if you only handle json requests in your laravel app.

because you handle another Type like the regular ones .... you should check the header in you request to know the Type of response to give back

jcmargentina left a reply on Dynamically Choose Database

I would say that this depends in what you want to achieve.

for exanple ... for certain cases this would help you

https://laravel.com/docs/5.6/database#using-multiple-database-connections

if you want to run console commands you can always create your own commands (make:command) and handle the logic to select the proper db inside it.

jcmargentina left a reply on Logic To Change Button After Adjudicator Score A Participant

I cannot see the image but you need to save the score of an adjudicator to the video. you need to save that action somewhere (i.e the database)

unfortunetly hoy dont have nothing coded yet so is hard for anyone to actually help you unless you want someone to do the work for you .... is not bad but you might have to pay for that work to someone.

are you new to programming? to laravel?

jcmargentina left a reply on How To Delay Database/mail Notifications?

@a-coudray glad to know.good luck

27 Jun
6 months ago

jcmargentina left a reply on How To Delay Database/mail Notifications?

RemindApplication is a notification created by php artisan right?

RemindApplication should implement the ShouldQueue interface and use the Queueable trait.

You shoudl configure your QUEUE and also ... RUN YOUR QUEUE WORKER (php artisan queue:work) and leave it running

the $when variable should be a Carbon instance object, ... right?

all of this is ok ?

jcmargentina left a reply on Download Csv File And Reload Page After Download In Controller

execute your download by AJAX, and after completion, perform whatever you need to do.

Is the only way I think

jcmargentina left a reply on AJAX File Upload Failing Validation?

whats is the list of errors you get?

Also, as far as I know, you CANNOT upload a file by AJAX, unless you do something extra.

Mostly you need to use FormData.

Please read these links and you will get a better understanding of what I am talking about.

(Algunos en español para vos)

https://desarrolloweb.com/articulos/upload-archivos-ajax-jquery.html

https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects

http://blog.teamtreehouse.com/uploading-files-ajax

https://stackoverflow.com/questions/4006520/using-html5-file-uploads-with-ajax-and-jquery

PD: This is expected, imagine if any website could just have a malicious javascript file, and could automatically upload an image from your computer??? Seria una mierda a? JAJA.

SALUDOS

jcmargentina left a reply on Logic To Change Button After Adjudicator Score A Participant

I think you need to provide us something more elaborated. Things can be modeled in a lot of ways.

Try to do your best, desing your models , relationships, views, controllers, routes, etc. and then let us know

jcmargentina left a reply on Issue With Retrieving Data

@dionarap , you are welcome , please mark an answer you think it was helpfull, in order to document your question for future readers in the forum

jcmargentina left a reply on Issue With Retrieving Data

but how is the HTML rendered correctly ??? I dont get it

jcmargentina left a reply on Issue With Retrieving Data

OMG, @Cronix is right, you have typo there

jcmargentina left a reply on Issue With Retrieving Data

Ok, thats it. It is what I told you first my friend, is your javascript code.

you are using

event.target

and that is not correct.

in order to see the exact instruction do 1 thing. I know the answer but I want to you to get it.

remember the console.log(event.target) , that gave you null ???

ok, now just do

console.log(event)

and EXAMINE the event object, try to look something similar than "target" ... for example, "currentTarget" ... and check if its content is the control (in your case ) you are looking for.

jcmargentina left a reply on Issue With Retrieving Data

@dionarap , ok. Excuse me if I dont understand well the situation, my native language is spanish so sometimes I dont get really good the english.

Please ... Please do this for me, doesnt matter if you think it is ridiculuous, please do it.

I am assuming you have chrome installed as your browser.

  1. when you render your page (view) , please, right click on it, and INSPECT the source code, and look you your are actually filling ok the data-id attribute of your element

  2. Please do "Developers tools, network tab" thing I told you to do, in order to actually see what is the browser sending to PHP

  3. Did you add the "console.log" instruction I suggested you? what was the output?

I will wait your reply.

jcmargentina left a reply on Problem With Saving Password During Edition User As Admin

you are welcome.

pay attention I have use a variable called $requestData to retrieve all parameters from $request.

this is considered a good practice from a lot a software developers, because you have parameters exclusively in one single variable.

good luck!

26 Jun
6 months ago

jcmargentina left a reply on Problem With Saving Password During Edition User As Admin

the problem is the order of the instructions.

make this changes

   public function update($id, CreateUserRequest $request)
    {
        $user = User::findOrFail($id);

        $requestData = $request->all();

        $requestData["password"] = Hash::make($request->password);

        $user->update($requestData);

        Session::flash('user_updated','Dane użytkownika zostały zaktualizowane');

        return redirect('users');
    }

jcmargentina left a reply on Issue With Retrieving Data

what is the output of the console.log instruction ?

also ... open the developers tools of your browser, and go to the network tab, click your button, and check the request you are making ... let me know if you can see the "comment_id" field in the request.

PD: realted to the changes I proposed you, ... It is high recommended that you always return a stated response from your server. If you dont, it is HTTP-antipattern.

you need to debug the whole cycle of this.

Regarding this ...

Could the problem be possible that its a foreach so their is multiple comment_id's and multiple approval buttons?

should not be a problem