Ejemplo n.º 1
0
 /**
  * Store an article on the storage.
  *
  * @param array $fillable Validated array parameters: author_id, industry_id, thumbnail_id
  *
  * @return Article|false
  */
 public function store(array $fillable)
 {
     $article = new Article($fillable);
     $article->assignAuthor(User::find($fillable['author_id']));
     $article->assignIndustry(Industry::find($fillable['industry_id']));
     $article->assignThumbnail(File::find($fillable['thumbnail_id']));
     return $article->save() ? $article : false;
 }
Ejemplo n.º 2
0
 /**
  * Get all users with role of company representative, which company/companies belong to the given industry.
  *
  * @param Industry $industry
  *
  * @return Builder
  */
 public function whereCompaniesIndustry(Industry $industry)
 {
     return User::whereHas('companies.industry', function (Builder $query) use($industry) {
         $query->where('industries.id', $industry->id);
     });
 }