<commit_before><?php

use Illuminate\Database\Seeder;

use App\Offer;
use League\Csv\Reader;
use App\Ngo;

class OfferTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {

        $reader = Reader::createFromPath(base_path().'/database/seeds/csvs/offers.csv');
        $reader->setDelimiter(";");
        $results = $reader->fetch();
        foreach ($results as $key => $row) {

            $ngo = Ngo::where('short', $row[0])->first();

            if(is_null($ngo)){
              $ngo = Ngo::where('short', 'NONE')->first();
            }

            $offer = new Offer();
            $offer->ngo_id = $ngo->id;
            if(!empty($row[6]))
              $offer->street = $row[6];
            if(!empty($row[7]))
              $offer->streetnumber = $row[7];
            if(!empty($row[10]))
              $offer->zip = $row[10];
            if(!empty($row[11]))
              $offer->city = $row[11];
            if(!empty($row[19]))
              $offer->phone = $row[19];
            if(!empty($row[17]))
              $offer->email = $row[17];
            if(!empty($row[18]))
              $offer->website = $row[18];

             $offer->save();
            if(!empty($row[4]) && !empty($row[5])){
            $offer->translateOrNew('de')->title = $row[4];
            $offer->translateOrNew('de')->description = $row[5];
              $offer->save();
          }
            if(!empty($row[22]) && !empty($row[23])){
            $offer->translateOrNew('en')->title = $row[22];
            $offer->translateOrNew('en')->description = $row[23];
              $offer->save();
          }
        }


    }
}
<commit_msg>offer seeding taking address from previous entry<commit_after><?php

use Illuminate\Database\Seeder;

use App\Offer;
use League\Csv\Reader;
use App\Ngo;
use App\Category;

class OfferTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {

        $reader = Reader::createFromPath(base_path().'/database/seeds/csvs/offers.csv');
        $reader->setDelimiter(";");
        $results = $reader->fetch();
        $categories = array();
        $street = "";
        $streetnumber = "";
        $zip = "";
        $city = "";

        foreach ($results as $key => $row) {

            $ngo = Ngo::where('short', $row[0])->first();

            if(is_null($ngo)){
              $ngo = Ngo::where('short', 'NONE')->first();
            }

            $offer = new Offer();
            $offer->ngo_id = $ngo->id;
            if(!empty($row[6]))
              $street = $row[6];
            $offer->street = $street;

            if(!empty($row[7]))
              $streetnumber = $row[7];
            $offer->streetnumber = $streetnumber;

            if(!empty($row[10]))
              $zip = $row[10];
            $offer->zip = $zip;

            if(!empty($row[11]))
              $city = $row[11];
            $offer->city = $city;

            if(!empty($row[19]))
              $offer->phone = $row[19];
            if(!empty($row[17]))
              $offer->email = $row[17];
            if(!empty($row[18]))
              $offer->website = $row[18];

            $offer->save();

            if(!empty($row[4]) && !empty($row[5])){
              $offer->translateOrNew('de')->title = $row[4];
              $offer->translateOrNew('de')->description = $row[5];
                $offer->save();
            }
            if(!empty($row[22]) && !empty($row[23])){
              $offer->translateOrNew('en')->title = $row[22];
              $offer->translateOrNew('en')->description = $row[23];
                $offer->save();
            }
            if(!empty($row[1])){
              $categories = explode(',', $row[1]);
            }
            if(count($categories)){
              foreach($categories as $cat){
                $category = Category::whereTranslation('title', trim($cat))->first();
                $offer->categories()->attach($category);
              }
            }

        }


    }
}

{'fraction_non_alphanumeric': 0.19600195026816186, 'fraction_numerical': 0.018527547537786446, 'mean_word_length': 1.655663430420712, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1990700', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1224, 'n_words': 194}