-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Morning-Train/feature/resource_links
Feature/resource links
- Loading branch information
Showing
13 changed files
with
165 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use App\Models\Course\CourseCategory; | ||
use Illuminate\Database\Eloquent\Model; | ||
use \Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
|
||
class ResourceLink extends Model | ||
{ | ||
public function courseCategory(): BelongsTo | ||
{ | ||
return $this->belongsTo(CourseCategory::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
/** @var \Illuminate\Database\Eloquent\Factory $factory */ | ||
|
||
use App\Models\ResourceLink; | ||
use Faker\Generator as Faker; | ||
use \App\Models\Course\CourseCategory; | ||
|
||
$factory->define(ResourceLink::class, function (Faker $faker) { | ||
return [ | ||
'url' => $faker->url, | ||
'text' => $faker->words($faker->numberBetween(1, 3), true), | ||
'course_category_id' => optional(CourseCategory::query()->inRandomOrder()->first('id'))->id, | ||
]; | ||
}); |
29 changes: 29 additions & 0 deletions
29
database/migrations/2021_09_20_125833_create_resource_links_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateResourceLinksTable extends Migration | ||
{ | ||
public function up(): void | ||
{ | ||
Schema::create('resource_links', function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
$table->string('url'); | ||
$table->string('text'); | ||
$table->integer('position')->default(0); | ||
$table->unsignedBigInteger('course_category_id'); | ||
$table->timestamps(); | ||
|
||
$table->foreign('course_category_id') | ||
->references('id')->on('course_categories') | ||
->onDelete('cascade'); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists('resource_links'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 15 additions & 17 deletions
32
resources/js/widgets/animations/worlds/CourseCoverWorld.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Iterator } from '@morningtrain/react-resources' | ||
import React from 'react' | ||
import * as Displays from 'support/displays' | ||
import { inject } from '@morningtrain/react-decorators' | ||
|
||
@inject(['model']) | ||
export default class CourseResources extends React.Component { | ||
render () { | ||
return ( | ||
<div className={'course-resource-links-wrapper'}> | ||
<div className={'section-wrap'}> | ||
<div className={'buttons-wrap'}> | ||
<Iterator collection={this.props.model.get('resource_links')}> | ||
<Displays.Link name={'url'} className={'button button--pink small'}> | ||
<Displays.Text name={'text'}/> | ||
</Displays.Link> | ||
</Iterator> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,8 @@ | |
&--active { | ||
z-index: 2; | ||
} | ||
} | ||
} | ||
|
||
.course-resource-links-wrapper + .course-wrap { | ||
padding-top: 40px; | ||
} |