bpocallaghan / laravel-admin-starter

A Laravel Admin Starter project with Page Builder, Roles, Impersonation, Analytics, Blog, News, Banners, FAQ, Testimonials and more
http://bpocallaghan.co.za
337 stars 92 forks source link

Error running php artisan db:seed on MacOs #8

Closed noogen closed 6 years ago

noogen commented 6 years ago

This is possibly an issue on linux too where path uses forward slash (/). I add a var_dump and this is what I get:

Toms-MacBook-Pro:pledge tomn$ php artisan db:seed
Seeding: RoleTableSeeder
Seeding: UserTableSeeder
Seeding: BannerTableSeeder
Seeding: PageTableSeeder
string(69) "/Users/tomn/Desktop/work/brickinc/pledge/database\seeds\csv\pages.csv"

  [ErrorException]                         
  Invalid argument supplied for foreach()  

This happen on every seeders file that process CSVs. To temporarily resolve this issue, I updated this file: https://github.com/bpocallaghan/titan/blob/master/src/Helpers/helpers.php#L118

Like so:

    if (!file_exists($filename) || !is_readable($filename)) {
        $filename = str_replace('\\', '/', $filename);
    }

    if (!file_exists($filename) || !is_readable($filename)) {
        return false;
    }

I leave it to you to determine the best way to resolve this. Thanks.

bpocallaghan commented 6 years ago

Hi @noogen

I've just pushed a potential fix. Instead of having the slashes hard coded - I've added php's DIRECTORY_SEPARATOR to determine the correct slashes.

It is still working on Windows - but please shout if it's not working on your Mac.

Please also let me know if you have any questions / ideas. Thank you.

noogen commented 6 years ago

Sorry for the delay. Just tested and works on my Mac now. Thanks.