diff --git a/app/Http/Controllers/HomepageController.php b/app/Http/Controllers/HomepageController.php index 3af22919..1593b598 100644 --- a/app/Http/Controllers/HomepageController.php +++ b/app/Http/Controllers/HomepageController.php @@ -48,7 +48,7 @@ public function index(Request $request): View $promos['components'] = $modularComponents['modularComponents']; } - $articles = $this->article->listing($request->data['base']['site']['news']['application_id']); + $articles['data'] = $this->article->listing($request->data['base']['site']['news']['application_id']); $events = $this->event->getEvents($request->data['base']['site']['id']); diff --git a/factories/ArticleComponent.php b/factories/ArticleComponent.php new file mode 100644 index 00000000..db1f0088 --- /dev/null +++ b/factories/ArticleComponent.php @@ -0,0 +1,160 @@ +faker = $faker->create(); + } + + /** + * {@inheritdoc} + */ + public function create($limit = 1, $flatten = false, $options = []) + { + $hero = [ + 'featured' => 0, + 'url' => '/styleguide/image/1600x580', + 'caption' => $this->faker->sentence(rand(5, 10)), + 'alt_text' => $this->faker->sentence(rand(5, 10)), + 'type' => 'Hero Image', + ]; + + $social = [ + 'featured' => 0, + 'url' => '/styleguide/image/1600x580', + 'caption' => $this->faker->sentence(rand(5, 10)), + 'alt_text' => $this->faker->sentence(rand(5, 10)), + 'type' => 'Social Image', + ]; + + $featured = [ + 'featured' => 1, + 'url' => '/styleguide/image/770x434', + 'caption' => $this->faker->sentence(rand(5, 10)), + 'alt_text' => $this->faker->sentence(rand(5, 10)), + 'type' => 'Embeddable', + ]; + + $faculty = []; + for ($i = 0; $i < 3; $i++) { + $faculty[] = [ + 'id' => $this->faker->randomDigit(), + 'first_name' => $this->faker->firstName(), + 'last_name' => $this->faker->lastName(), + 'accessid' => $this->faker->randomLetter().$this->faker->randomLetter().$this->faker->randomNumber(4, true), + ]; + } + + $programs = []; + for ($i = 0; $i < 3; $i++) { + $programs[] = [ + 'name' => $this->faker->randomElement(['Accounting (BS)', 'Art Education (BA)', 'Biological Sciences (BA)', 'Chemical Engineering (MS)']), + 'url' => 'https://wayne.edu', + ]; + } + + $assets = []; + for ($i = 0; $i < 3; $i++) { + $assets[] = [ + 'id' => $this->faker->randomDigit(), + 'url' => 'https://wayne.edu', + 'caption' => $this->faker->sentence(), + 'filename' => substr(md5($this->faker->sentence()), 0, 10).'.pdf', + ]; + } + + for ($i = 1; $i <= $limit; $i++) { + $data[$i] = [ + 'id' => $i, + 'user_id' => $this->faker->randomDigit(), + 'application_id' => $this->faker->randomDigit(), + 'favicon_id' => null, + 'title' => $this->faker->sentence(rand(6, 10)), + 'short_title' => $this->faker->sentence(rand(3, 6)), + 'sub_title' => null, + 'permalink' => $this->faker->slug(), + 'meta_description' => $this->faker->sentence(), + 'body' => '

'.$this->faker->paragraph(8).'

+

'.$this->faker->paragraph(8).'

+
+ Placeholder +
'.$this->faker->paragraph().'
+
+

'.$this->faker->paragraph().'

+
+

'.$this->faker->paragraph(1).'

+
+

'.$this->faker->paragraph(8).'

+

'.$this->faker->paragraph(8).'

+
+

'.$this->faker->paragraph(1).'

+
+

'.$this->faker->paragraph(8).'

+

'.$this->faker->paragraph(8).'

+

 

+

'.$this->faker->paragraph(1).'

+
+ Placeholder +
'.$this->faker->paragraph().'
+
+

'.$this->faker->paragraph(8).'

+

'.$this->faker->paragraph(15).'

+
+

'.$this->faker->paragraph(5).'

+
+

'.$this->faker->paragraph(15).'

+
+
+ Placeholder +
'.$this->faker->paragraph().'
+
+
+

'.$this->faker->paragraph(15).'

+ Placeholder +

'.$this->faker->paragraph(8).'

+

'.$this->faker->paragraph(15).'

+ Placeholder +

'.$this->faker->paragraph(8).'

+

'.$this->faker->paragraph(15).'

+

+ Placeholder +

+

'.$this->faker->paragraph(8).'

+ ', + 'article_date' => $this->faker->date(), + 'status' => 'Published', + 'link' => '/styleguide/'.config('base.news_view_route').'/item-1', + 'hero_image' => $hero, + 'social_image' => $social, + 'featured' => $featured, + 'files' => [ + 0 => $hero, + 1 => $featured, + ], + 'assets' => $this->faker->randomElements($assets, rand(1, 3)), + 'faculty' => $this->faker->randomElements($faculty, rand(1, 3)), + 'programs' => $this->faker->randomElements($programs, rand(1, 3)), + 'favicon' => null, + 'user' => null, + 'applications' => null, + ]; + + $data[$i] = array_replace_recursive($data[$i], $options); + } + + if ($limit === 1 && $flatten === true) { + $data = current($data); + } + + return $data; + } +} diff --git a/resources/views/components/news-column.blade.php b/resources/views/components/news-column.blade.php index a169a1eb..8452e115 100644 --- a/resources/views/components/news-column.blade.php +++ b/resources/views/components/news-column.blade.php @@ -3,9 +3,9 @@ $url => string '/news/' $link_text => string // 'More news' --}} -@if(!empty($data['data'])) +@if(!empty($data))