Nash

Nash

Member Since 3 Years Ago

Experience Points 85,670
Experience Level 18

4,330 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 101
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.

23 Apr
1 day 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.

16 Apr
1 week ago

Nash left a reply on View [admin.users.index] Not Found. In Local It Works For Me, But In The Server Of Heroku Not

@CHECHOGROM - Apparently, this can still be a problem on Windows even if you are using Homestead. Check the names for the relevant files and folders.

https://stackoverflow.com/questions/26483867/how-to-handle-files-in-case-sensitive-way-in-vagrant-on-windows-host

Nash left a reply on View [admin.users.index] Not Found. In Local It Works For Me, But In The Server Of Heroku Not

Are you developing on Windows? Make sure your directories and files are named exactly like in your controller (currently all lowercase). Linux filesystem is case-sensitive, Windows is not.

15 Apr
1 week ago

Nash left a reply on The Mix Manifest Does Not Exist.

Um...you're not supposed to delete the public folder...it's the entry point for your application. In fact, don't remove anything you don't know the purpose of. I suggest you do a fresh install.

11 Apr
1 week ago

Nash left a reply on Can I Omit PHP Docblocks If I Type Hint Parameters And Return Values?

Docblocks are not solely for giving hints about used types in the source code file. It is used for generating documentation (e.g. using phpDocumentor, Doxygen etc.) and describing/explaining your methods. Whether you choose to use them or not is up to you.

10 Apr
2 weeks ago

Nash left a reply on Laravel 5.5 PHP Error

PHP 7.0 has reached end of life and is no longer supported. If your hosting refuses to upgrade it then you should consider switching to another provider.

https://www.php.net/supported-versions.php

06 Apr
2 weeks ago

Nash left a reply on How To Hide Ajax Url From The User's Perspective In Js?

@ALIHOUSHYARIPOUR - Session should be fine but it depends entirely on your use case. What are you trying to protect and from whom? A regular Auth::check() will verify that the user is still logged in if that is what you want to know. You can also check for specific URL parameters or verify some sort of ID against something in your DB...it's all up to you.

Nash left a reply on How To Hide Ajax Url From The User's Perspective In Js?

You don't. The requests would still be visible through the Network tab.

You don't protect routes by "hiding" them from the user, you protect them by adding authentication (e.g. "regular" session-based or some sort of token, popular with API's) and authorization (checking that a particular user is really allowed to do something).

02 Apr
3 weeks ago

Nash left a reply on Hacked

@jai6150 Like others have said: the domain should point to the public directory and nothing above said directory should be made available or even uploaded to any sort of public directory (hidden or not). It could also be that your application is vulnerable to things like path traversal attacks, XSS, etc. due to the way it's coded or perhaps the server is not properly configured or protected.

It's impossible to tell without fully knowing your project, its code and its setup. Regardless, these things are not specific to the Laravel framework itself and any framework will be vulnerable when used incorrectly.

Learn about common OWASP vulnerabilities and how to protect against them: https://www.cloudflare.com/learning/security/threats/owasp-top-10/

30 Mar
3 weeks ago

Nash left a reply on Laravel SMTP Mail Error (mailtrap)

Try with MAIL_PORT=465 and MAIL_ENCRYPTION=tls

26 Mar
4 weeks ago

Nash left a reply on The Best Forum For React Native

React Native's own community page has a pretty extensive list on the topic: https://facebook.github.io/react-native/help

24 Mar
1 month ago

Nash left a reply on Laravel Ancessor

You can use PHP's number_format function to show a number with two decimal places, e.g. number_format($value, 2) Note that this returns a string and is not the same things as rounding the value. If you need a float and want to do calculations you can do so before formatting and displaying the final value.

Nash left a reply on Return Eloquent Model With Extra Data

Just add that method to your model and call it with $model->path()? If you would like to access it as an attribute, e.g. $model->path, you can name the method getPathAttribute() (i.e. define an accessor) and Laravel will take of it for you.

https://laravel.com/docs/5.8/eloquent-mutators#defining-an-accessor

21 Mar
1 month ago

Nash left a reply on Php Version Problem When Deploying Laravel Project

A little off topic but since you mentioned cPanel and multiple projects, I just want to make sure that you are not on shared hosting and uploading all your project directly to public_html? Because that would leave your .env file (and all other application files) exposed.

Nash left a reply on Database Does Not Exist When Trying To Use MySQL For PHPUnit Tests

Try removing DB_DATABASE from phpunit.xml and only specify the name of your connection (DB_CONNECTION). Then in config/database.php, set the database to 'testing' directly, i.e.

'testing' => [
   // driver, host, etc...

   'database' => 'testing',

  // ...
];

Is it still giving you any error messages?

Nash left a reply on How To Make Exmaple.test Local Domain Name

The most basic way to accomplish this is to edit the hosts file located under C:\Windows\System32\drivers\etc\hosts and add the following line:

10.2.33.11 example.test

Note that editing this file requires administrator privileges. The easiest way is to open something like Notepad with right-click -> "run as administrator" and then proceed to opening the hosts file from within the editor (File->Open). It might be a hidden file, so make sure you display those in your file explorer.

Nash left a reply on How To Run Scheduler In Forge?

You can add scheduled jobs under Server Details -> YOUR SERVER -> Scheduler, e.g. php /home/forge/your-site/artisan schedule:run

16 Mar
1 month ago

Nash left a reply on Database Does Not Exist When Trying To Use MySQL For PHPUnit Tests

Can you show us your config/database.php, phpunit.xml and an example test?

Nash left a reply on Database Does Not Exist When Trying To Use MySQL For PHPUnit Tests

Are you also using the RefreshDatabase trait in your test class? Are you caching the config? Try running php artisan config:clear and restart your local server.

Nash left a reply on Database Does Not Exist When Trying To Use MySQL For PHPUnit Tests

Are you using the correct DB_CONNECTION in phpunit.xml?

Nash left a reply on Why Does Authorize() Add Blocking For Guests?

Yes, this is the expected behavior. You can allow guest users by adding null as a default value for the $user parameter or by using "optional" type hint.

public function showApproved(?User $user, Event $event) 
{

}

https://laravel.com/docs/5.8/authorization#guest-users

Nash left a reply on Error In Migration With Use Prefix Set In Modal Constructor

Is it really necessary to use all those variables though? You are still hard coding a bunch of field names all over the query so it seems that there is little to gain by trying to add the table name through a variable like that. It arguably only makes it more difficult to read and to get it right. See if you can first get it to work at all and then refactor it if you feel the need to.

Nash left a reply on Error In Migration With Use Prefix Set In Modal Constructor

"Count" is actually one of the cases where a raw query can come in handy. You can do something like DB::raw('count(*) as some_count') for that particular parameter. Just remember to add the prefix manually to the table name for that particular statement, for example by using DB::getTablePrefix(). If you are unsure whether the string is correct, check it with dd(). Also, read the error messages to figure out where the error is.

15 Mar
1 month ago

Nash left a reply on Testing File Upload And Resizing Won't Work

The "resize part" is saving the image to the real storage while the fake storage used by the Storage facade is actually located under storage/framework/testing/disks. Use the store method on the request, Laravel's Storage facade or change the $path depending on the environment. Something like this should also work:

// Image::make(), fit(), etc...

Storage::put($path, (string) $image->encode('jpg', 100));

Nash left a reply on How To Restrict/limit Resource Edit Without An Login System?

Maybe use Signed URLs that expire after use or a certain period of time? Or you could have the user click some sort of "save and lock" type of button that locks down the post after editing (or just do it automatically after a certain period of time)?

Nash left a reply on AssertStatus Giving Errors

Are you running an outdated version of phpunit globally? Try to run it with vendor/bin/phpunit instead of phpunit.

Nash left a reply on How To Delay A Job For Next Week?

Rather than delaying it, you may want to take a look at Task Scheduling. With task scheduling you can, for example, have your application do a specific task every week, or check every hour if a certain task is ready to be executed (could be based on a timestamp or some other field in the db or whatever you want).

Nash left a reply on Error In Migration With Use Prefix Set In Modal Constructor

Every column you select needs be a separate parameter, not all in the same string, for example:

// Like this
->select('votes.*', 'vote_categories.name as vote_category_name', 'vote_categories.slug as vote_category_slug');

// NOT like this
->select("votes.*, vote_categories ...etc");

Nash left a reply on Error In Migration With Use Prefix Set In Modal Constructor

What error message are you getting without DB::raw()? Are some of your tables without a prefix in the database?

Nash left a reply on Error In Migration With Use Prefix Set In Modal Constructor

@petrogromovo Like I said, Laravel will handle the prefix for you automatically if you set it in config/database.php. No need to specify it in the model or anywhere else. SQL joins using the query builder should work without any need to manually inject the prefix when used as described in the documentation:

https://laravel.com/docs/master/queries#joins

DB::raw() is a raw query and needs the full name of the table, i.e. this is the only case where you need to manually specify the prefix before the table name (you can do this with DB::getTablePrefix()) but the use of raw queries seem completely unnecessary in this case.

Nash left a reply on Error In Migration With Use Prefix Set In Modal Constructor

There should be no need to use DB::raw() all over the query like that to do a simple join + select. See the docs: https://laravel.com/docs/master/queries#joins

14 Mar
1 month ago

Nash left a reply on Error In Migration With Use Prefix Set In Modal Constructor

Take a look at the error messages you are getting and try to work from there.

For example:

"SQLSTATE[HY000]: General error: 1364 Field 'text' doesn't have a default value"

This suggests that you are doing an insert without providing a unique value for "text".

@munazzil It makes no sense to remove the unique constraint unless that is the desired behavior (which only OP knows).

Nash left a reply on How Does Laravel/Blade Handle Assets ?

The path you have specified is relative to your current URL. This is not specific to Laravel but to how HTML works. If you put a slash (/) before your path, it will always refer to the root. You could also just add the full URL or use Larvel's asset helper: src="{{ asset('global_assets/js/plugins/visualization/d3/d3.min.js') }}"

Nash left a reply on Error In Migration With Use Prefix Set In Modal Constructor

You should not need to specify the prefix anywhere but in config/database.php. Laravel will take care of this behind the scenes. $protected $table can be without a prefix and Laravel will still find the right table.

13 Mar
1 month ago

Nash left a reply on Laravel Won't Send Mail With 25 Port And No Encryption

It's hard to say without knowing more about your setup. Is your mail driver set to sendmail or mail? Do you even have sendmail or postfix installed and configured on your server?

If you are new to all this, it might be easier to use one of the many mail services supported by Laravel. Mailtrap is great for testing.

https://laravel.com/docs/master/mail#introduction

Nash left a reply on Error In Migration With Use Prefix Set In Modal Constructor

Why are you trying to manually specify the prefix like that instead of setting it in config/database.php like you are supposed to?

Nash left a reply on Selecting Row Number 2

This question seems to be about CodeIgniter's active record class (NOT Laravel)? You should mention that to avoid confusion.

Nash left a reply on How To Test Mail Sent From Notification

@bYou could test that the channel is set correctly, e.g. $this->assertEquals(['mail', $notification->via($request->user())]), or however you are specifying the preferred channel. There is no point in testing the framework itself since that has already been tested. If Laravel is set to send an email you should trust that it will do so.

12 Mar
1 month ago

Nash left a reply on How To Test Mail Sent From Notification

Use Notification::fake() and Notification::assertSentTo()instead.

https://laravel.com/docs/master/mocking#notification-fake

06 Mar
1 month ago

Nash left a reply on Git Is Not Tracking My Config/database.php

Are you sure it's really the config and not a problem with Heroku's environment variables:

https://devcenter.heroku.com/articles/config-vars#managing-config-vars

Can you tell us what error message you are getting?

01 Mar
1 month ago

Nash left a reply on Where Can I Find My Receipt After Payment For Laracasts Subscription?

You can view your invoices under account settings -> invoices. No need to contact support.

https://laracasts.com/settings/subscription/invoices

27 Feb
1 month ago

Nash left a reply on Overriding Properties Of Trait

Like this Stackoverflow thread states, you can't override the property directly in the class where the trait is used. You can, however, override it in a child class or in the constructor:

https://stackoverflow.com/questions/32571920/overriding-doctrine-trait-properties

Nash left a reply on Overriding Properties Of Trait

@DANNY620 - Like @tykus said, you could just define the property on the class. You could still have a default in your trait, e.g.

trait MyTrait
{
    protected $defaultAddressLine = 'address'; 

    public function getAddressAttribute()
    {
        return $this->customAddressLine ?? $this->defaultAddressLine;
    }
}

class MyModel
{
    protected $customAddressLine = 'address_custom';
}

Nash left a reply on Overriding Properties Of Trait

Well the properties in your trait are static and the ones in your model are not.

26 Feb
1 month ago

Nash left a reply on Global Variable In Laravel

Global variable? Do you mean like a class property?

class MyController extends Controller
{
    public $id;

    public function __construct()
    {
        $this->id = Str::random();
    }

    public function someFunction()
    {
        dd($this->id);
    }
}

25 Feb
1 month ago

Nash left a reply on Confused About Concepts

@dalot You're welcome. Please mark this question as solved if you found your answer.

Nash left a reply on Confused About Concepts

The following Laracasts series should give you some pointers and hands-on examples:

23 Feb
2 months ago

Nash left a reply on Laravel Logging To Gzip Rather Than .log

@sunny_jay_jay You're welcome. Please mark the question as solved.