Nash

Nash

Member Since 3 Years Ago

Experience Points 89,880
Experience Level 18

120 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 107
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.

25 Jun
1 day 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
2 days 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
4 days 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
6 days 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
1 week 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 week 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 week 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
2 weeks 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
2 weeks 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
2 weeks 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
2 weeks 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
3 weeks 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
3 weeks ago

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

For more information about this error go to ...

27 May
4 weeks ago

Nash left a reply on Heroku Laravel 403 Forbidden - Tried All Possible Options But Cant Show Page

 ReflectionException
Class App\Http\Controllers\indexController does not exist

Is the controller supposed to have a lowercase "i" in its name or is it actually IndexController? Linux is case-sensitive while Windows is not (in most cases), so you might need to check your file/controller names if you've been developing on Windows.

Nash left a reply on Heroku Laravel 403 Forbidden - Tried All Possible Options But Cant Show Page

Also, that's not what the default Laravel .htaccess file is supposed to look like?

Try using the default file: https://raw.githubusercontent.com/laravel/laravel/master/public/.htaccess

...or the alternative one in the docs: https://laravel.com/docs/5.8/installation#pretty-urls

...and check the Procfile like I said, it should not have quotation marks.

I also added an .htaccess to the root directory. This page isnt working and the logs are... Why would you need do that? Don't randomly change or add things, otherwise it will be impossible to figure out where the actual problem is. Read the docs for Heroku and Laravel.

Nash left a reply on Heroku Laravel 403 Forbidden - Tried All Possible Options But Cant Show Page

@ADRIANMCG85 - Did you make changes to index.php? I think the default line should be:

require __DIR__.'/../vendor/autoload.php';

Nash left a reply on Heroku Laravel 403 Forbidden - Tried All Possible Options But Cant Show Page

Are those quotes in your Procfile? If so, remove them.

20 May
1 month ago

Nash left a reply on SSH Php Version Not The Same As Vagrant

Vagrant/Homestead is a virtual Ubuntu machine with its own PHP installation. The other one is probably the version you have installed on your own machine. You can change the PHP version in Homestead by running php71 (for 7.1) or some other version. You can also change the version per-project in you Homestead.yaml file.

https://laravel.com/docs/5.8/homestead#multiple-php-versions

17 May
1 month ago

Nash left a reply on Serve Many Laravel Apps (virtual Hosts) On One VPS WITHOUT DOMAIN

You can use one IP with multiple domains/subdomains or you can use multiple IP's (or different ports) and no domains but I don't think you can easily use one IP with multiple apps like you describe. A domain. Hover.com has domains for as low as $4.99/year so it's not a huge investment.

See this article: https://www.tecmint.com/apache-ip-based-and-name-based-virtual-hosting/

15 May
1 month ago

Nash left a reply on Auth Data Empty

@van1310 It would seem that your user is not authenticated (logged in). Also, the $pin=$user line does nothing; there is no variable with that name.

@munazzil How does adding the auth middleware and type hinting a user in the controller?

08 May
1 month ago

Nash left a reply on Screen Reader Accessibility Inquery

This has more to do with how the front end (HTML, CSS, JS) is put together in terms of semantics, UI controls and visibility. Not so much related to Laravel itself.

The Bootstrap framework (default in Laravel) should have good accessibility and is well documented: https://getbootstrap.com/docs/4.3/getting-started/accessibility

MDN:

03 May
1 month ago

Nash left a reply on Do I Need Cron To Use Schedulers On Homestead?

Have you tried vagrant reload --provision?

23 Apr
2 months ago

Nash left a reply on Many To Many Table Name Suggestion

Laravel will probably look for a table named item_category_vendor_company but you name it whatever you want and pass the name of the table as the second parameter in your belongsToMany relationship, e.g. $this->belongsToMany('App\VendorCompany', 'name_of_intermediate_table');.

From the docs (example with users and roles):

To define this relationship, three database tables are needed: users, roles, and role_user. The role_user table is derived from the alphabetical order of the related model names, and contains the user_id and role_id columns.

https://laravel.com/docs/5.8/eloquent-relationships#many-to-many

You can define the belongsToMany relationship between your models and see which table Laravel is looking for by default when you try to fetch the data from the non-existing table.

Nash left a reply on Laravel Learning Path

Laravel 5.7 from scratch should be fine. The latest version is 5.8 so you can always watch What's new in 5.8 afterwards if you want but not much has changed.

Nash left a reply on Prerequisites Before Learning Laravel?

Some basic knowledge of PHP, HTML, SQL and Object-oriented programming (OOP) is recommended. If Laravel from scratch seems difficult, try the PHP Practitioner and Object -Oriented Bootcamp series first.