Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
#87 #88 Add Platform-Channel-Milestone management
Browse files Browse the repository at this point in the history
  • Loading branch information
Studio384 committed Dec 6, 2020
1 parent a817d53 commit cc11811
Show file tree
Hide file tree
Showing 15 changed files with 350 additions and 24 deletions.
21 changes: 21 additions & 0 deletions app/ChannelMilestonePlatform.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ChannelMilestonePlatform extends Model {
use HasFactory;

protected $table = 'channel_milestone_platforms';
protected $fillable = ['channel_platform_id', 'milestone_platform_id', 'active'];

public function channelPlatform() {
return $this->belongsTo(ChannelPlatform::class);
}

public function milestonePlatform() {
return $this->belongsTo(MilestonePlatform::class);
}
}
41 changes: 41 additions & 0 deletions app/Http/Controllers/Admin/ChannelMilestonePlatformController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\ChannelMilestonePlatform;
use App\MilestonePlatform;
use App\ChannelPlatform;

class ChannelMilestonePlatformController extends Controller {
public function store(MilestonePlatform $milestonePlatform, ChannelPlatform $channelPlatform) {
$this->authorize('edit_milestone');

$channelMilestonePlatform = ChannelMilestonePlatform::create([
'milestone_platform_id' => $milestonePlatform->id,
'channel_platform_id' => $channelPlatform->id,
'active' => 1
]);

return redirect()->back()->with('status', '<b>'.$channelPlatform->name.'</b> has been added to <b>'.$milestonePlatform->platform->name.'</b> for <b>'.$milestonePlatform->milestone->name.'</b>.');
}

public function toggle(ChannelMilestonePlatform $channelMilestonePlatform) {
$this->authorize('edit_milestone');

$channelMilestonePlatform->update([
'active' => $channelMilestonePlatform->active === 1 ? 0 : 1
]);

return redirect()->back()->with('status', '<b>'.$channelMilestonePlatform->channelPlatform->name.'</b> has been toggled for <b>'.$channelMilestonePlatform->milestonePlatform->platform->name.'</b> for <b>'.$channelMilestonePlatform->milestonePlatform->milestone->name.'</b>.');
}

public function destroy(ChannelMilestonePlatform $channelMilestonePlatform) {
$this->authorize('edit_milestone');

$channelMilestonePlatform->delete();

return redirect()->back()->with('status', '<b>'.$channelMilestonePlatform->channelPlatform->name.'</b> has been removed from <b>'.$channelMilestonePlatform->milestonePlatform->platform->name.'</b> for <b>'.$channelMilestonePlatform->milestonePlatform->milestone->name.'</b>.');
}
}
30 changes: 30 additions & 0 deletions app/Http/Controllers/Admin/MilestonePlatformController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\MilestonePlatform;
use App\Milestone;
use App\Platform;

class MilestonePlatformController extends Controller {
public function store(Milestone $milestone, Platform $platform) {
$this->authorize('edit_milestone');

$milestonePlatform = MilestonePlatform::create([
'milestone_id' => $milestone->id,
'platform_id' => $platform->id
]);

return redirect()->back()->with('status', '<b>'.$milestonePlatform->platform->name.'</b> has been added to <b>'.$milestonePlatform->milestone->name.'</b>.');
}

public function destroy(MilestonePlatform $milestonePlatform) {
$this->authorize('edit_milestone');

$milestonePlatform->delete();

return redirect()->back()->with('status', '<b>'.$milestonePlatform->platform->name.'</b> has been removed from <b>'.$milestonePlatform->milestone->name.'</b>.');
}
}
7 changes: 6 additions & 1 deletion app/Http/Controllers/admin/MilestoneController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Milestone;
use App\Platform;
use App\MilestonePlatform;
use App\ChannelMilestonePlatform;
use Twitter;

class MilestoneController extends Controller
Expand Down Expand Up @@ -50,8 +53,10 @@ public function store(Request $request) {
*/
public function edit(Milestone $milestone) {
$this->authorize('edit_milestone');

$platforms = Platform::all();

return view('core.milestones.edit', compact('milestone'));
return view('core.milestones.edit', compact('milestone', 'platforms'));
}

/**
Expand Down
4 changes: 4 additions & 0 deletions app/Milestone.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public function releases() {
return $this->hasMany(Release::class, 'milestone');
}

public function milestonePlatforms() {
return $this->hasMany(MilestonePlatform::class);
}

public function getBgColorAttribute() {
return 'background-color: #'.$this->color;
}
Expand Down
25 changes: 25 additions & 0 deletions app/MilestonePlatform.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class MilestonePlatform extends Model {
use HasFactory;

protected $table = 'milestone_platforms';
protected $fillable = ['milestone_id', 'platform_id'];

public function milestone() {
return $this->belongsTo(Milestone::class);
}

public function platform() {
return $this->belongsTo(Platform::class);
}

public function channelMilestonePlatform() {
return $this->hasMany(ChannelMilestonePlatform::class);
}
}
2 changes: 1 addition & 1 deletion app/Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getColoredIconAttribute() {
}

public function getBgColorAttribute() {
return 'background-color: #'.$this->color;
return 'background-color: '.$this->color;
}

public function getRouteKeyName() {
Expand Down
44 changes: 22 additions & 22 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateChannelMilestonePlatformsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('channel_milestone_platforms', function (Blueprint $table) {
$table->id();
$table->foreignId('channel_platform_id')->references('id')->on('channel_platforms');
$table->foreignId('milestone_platform_id')->references('id')->on('milestone_platforms');
$table->integer('active')->required()->default(1);
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('channel_milestone_platforms');
}
}
20 changes: 20 additions & 0 deletions public/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -11593,6 +11593,9 @@ textarea.form-control-lg {
.card .card-header + .card-body {
padding: 0 1rem 1rem;
}
.card :first-child {
border-radius: calc(0.25rem - 1px) calc(0.25rem - 1px) 0 0;
}
.card .card-description-overflow {
overflow: hidden;
text-overflow: ellipsis;
Expand Down Expand Up @@ -12102,6 +12105,23 @@ a:hover {
border-width: 1.5px;
}

.dropdown-item {
height: 2.25rem;
}
.dropdown-item > svg[style] {
transition: all 0.2s ease-in-out;
}
.dropdown-item:hover > svg[style] {
color: #fff !important;
}

.dot {
width: 6px;
height: 6px;
border-radius: 6px !important;
margin-right: 0.5rem;
}

.action-close {
background-color: transparent;
width: 40px;
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,8 @@ alter table `channel_platforms` add constraint `channel_platforms_channel_id_for

alter table `channel_platforms` add `short_name` varchar(191) not null after `channel_id`, `name` varchar(191) not null after `channel_id`;
alter table `platforms` add `position` int not null default '1' after `icon`;

create table `channel_milestone_platforms` (`id` bigint unsigned not null auto_increment primary key, `channel_platform_id` bigint unsigned not null, `milestone_platform_id` bigint unsigned not null, `active` int not null default '1', `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci';
alter table `channel_milestone_platforms` add constraint `channel_milestone_platforms_channel_platform_id_foreign` foreign key (`channel_platform_id`) references `channel_platforms` (`id`);
alter table `channel_milestone_platforms` add constraint `channel_milestone_platforms_milestone_platform_id_foreign` foreign key (`milestone_platform_id`) references `milestone_platforms` (`id`);
```
4 changes: 4 additions & 0 deletions resources/sass/core/_card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
padding: 0 1rem 1rem;
}

:first-child {
border-radius: calc(0.25rem - 1px) calc(0.25rem - 1px) 0 0;
}

.card-description-overflow {
overflow: hidden;
text-overflow: ellipsis;
Expand Down
Loading

0 comments on commit cc11811

Please sign in to comment.