Skip to content

Commit

Permalink
Youtube video on profile view.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fw7424 committed Jun 22, 2023
1 parent 0ca2bd7 commit 3339f82
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/Repositories/PeopleRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Contracts\Repositories\ProfileRepositoryContract;
use Illuminate\Cache\Repository;
use Waynestate\Youtube\ParseId;
use Illuminate\Support\Str;
use Waynestate\Api\News;
use Waynestate\Api\People;
Expand Down Expand Up @@ -268,6 +269,12 @@ public function getProfile($site_id, $accessid)
if (!empty($profile['data'])) {
$profile['data']['link'] = '/profile/'.$profile['data']['accessid'];

if (!empty($profiles['profiles'][$site_id]['data']['Youtube Videos'])) {
$profiles['profiles'][$site_id]['data']['Youtube Videos'] = collect($profiles['profiles'][$site_id]['data']['Youtube Videos'])->map(function ($youtube_link) {
return ParseId::fromUrl($youtube_link);
});
}

foreach ($profile['data']['field_data'] as $data) {
if ($data['field']['type'] == 'file') {
$profile['data']['data'][$data['field']['name']]['url'] = $data['value'];
Expand Down Expand Up @@ -341,6 +348,7 @@ public function getFields()
'Last Name',
'Picture',
'Photo Download',
'Youtube Videos',
],
// Build the users name based on these fields
'name_fields' => [
Expand Down
9 changes: 9 additions & 0 deletions app/Repositories/ProfileRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Support\Str;
use Waynestate\Api\Connector;
use Illuminate\Cache\Repository;
use Waynestate\Youtube\ParseId;
use Waynestate\Api\News;
use Waynestate\Promotions\ParsePromos;
use Contracts\Repositories\ProfileRepositoryContract;
Expand Down Expand Up @@ -239,6 +240,12 @@ public function getProfile($site_id, $accessid)
return ['profile'=> []];
}

if (!empty($profiles['profiles'][$site_id]['data']['Youtube Videos'])) {
$profiles['profiles'][$site_id]['data']['Youtube Videos'] = collect($profiles['profiles'][$site_id]['data']['Youtube Videos'])->map(function ($youtube_link) {
return ParseId::fromUrl($youtube_link);
});
}

if (!empty($profiles['profiles'])) {
$profiles['profiles']['articles'] = $this->getNewsArticles($accessid, 10);
}
Expand Down Expand Up @@ -298,6 +305,7 @@ public function getFields()
'file_fields' => [
'Curriculum Vitae',
'Syllabi',
'Youtube Videos',
],
// Hide these in the main tube of content
'hidden_fields' => [
Expand All @@ -309,6 +317,7 @@ public function getFields()
'Last Name',
'Picture',
'Photo Download',
'Youtube Videos',
],
// Build the users name based on these fields
'name_fields' => [
Expand Down
7 changes: 7 additions & 0 deletions factories/People.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ public function create($limit = 1, $flatten = false, $options = [])
'Office' => $office,
'Biography' => $biography,
'Research Interests' => $research_interests,
'Youtube Videos' => [
0 => [
'youtube_id' => 'PHqfwq033yQ',
'link' => 'https://www.youtube.com/watch?v=PHqfwq033yQ',
'filename_alt_text' => 'YouTube video from '.$this->faker->firstName,
],
],
],
];

Expand Down
7 changes: 7 additions & 0 deletions factories/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public function create($limit = 1, $flatten = false, $options = [])
'<p>'.$this->faker->paragraph(10).'</p>',
'<p>'.$this->faker->paragraph(10).'</p>',
],
'Youtube Videos' => [
0 => [
'youtube_id' => 'PHqfwq033yQ',
'link' => 'https://www.youtube.com/watch?v=PHqfwq033yQ',
'filename_alt_text' => 'YouTube video from '.$this->faker->firstName,
],
],
],
'groups' => [
$groups->random()['display_name'],
Expand Down
9 changes: 9 additions & 0 deletions resources/views/components/video-profile.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{--
$video => array // [['title', 'link', 'relative_url', 'youtube_id']]
--}}

<div>
<a href="{{ $video['link'] }}">
@image('//i.wayne.edu/youtube/'.$video['youtube_id'], $video['filename_alt_text'], "lazy")
</a>
</div>
8 changes: 8 additions & 0 deletions resources/views/profile-view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
@endif
@endif
@endforeach

@if(!empty($profile['data']['Youtube Videos']))
@foreach ($profile['data']['Youtube Videos'] as $item)
<div class="pb-4">
@include('components.video-profile', ['video' => $item])
</div>
@endforeach
@endif
</div>
</div>

Expand Down

0 comments on commit 3339f82

Please sign in to comment.