chriz74

chriz74

Member Since 3 Years Ago

Experience Points 17,805
Experience Level 4

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

05 Feb
1 month ago

chriz74 started a new conversation Laracasts Nav Broken

The nav of laracasts.com is broken at 1366x768 screen resolution. It only shows half vertically.

26 Nov
3 months ago

chriz74 left a reply on What Does This Even Mean? ( Validate In Laravel 5.7)

ok I get it. No, I am validating some requests with some rules. I didn't write any base-validator, afaik.

chriz74 left a reply on What Does This Even Mean? ( Validate In Laravel 5.7)

Thanks for your reply, however it's not clear to me what "implementing the interface" means in this context.

chriz74 started a new conversation What Does This Even Mean? ( Validate In Laravel 5.7)

From the 5.7 guide:

"The Validator Contract Likelihood Of Impact: Very Low

The validate method was added to the Illuminate\Contracts\Validation\Validator contract:

/**

  • Run the validator's rules against its data.
  • @return array */ public function validate(); If you are implementing this interface, you should add this method to your implementation."

So? What does this mean? "add this method to your implementation" ?? I have some validation going on and now I get "unhandled validation exception yada yada"

18 Jul
8 months ago

chriz74 left a reply on Is There A Package To Show Posts Singularly On An Overlay Like Fb Or IG Do When You Click A Pic?

@Cronix what do you think is better practice: put the div in the page as hidden and then show it on click or put it in the dom through javascript after click and then remove it?

chriz74 left a reply on Is There A Package To Show Posts Singularly On An Overlay Like Fb Or IG Do When You Click A Pic?

Thanks however I don’t think they are using modals on IG or FB, check it with dev tools. FB is a bit of a mistery to me as it seems it’s adding an empty div as the background and then the post stuff will be on a different div. on Instagram instead what happens is they add a div with all the content and then remove it from the dom after you close it.

chriz74 started a new conversation Is There A Package To Show Posts Singularly On An Overlay Like Fb Or IG Do When You Click A Pic?

If you go to Fb or IG when you click on a picture in the desktop version the post will be shown on an overlay semi transparent div with the pic itself and a box on the right for description and comments etc. Does anyone know how to technically fo that or if there's a package than can create this kind of layout on the fly?

06 Jul
8 months ago

chriz74 left a reply on Pagination HTML Element (ul.pagination) Takes Forever To Hide

I think I found a simple solution by adding the links in the page inside an hidden div:

chriz74 left a reply on Pagination HTML Element (ul.pagination) Takes Forever To Hide

That is triggered in the last page.

chriz74 left a reply on Pagination HTML Element (ul.pagination) Takes Forever To Hide

Because the script uses the links to load the rest of the content and if it has no links then it will not load anything more then the first page.

chriz74 started a new conversation Pagination HTML Element (ul.pagination) Takes Forever To Hide

I followed this tutorial for implementing infinte scroll:

https://laraget.com/blog/implementing-infinite-scroll-pagination-using-laravel-and-jscroll

It works however the pagination links do not get hidden in time.

the code used in the script is $('ul.pagination').hide(); If I scroll down I can see them and they disappear after 1 or 2 seconds. Obviously this is ugly. Any clue? I tried to use var x = document.getElementsByClassName("ul.pagination"); and set the style to display.none but I get an error .. x is undefined (while it is very defined).

03 Jul
8 months ago

chriz74 started a new conversation Gulp Watch Causing Terminal Notification Spam / Loop

I am still using gulp in my Laravel project as I refuse to use webpack which is a complete mess. My gulpfile is like this:

var elixir = require('laravel-elixir');
elixir.config.css.sass.pluginOptions.precision = 10;
elixir.config.sourcemaps = false;

/*
 |--------------------------------------------------------------------------
 | Elixir Asset Management
 |--------------------------------------------------------------------------
 |
 | Elixir provides a clean, fluent API for defining some basic Gulp tasks
 | for your Laravel application. By default, we are compiling the Less
 | file for our application, as well as publishing vendor resources.
 |
 temp
 */

elixir(function (mix) {

    mix.sass('app.scss')

        .browserify('app.js')

        .copy('resources/assets/libs/font-awesome-4.6.3/fonts', 'resources/fonts')

        .copy('node_modules/jquery-ui-bundle/images', 'public/css/images')

        .scripts('script.js')

        //various other scripts

        .scripts('scriptN.js');

});

I am still using gulp in my Laravel project as I refuse to use webpack which is a complete mess. My gulpfile is like this:

var elixir = require('laravel-elixir'); elixir.config.css.sass.pluginOptions.precision = 10; elixir.config.sourcemaps = false;

/* |-------------------------------------------------------------------------- | Elixir Asset Management |-------------------------------------------------------------------------- | | Elixir provides a clean, fluent API for defining some basic Gulp tasks | for your Laravel application. By default, we are compiling the Less | file for our application, as well as publishing vendor resources. | temp */

elixir(function (mix) {

mix.sass('app.scss')

    .browserify('app.js')

    .copy('resources/assets/libs/font-awesome-4.6.3/fonts', 'resources/fonts')

    .copy('node_modules/jquery-ui-bundle/images', 'public/css/images')

    .scripts('script.js')

    //various other scripts

    .scripts('scriptN.js');

}); I read font awesome my be causing this loop and the solution suggested is to move fonts from public/fonts to resources/fonts, which as you can see I already did however nothing changed. Laravel version is 5.6.26 and gulp versions is

gulp -v
[19:22:34] CLI version 3.9.0
[19:22:34] Local version 3.9.1
20 Jun
9 months ago

chriz74 left a reply on Validation Not Working As Expected

I think I found the solution, I modified it like this:

'price' => 'nullable'numeric|max:99999',

is this new in Laravel? Because the same validation rule was working normally before and now I am on Laravel 5.6.17

chriz74 started a new conversation Validation Not Working As Expected

I have a form with a "price" input. The user can leave this input blank, so I validate it like this:

'price' => 'numeric|max:99999',

So if I leave the input empty and submit the form I get "422 Unprocessable Entity"

{"message":"The given data was invalid.","errors":{"price":["The price must be a number."]}}

I know it must be a number, in this case it's null but the input is not required in the validation so what's Laravel complaining about ?

12 Jun
9 months ago

chriz74 left a reply on Can't Use Raspberry Pi 3B+ As A Local Server To Run Laravel...

That is not a fix, that’s a workaround. I won’t touch my code like that.

chriz74 left a reply on Can't Use Raspberry Pi 3B+ As A Local Server To Run Laravel...

No, the fix doesn’t work and there is no armhf version of mariaDB that solves this.

chriz74 left a reply on Can't Use Raspberry Pi 3B+ As A Local Server To Run Laravel...

It’s not a fresh install. It’s a project that I am developing on my Mac and I want to run on the raspberry for testing.

11 Jun
9 months ago

chriz74 started a new conversation Can't Use Raspberry Pi 3B+ As A Local Server To Run Laravel...

Long story short, the raspbian stretch distro doesn't have mysql, it has mariaDB version 10.1 .. it fails to migrate the database with error 1709, it complains about some indexes being too long. None of the solutions suggested work, included the one to add

use Illuminate\Support\Facades\Schema;

public function boot()
{
    Schema::defaultStringLength(191);
}

in appServiceProvider. Did anyone succeed in some exoteric way?

04 Jun
9 months ago

chriz74 left a reply on Validate Route Where Id Is A Username

ok so even if I don't add that in the route I am immune to sql injection and the likes is that right?

chriz74 started a new conversation Validate Route Where Id Is A Username

I got a route to user pages that other users can see while browing the site.

the route is like this:

Route::get('user/{id}', '[email protected]')->middleware('auth');

The question is, how do I validate the id here? It must be the username. So in my controller I should validate it, or can I just add something in the route? Also, should I continue in this path or ditch it for numbered ids page? Now a user can follow a link like www.myproject.com/users/username and see their page, i like it this way better than something like www.myproject.com/users/1

29 May
9 months ago

chriz74 left a reply on Can't Run A Test App On Skysilk Vps -> Forbidden

I also added the path to www-data whatever...

chriz74 started a new conversation Can't Run A Test App On Skysilk Vps -> Forbidden

I am trying to put up a test app on skysilk vps, I added it to my folder /home/user/www/test I added vhost, hosts and all the stuff. If I go to the page it tells me Forbidden.

11 May
10 months ago

chriz74 left a reply on Do We Need To Validate User Input Using Regex To Prevent SQL Injection?

@jlrdw ok but doesn't laravel itself perform the stripping? I tried to input something like "some text alert("boom") some text" and the resulting post is "some text some text". That without the regex in validation rules that I now changed to body' => 'required|string'

chriz74 started a new conversation Do We Need To Validate User Input Using Regex To Prevent SQL Injection?

I was reading this article:

https://www.cloudways.com/blog/prevent-xss-exploits-using-laravel-validation-and-sanitization/

This guy tells to prevent user from inputting malicious code in posts or comment etc it's advisable to use regex in the validation like this:

'names' => 'required|max:255|regex:[A-Za-z1-9 ]',

In my code I have a comment controller that I was validating like this:

$rules = array(

            'post_id' => 'required',
            'body' => 'required'
        );

I tried to input this code in the post <script>alert("boom")</script> and the result is that the post succeed but empty so I guess laravel is deleting that input. Am I right or am I missing something?

09 May
10 months ago

chriz74 left a reply on RAW Queries And SQL Injection

@jlrdw what is $con in $sth = $con->prepare ?

08 May
10 months ago

chriz74 left a reply on RAW Queries And SQL Injection

@jlrdw maybe I didn't make myself clear. The original query works perfectly as my $ids is a string I get like this:

        $plucked_ids = $models_ids->pluck('id')->toArray();

                $ids = join(",", $plucked_ids);

With that I get a string ( $ids) that I pass to the SQL query and it works. However if I try to pass the same string to the placeholder :ids the string is not passed. So the placeholder is not getting any data.

chriz74 left a reply on RAW Queries And SQL Injection

@jlrdw Thanks for your reply however I don't get it. If I dump $params this is the result:

array:1 [
  ":ids" => "35,36,69,73,98,218,219,234,242"
]

So :ids has the data, so why it's not passed correctly?

chriz74 left a reply on RAW Queries And SQL Injection

the solution works if the query has one id to look for. But what if I need to search for multiple ids?

in the query it will be

AND item.id IN ($ids)

where for example

$ids = "35,36,69,73,98,218,219,234,242"

if I put ':ids => $ids in the params and pass them as

AND item.id IN (:ids)

I get 0 results

05 May
10 months ago

chriz74 left a reply on RAW Queries And SQL Injection

@rsvb thanks for the explanation however if the point is to pass a string to the query can't we just cast the parameters to string and keep the RAW query? What difference does it make?

04 May
10 months ago

chriz74 left a reply on RAW Queries And SQL Injection

@jlrdw This works. I had to cast the result to an array like this:

$models = array($sth->fetch(\PDO::FETCH_OBJ)) ;

to be able to traverse it with my routines.

chriz74 left a reply on RAW Queries And SQL Injection

@36864 I tried running the query in the ide, I can still see it's passing something like $id OR 1=1 .. however the IDE is asking me to input the data so maybe it's not considering the bindings. I have to find a way to output the query in the browser.

chriz74 left a reply on RAW Queries And SQL Injection

@36864 ok, however the only data passed by the user is $id, those others are set inside the controller. by the way it's [ or ( ? ['data_type' => $user_data_type, 'user_type' => $user_type, 'id' =>$id) and am I not passing bindings like this:

        array(
                    
                    'input_id' => $id,

                    )

as in the original question

chriz74 left a reply on RAW Queries And SQL Injection

@jlrdw Like this?

$params = array(':id' => $id);

$pdo->prepare('

//That long RAW query   

');

$pdo->execute($params);

chriz74 left a reply on RAW Queries And SQL Injection

However, since the $id comes from this kind of request url:

http://myproject55.test/model/{id}?_method=get

Can't I just add a constraint to the route like this:

Route::get('model/{id}', '[email protected]')->where('id', '[0-9]+')->middleware('auth');

This way id can only be numeric

chriz74 left a reply on RAW Queries And SQL Injection

@jlrdw @Vilfago

Ok this is the exact query, how do you convert to eloquent without using a DB:RAW?

the only data passed by the user is $id

    $models = DB::select(DB::raw("SELECT
                Count(collected_items.model_type_id) AS total_collected,
                       producers.producer,
                       item_models.id,
                       item_models.model_name,
                       lengths.mm,
                       item_models.picture,
                       item_models.color,
                       item_models.material,
                       collected_item_user.collected_item_hand,

                       Count(CASE item_types.id WHEN '1' THEN item_types.id ELSE NULL END) AS '1',
                       Count(CASE item_types.id WHEN '2' THEN item_types.id ELSE NULL END) AS '2',
                       Count(CASE item_types.id WHEN '3' THEN item_types.id ELSE NULL END) AS '3',
                       Count(CASE item_types.id WHEN '4' THEN item_types.id ELSE NULL END) AS '4',
                       Count(CASE item_types.id WHEN '5' THEN item_types.id ELSE NULL END) AS '5',
                       Count(CASE item_types.id WHEN '6' THEN item_types.id ELSE NULL END) AS '6',
                       Count(CASE item_types.id WHEN '7' THEN item_types.id ELSE NULL END) AS '7',
                       Count(CASE item_types.id WHEN '8' THEN item_types.id ELSE NULL END) AS '8',
                       Count(CASE item_types.id WHEN '9' THEN item_types.id ELSE NULL END) AS '9',
                       Count(CASE item_types.id WHEN '10' THEN item_types.id ELSE NULL END) AS '10',
                       Count(CASE item_types.id WHEN '11' THEN item_types.id ELSE NULL END) AS '11',
                       Count(CASE item_types.id WHEN '12' THEN item_types.id ELSE NULL END) AS '12',
                       Count(CASE item_types.id WHEN '13' THEN item_types.id ELSE NULL END) AS '13',
                       Count(CASE item_types.id WHEN '14' THEN item_types.id ELSE NULL END) AS '14',
                       Count(CASE item_types.id WHEN '15' THEN item_types.id ELSE NULL END) AS '15'
                FROM   collected_items
                       INNER JOIN collected_item_user
                               ON collected_items.id = collected_item_user.collected_item_id
                       INNER JOIN users
                               ON collected_item_user.user_id = users.id
                       INNER JOIN item_types
                               ON collected_items.model_type_id = item_types.id
                       INNER JOIN item_models
                               ON collected_items.model_id = item_models.id
                       INNER JOIN producers
                               ON collected_items.producer_id = producers.id
                       INNER JOIN lengths
                               ON collected_items.length_id = lengths.id
                                  AND lengths.id = item_models.length_id
                                  AND producers.id = item_models.producer_id
                WHERE  users.data_type_id = $user_data_type
                       AND users.item_type_id = $user_type
                       AND users.data_x_id = 1
                       AND collected_items.model_id = $id

                GROUP  BY collected_item_user.collected_item_hand"));

chriz74 left a reply on RAW Queries And SQL Injection

@jlrdw As you can see from the question I am already passing the binding from an array yet the query gets executed without sanitization. I will post later the exact query and you tell me if it's possible to convert to eloquent without using RAW as I was not able.

03 May
10 months ago

chriz74 left a reply on RAW Queries And SQL Injection

@jlrdw thanks for the links, I'll check them out but my query is rather complex and I need to do it as RAW, there's no way to convert it to eloquent.

chriz74 started a new conversation RAW Queries And SQL Injection

I have a a raw query like this:

$data = DB::select(DB::raw("SELECT
                Count  //something
                FROM   //table

                       // some joins
                       
                WHERE  users.data_id = $somevariable
                       AND // something else
                       AND // something else 
                       AND data.id = :input_id

                GROUP  BY // something")

                , array(
                    
                    'input_id' => $id,

                    ));

I used the solution suggested at http://fideloper.com/laravel-raw-queries to pass the user input as :input_id from an array:

                  array(
                   
                   'input_id' => $id,

                   )

However if I try this query in the ide with something like 218 OR 1 = 1 I can see clearly that the data is passed to the query

AND data.id = 218 OR 1 = 1

So I think that is not sanitizing anything at all. Clues?

02 May
10 months ago

chriz74 left a reply on What Framework / Template For A Webapp With Idea To Convert To Native App?

Yeah I know that @jlrdw , however I don't want to spend too much time learning css from scratch.

chriz74 started a new conversation Discriminate Between Searches With One Search Input Box

I have a search form in my nav bar, at the moment it just searches for user posts. I want to make this search broader and let the user decide to search for other data, for example models, users, etc. Since I am using autocomplete in the form now when the user starts typing he gets results of what is in the DB and can be searched. My though was I can fill this autocomplete array with some prefixes like "models: " . $value "posts: " . $value" etc and then strip the prefix from the search in the controller so that only the $value is searched.

example in pseudo code:

if ($prefix == "models "){

    search in model table;

}
else if ($prefix == "posts "){

    search in posts table;
}

However maybe it would be better to show some way the prefix as ghost txt in the form and then discriminate by setting a data value like $search_type in the form query.

Any tip?

chriz74 started a new conversation What Framework / Template For A Webapp With Idea To Convert To Native App?

At the moment I am using bootstrap and I used it all the time to set basic pages and test the code etc. Now I have to decide the look of the project. I see there are many bootstrap alternatives however I don't know what could be a good decision. Any suggestion?

29 Mar
11 months ago
24 Mar
1 year ago

chriz74 left a reply on Doubt Re Time Impact Of Notifications Loop In Controller

@martinbean thanks for the suggestion however my understanding is that with built in notifications we are past the event / listener methods. Am I wrong? I was able to create a notification and an observer using a package that fires new events for many to many relations.

22 Mar
1 year ago

chriz74 left a reply on How To Include Masonry In App.js Using Gulp?

edit: actually doing like that it gets into the browserified app.js. Am I missing anything though?