Nash

Nash

Member Since 3 Years Ago

Experience Points 90,530
Experience Level 19

4,470 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 200
Lessons
Completed
Best Reply Awards 108
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.

17 Jul
1 day ago

Nash left a reply on PHP Laravel Framework 5.5.40 / 5.6.x < 5.6.30 - Token Unserialize Remote Command Execution

This issue has already been addressed and fixed. If you are using an up-to-date version of Laravel and you don't use cookie serialization, you should be in the clear. The vulnerability also needs the app key to be exploited.

https://laravel.com/docs/5.5/upgrade#upgrade-5.5.42

15 Jul
3 days ago

Nash left a reply on Cashier For Braintree Abandoned!?

Well Braintree still has a PHP SDK but you would have to integrate it yourself if Cashier no longer supports it. If Cashier is still working you may be fine for now but there's no telling whether it will break in a future update. You could fork the Laravel Braintree package but it's probably no small task to keep it up to speed with Laravel and any potential Braintree API changes. You could also consider switching to Stripe and integrating PayPal manually.

Nash left a reply on Cashier For Braintree Abandoned!?

What is the best option now?

Stripe?

12 Jul
6 days ago

Nash left a reply on Laravel Mail Working Locally But Not On Server

Try with MAIL_ENCRYPTION=tls as well

11 Jul
1 week ago

Nash left a reply on Deep Replication (Model + Relations)

@holm There is also a package named Cloner that could help with this.

Laravel news article: https://laravel-news.com/eloquent-cloner-package

Nash left a reply on Undefined Variable: Products For PDF

The line in your controller should be compact('products') instead of compact($products).

10 Jul
1 week ago

Nash left a reply on How To Show Existed Category Name In My Post Edit Form

@bikal Probably just a basic edit function that fetches the post and some categories and passes them to the view, for example:

public function edit(Post $post)
{
    $categories = \App\Category::all();
    return view('posts.edit', compact('categories', 'post');
}

But I obviously can't know what OP's controller really looks like...

Nash left a reply on Laravel 5.8 Memory Leak

I haven't looked into this but if you really think you've found an actual memory leak, you should probably open up an issue at the official github repo so that the devs can comment on it:

https://github.com/laravel/framework/issues

01 Jul
2 weeks ago

Nash left a reply on Edit: Regex For Email

Something like this, for example. Modify to your own needs:

Validator::make($request->all(), [
    'email' => [
        // the standard "email" rule
        'email',
    // custom validation rule (using closures)
        function ($attribute, $value, $fail) {
            // split the string at every "."
            $exploded = explode('.', $value);
            // check if the last piece of the string is found in the array below
             if (! in_array(end($exploded), ['fr', 'com'])) {
                  $fail($attribute.' is invalid.');
              }
            },
    ],
])

Nash left a reply on Edit: Regex For Email

Then ask for that instead of the "equivalent of FILTER_VALIDATE_EMAIL for Laravel".

You could probably do this using the regex rule or a custom validation rule.

Nash left a reply on FILTER_VALIDATE_EMAIL For Laravel

That would be the email rule, like you already have in your array.

https://laravel.com/docs/5.8/validation#rule-email

Nash left a reply on Capture Exec Output

Return it where? Are you actually doing anything with the $output variable? What does dd($output) return?

Nash left a reply on Capture Exec Output

The second parameter in exec is an array with every line of the output from the command.

exec('your command here', $output_array);

https://www.php.net/manual/en/function.exec.php

28 Jun
2 weeks ago

Nash left a reply on PHP Artisan Not Stopping

Are you using the Linux (WSL) terminal to launch the Windows CMD and run Windows programs/commands? This seems like a messy setup. I would rather install/run them directly under WSL, simply use Windows, or install Laravel Homestead (a virtual Ubuntu machine with everything you need for Laravel development) and then SSH into that.

You could also try MobaXterm. It gives you the basic UNIX tools and commands but should still be able to execute native Windows programs just like you would in CMD.

Nash left a reply on Testing Flash Messages And Redirects

Do you really need all 3 assertions? Is the session key the main thing you are trying to test or would it be enough to check the HTTP status (200 OK as opposed to some error code) + assertSee? Is there a situation where the session key is NOT set but the rest of the action would be successful?

25 Jun
3 weeks ago

Nash left a reply on Star Rating

There are numerous tutorials, packages and threads on this very topic, please do a search before asking.

Laracasts video: How Do I Create a Star-Rating System: Part 1

24 Jun
3 weeks ago

Nash left a reply on Post Requests Working Without CSRF Token

It's probably fetching it from the XSRF-TOKEN cookie?

https://laravel.com/docs/5.8/csrf#csrf-x-xsrf-token

22 Jun
3 weeks ago

Nash left a reply on Where To Find All Built In Classes In PHP

As you can see from the breadcrumbs (at the top of the page under the main menu), the ReflectionClass page is under Function Reference.

20 Jun
4 weeks ago

Nash left a reply on Versioning

Ah, I see now. One possible way would be to have separate branches for each release or version. One branch for v1, another for v2 and so on. You could still run them both side by side as different applications if you want to.

Here's a classic article on Git branching that I like to refer to from time to time: https://nvie.com/posts/a-successful-git-branching-model/

Example Nginx config (to give you an idea, I did not make or test this particular config): https://gist.github.com/mreschke/27bfafb84add38d3bab8

Nash left a reply on Versioning

You should definitely look into some version control system such as Git. There's even a Laracasts series on the topic:

https://laracasts.com/series/git-me-some-version-control

19 Jun
4 weeks ago

Nash left a reply on Set Restrictions In Migration

Well you can give the VARCHAR field a length (e.g. $table->string('name', 15)) but for the type of control that you are describing, you will need some sort of validation, for example using the size andregex rules:

https://laravel.com/docs/5.8/validation#available-validation-rules

The attributes in the form elements (HTML) can be easily modified by the user, you should always validate user input in the back end as well.

Nash left a reply on Intervention Image Not Resizing Image Greater Than 15mb

Is it the correct php.ini file? Try setting the limit in your code before the Intervention function:

ini_set('memory_limit', '1000M');

Nash left a reply on Where != Foo Also Excludes Null

This appears to be the case with SQL server at least, but you should be able to specifically tell it to include those rows as well e.g. by using ->orWhereNull('foo');

Nash left a reply on Where != Foo Also Excludes Null

Try

Model::where('foo', '!=', 'bar')
    ->orWhereNull('foo')
    ->get();

Nash left a reply on Where != Foo Also Excludes Null

Try

Model::where('foo', '!=', 'bar)
  ->whereNotNull()
  ->get();
17 Jun
1 month ago

Nash left a reply on PDOException::("could Not Find Driver")

You have DB_CONNECTION set to mysql in your previous post on a similar topic. Are you trying to use MySQL or SQLite?

Nash left a reply on PDOException::("could Not Find Driver")

Simply creating a new file will not create a new database in MySQL (SQLite works like this though).

Check out this basic guide on MySQL: https://www.digitalocean.com/community/tutorials/a-basic-mysql-tutorial

Nash left a reply on Unable To Do Php Artisan Migrate

Is MySQL actually running (check with systemctl status mysql.service) and have you created a database named meriki? If you are not using Homestead, did you create the migrations table by doing php artisan migrate:install?

14 Jun
1 month ago

Nash left a reply on How To Login Admin, Direct Go To Admin Panel

You can override the default redirect in app\Http\Controllers\Auth\LoginController.php by adding a protected redirectTo() method to the same file, something like:

// Add this method to app\Http\Controllers\Auth\LoginController.php
protected function redirectTo()
{
    if (auth()->user()->isAdmin()) {
        return 'path/for/admins/here';
    }
    return 'default/path/here';
}

@munazzil Your code does not make sense syntactically.

Nash left a reply on It Is That Possible To Gerate A New Class With A Custom Artisan Command ?

You could easily create a new file using file_put_contents() (or a combination of fopen(), fwrite() and fclose()), e.g. file_put_contents("path/to/file.php", "YOUR\nTEMPLATE\nHERE").

If you just need a quick way to create a basic class and/or some methods (like a constructor) to avoid retyping things, I would look into the snippet capabilities of your current editor/IDE instead.

Nash left a reply on Laravel 5.8 @can Not Working

The answer has already been given. The reason for your original error is in this snippet that you posted (but have now for some reason deleted from this thread):

public function roles()
{
    return $this->belongsToMany(Role::class);
}

public function hasRole($role){
    if(is_string($role)){
        return $this->roles->contains('name', $role);
    }
    return !! $role->bigIncrements($this->roles)->count(); // this is wrong!
}

The line with bigIncrements is wrong and it is unclear what you are trying to do. @can is not broken.

10 Jun
1 month ago

Nash left a reply on Optimizing Eloquent Query

@SCREWTAPE_MK - Hmm...you should probably limit the query regardless so it doesn't fetch everything if type is not set. Here's a slightly modified version of your example, see if playing around with this helps.

$countries = \DB::table('MY_TABLE')
    ->select('EmployeeService') // does selecting a single column help?
    ->when($request->type == 'EmpService', function ($query) use ($query1) {
        $query->where('EmployeeService','LIKE', $query1.'%')
            ->distinct(); // distinct instead of groupBy?
    })
    ->take(5) // always limit the query
    ->get();

return $countries;

What do you mean by slow and how much data is in that table? Are you sure it's not a client side problem? How long does it take for a single request in the network tab in dev tools?

09 Jun
1 month ago

Nash left a reply on Class 'Amranidev\Laracombee\facades\LaracombeeFacade' Not Found

The facade alias in the readme file's example uses a lower case "f" (like you have now) but the directory + namespace actually has a capital "F". Linux is case-sensitive so it will not find the class. I submitted a PR to fix this in the docs.

Nash left a reply on Optimizing Eloquent Query

Show your query. Make sure -take(5) comes before -get(), otherwise it will first fetch everything in the db and then take 5 from the resulting collection.

Also, make sure to actually read the query builder docs, it has plenty of examples on how to use things like select.

Nash left a reply on Deploy Base WordPress Build

Forge lets you save your own scripts as "Recipes". Forgerecipes.com has lots of examples to get you started.

Forge also has an official API that can be used to do pretty much anything: https://forge.laravel.com/api-documentation#uri

Nash left a reply on New Metric For Leaderboard

Some basic filters like sorting by number of Best reply awards, Experience and perhaps even time frame (all time, last year, etc.) could be nice. No single metric is perfect but ultimately, it's @jeffreyway who decides what the leaderboard should be like.

Nash left a reply on Optimizing Eloquent Query

Do you really need to fetch all results from the DB? That can be quite heavy if you have a large table. If it's for autocomplete, something like the top 10 nearest results is probably enough. You can limit the query with ->take() or ->limit(), e.g. $countries->take(10)->get();.

You are also looping through the results with foreach just to format it a little differently / fetch a single column? You could use ->pluck('EmployeeService') if you only need that column; in fact, you could probably ->select() a single column if you don't need the rest (the more you load, the heavier your query will be).

08 Jun
1 month ago

Nash left a reply on Start New Query Builder On Model's Table

A basic example to visualize:

Returns "Illuminate\Database\Eloquent\Builder"
dd( get_class(App\User::query()) );

// Returns "Illuminate\Database\Query\Builder"
dd( get_class(App\User::getQuery()) );

// Returns "Illuminate\Support\Collection"
dd( get_class(App\User::getQuery()->get()) );

Nash left a reply on Start New Query Builder On Model's Table

@ROBOROBOK - getQuery() exists on the Eloquent builder instance (Illuminate\Database\Eloquent\Builder), query() exists on Illuminate\Database\Eloquent\Model and returns a new instance of \Illuminate\Database\Eloquent\Builder.

Nash left a reply on Start New Query Builder On Model's Table

I notice now that you are calling getTable() only to get the name of the table for DB statement...difficult to see with all the parenthesis.

Anyways, calling getQuery() on the Eloquent model should get you the underlying Illuminate\Database\Query\Builder instance (as opposed to the Illuminate\Database\Eloquent\Builder instance). So something like, $model->getQuery()->get() would get a "pure" collection as you call it (an instance of Illuminate\Support\Collection).

Nash left a reply on Laravel Envoy: Use Command Output In PHP

Use exec

exec('git log --pretty=oneline', $output);

Nash left a reply on Start New Query Builder On Model's Table

You said something about getTable() but that just returns the name of the table? You could fetch the data as an array if you don't want Eloquent models or turn the array into an instance of Illuminate\Support\Collection. What do you expect the output to look like?

Nash left a reply on Start New Query Builder On Model's Table

Raw in what way? Would something like $query->toArray() work for you? Or perhaps collect($query->toArray())? Could be used in a query scope like @jlrdw suggested.

Nash left a reply on Update Column Based On Number Of Record? (Seeding)

You are not specifying which row to update. Try something like:

DB::table('artist_tag')->where('artist_id', $artist_id_here)->update(['song_id', $song_id_here]);
07 Jun
1 month ago

Nash left a reply on Laravel 5.8 @can Not Working

Like I said in my first answer:

...you are trying to call bigIncrements() on an Eloquent Collection somewhere in your code

Nash left a reply on Laravel 5.8 @can Not Working

Your error message suggests that you are trying to call bigIncrements() on an Eloquent Collection somewhere in your code.

04 Jun
1 month ago

Nash left a reply on Csrf Or Honeyspot

These are different things. The honey pot is just a first aid against spam in your forms, it is not intended as protection against CSRF or XSS.

Nash left a reply on Query To Select Data From Database Table And Array

Nothing in your query suggests that you actually need a raw query for this. Take a look at the query builder docs and update your code accordingly, particularly select, where and whereIn for the array. Using a variable in your raw query like that is dangerous and makes your application vulnerable to SQL injection

31 May
1 month ago

Nash left a reply on HTTP Error Occurred During File Upload (404: File Not Found).

For more information about this error go to ...