This repository was archived by the owner on Nov 1, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathChannelPlatformController.php
More file actions
52 lines (40 loc) · 1.76 KB
/
ChannelPlatformController.php
File metadata and controls
52 lines (40 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\ChannelPlatform;
class ChannelPlatformController extends Controller {
public function store() {
$this->authorize('edit_platform');
$this->validate(request(), [
'channel' => ['required'],
'platform' => ['required'],
'name' => ['required'],
'short_name' => ['required']
], [
'channel.required' => 'A channel is required.',
'platform.required' => 'A platform is required.',
'name.required' => 'A platform is required.',
'short_name.required' => 'A platform is required.'
]);
$channelPlatform = ChannelPlatform::create([
'channel_id' => request('channel'),
'platform_id' => request('platform'),
'name' => request('name'),
'short_name' => request('short_name')
]);
return redirect()->back()->with('status', '<b>'.$channelPlatform->channel->name.'</b> has been added to <b>'.$channelPlatform->platform->name.'</b>.');
}
public function toggle(ChannelPlatform $channelPlatform) {
$this->authorize('edit_platform');
$channelPlatform->update([
'active' => $channelPlatform->active === 1 ? 0 : 1
]);
return redirect()->back()->with('status', '<b>'.$channelPlatform->channel->name.'</b> has been toggled.');
}
public function destroy(ChannelPlatform $channelPlatform) {
$this->authorize('edit_platform');
$channelPlatform->delete();
return redirect()->back()->with('status', '<b>'.$channelPlatform->channel->name.'</b> has been removed from <b>'.$channelPlatform->platform->name.'</b>.');
}
}