2016-09-29 22:20:49 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use App\Models\Company;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
|
|
|
|
class CompanySeeder extends Seeder
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the database seeds.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function run()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
Company::truncate();
|
2017-06-12 17:39:03 -07:00
|
|
|
factory(Company::class, 4)->create();
|
2017-10-28 05:46:43 -07:00
|
|
|
|
|
|
|
$src = public_path('/img/demo/companies');
|
|
|
|
$dst = public_path('/uploads/companies');
|
|
|
|
|
|
|
|
$del_files = glob($dst."/*.*");
|
|
|
|
|
|
|
|
foreach($del_files as $del_file){ // iterate files
|
|
|
|
if(is_file($del_file))
|
|
|
|
unlink($del_file); // delete file
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$add_files = glob($src."/*.*");
|
|
|
|
foreach($add_files as $add_file){
|
|
|
|
$file_to_copy = str_replace($src,$dst,$add_file);
|
|
|
|
copy($add_file, $file_to_copy);
|
|
|
|
}
|
|
|
|
|
2016-09-29 22:20:49 -07:00
|
|
|
}
|
|
|
|
}
|