Skip to content

Commit

Permalink
fix(Cdn) fix erro while try delete (#15)
Browse files Browse the repository at this point in the history
This commit will fix erro 500 while try delete cdn.

Fix #14
  • Loading branch information
eufelipemateus authored Apr 7, 2023
1 parent e1648a9 commit ea38aef
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/Controllers/CdnController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use FelipeMateus\IPTVChannels\Model\IPTVCdn;
use \FelipeMateus\IPTVCustomers\Models\IPTVCdn as IPTVCdnCustomer;
use FelipeMateus\IPTVCore\Model\IPTVConfig;
use FelipeMateus\IPTVCore\Controllers\CoreController;

Expand Down Expand Up @@ -97,7 +98,13 @@ public function delete($id,Request $request){
* @return view -> IPTV::channel_list
*/
public function list(){
$data['list'] = IPTVCdn::all();

if(class_exists(IPTVCdnCustomer::class)){
$data['list'] = IPTVCdnCustomer::all();
}else {
$data['list'] = IPTVCdn::all();
}

$data['url_cdn'] = IPTVConfig::get('URL_CDN');
$data['donwload'] = IPTVConfig::get('DOWNLOAD_FILE');
return view("IPTV::cdn_list",$data);
Expand Down
10 changes: 9 additions & 1 deletion src/Model/IPTVCdn.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,19 @@ class IPTVCdn extends Model

protected $table = "iptv_cdns";

/**
/**
* The channels that belong to the user.
*/
public function channels(){
return $this->belongsToMany(IPTVChannel::class, 'iptv_urls','iptv_cdn_id', 'iptv_channel_id')->using(IPTVUrl::class);
}


/**
* This function will return always true.
*/
public function canDelete(){
return true;
}

}
5 changes: 4 additions & 1 deletion src/resources/views/cdn_list.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class="fas fa-plus fa-sm text-white-50"></i> {{ __('Add CDN')}}</a>

@if($url_cdn && !$donwload)
<div class="col-md-2">
<a href="{{ route('cdn-playslit',$cdn->slug) }}" target="_blank">Playslit</a>
<a href="{{ route('cdn-playslit',$cdn->slug) }}" target="_blank">Playslit</a>
</div>
@endif
@if ($url_cdn && $donwload)
Expand All @@ -43,9 +43,12 @@ class="fas fa-plus fa-sm text-white-50"></i> {{ __('Add CDN')}}</a>
<div class="col-md-2">
<a href="{{ route('show_cdn',$cdn->id) }}">{{ __('edit') }}</a>
</div>
@if ($cdn->canDelete())
<div class="col-md-2">
<a href="{{ route('delete_cdn',$cdn->id) }}">{{ __('delete')}}</a>
</div>
@endif

</div>
@endforeach

Expand Down

0 comments on commit ea38aef

Please sign in to comment.