2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
use App\Models\Location;
|
|
|
|
|
|
|
|
|
|
|
|
class LocationSeeder extends Seeder
|
|
|
|
{
|
2017-06-12 17:39:03 -07:00
|
|
|
public function run()
|
|
|
|
{
|
|
|
|
Location::truncate();
|
2017-10-28 05:46:43 -07:00
|
|
|
factory(Location::class, 10)->create();
|
|
|
|
|
|
|
|
$src = public_path('/img/demo/locations');
|
|
|
|
$dst = public_path('/uploads/locations');
|
|
|
|
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
|
2017-06-12 17:39:03 -07:00
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|