/** * Run the database seeds. * * @return void */ public function run() { DB::table('interests')->delete(); $interests = [['女装', 'joso'], ['マゾ', 'mazo'], ['サド', 'sado'], ['露出', 'rosyutsu'], ['熟女', 'jukujo'], ['アナル', 'anal'], ['SM', 'sm'], ['コスプレ', 'kosupure'], ['痴女', 'chijo'], ['レズ', 'rezu'], ['ゲイ', 'gei'], ['オナニー', 'onani'], ['緊縛', 'kinbaku'], ['フェチ', 'fechi'], ['痴漢', 'chikan']]; foreach ($interests as $key => $row) { \App\Orm\Interest::create(array('id' => $key + 1, 'name' => $row[0], 'name_tag' => $row[1], 'created_at' => Carbon::today(), 'updated_at' => Carbon::today())); } }
/** * articlesとphotosへ格納 * @param array $data */ public function create(array $data) { DB::transaction(function () use($data) { $this->article->newInstance(); $this->article->{'res_id'} = $data['parent_id']; $this->article->{'name'} = $data['name']; $this->article->{'age'} = $data['age']; $this->article->{'sex'} = $data['sex']; $this->article->{'prefectures'} = $data['prefectures']; $this->article->{'title'} = $data['title']; $this->article->{'body'} = $data['body']; $this->article->{'mail'} = $data['mail']; $this->article->{'password'} = $data['password']; $this->article->{'ip_address'} = $data['client_ip']; $this->article->{'checked'} = 0; $this->article->save(); // 返信の場合、親のupdate_atを更新とお知らせメール送信 if ($this->article->{'res_id'} !== '0') { $article = $this->article->newInstance(); $parentArticle = $article->find($this->article->{'res_id'}); $parentArticle->updated_at = Carbon::now(); $parentArticle->save(); if ($parentArticle->mail) { Log::info('replay mail set queue. id: ' . $this->article->{'id'}); $this->dispatch(new ReplySendEmail($parentArticle, $this->article)); } } $photos = []; for ($i = 1; $i <= 2; $i++) { if (isset($data['file' . $i])) { $file1Result = $this->getExifReadData($data['file' . $i]); if ($file1Result) { $photos[] = new Photo($file1Result); } } } if ($photos) { $this->article->photos()->saveMany($photos); } $interests = $this->interest->all(); foreach ($interests as $row) { if (isset($data[$row->name_tag])) { $this->article->interests()->attach($data[$row->name_tag]); } } // 新規記事・返信でインクリメント $this->analysisService->newPostIncrement(); // tweet $this->dispatch(new TwetterTweet($this->article)); }); }
/** * @param Builder $query * @param array $conditions * @return mixed */ public function scopeSearch(Builder $query, array $conditions) { // 見た目 if (isset($conditions['sex_s']) and $conditions['sex_s'] !== '0') { $query->where('sex', $conditions['sex_s']); } // 年代 if (isset($conditions['age_s']) and $conditions['age_s'] !== '0') { $query->where('age', $conditions['age_s']); } // 都道府県 if (isset($conditions['prefectures_s']) and $conditions['prefectures_s'] !== '0') { $query->where('prefectures', $conditions['prefectures_s']); } // 地域 if (isset($conditions['area_s']) and $conditions['area_s'] !== '0') { $areas = config::get('const.area_prefectures'); $areaPrefectures = $areas[$conditions['area_s']]; $query->whereIn('prefectures', $areaPrefectures); } // test 投稿を無視 $query->where('name', '<>', 'test'); $hasInterests = false; $interests = Interest::all(); $keys = array_keys($conditions); foreach ($interests as $row) { if (in_array($row->name_tag, $keys)) { $hasInterests = true; break; } } if ($hasInterests) { foreach ($interests as $row) { if (in_array($row->name_tag, $keys)) { $query->whereHas('interests', function ($query) use($row) { $query->where('id', $row->id); }); } } } $query->where('res_id', 0); return $query; }
/** * アプリケーションサービスの初期化処理 * * @return void */ public function boot() { $result = []; $result['linkList'] = LinkList::all(); $result['interestsList'] = Interest::all(); $result['keyword'] = $result['interestsList']->pluck('name')->toArray(); $result['sexList'] = Config::get('const.sex'); $result['ageList'] = Config::get('const.age'); $result['areaList'] = Config::get('const.area'); $result['prefecturesList'] = Config::get('const.prefectures'); $result['thumbnail_img_path'] = Config::get('const.thumbnail_img_path'); $result['original_img_path'] = Config::get('const.original_img_path'); $result['affiliatesList'] = Config::get('const.affiliate'); $result['links'] = Config::get('const.links'); shuffle($result['affiliatesList']); foreach ($result as $key => $value) { view()->share($key, $value); } }