blob: 278916c4a9346c6e19248821be76cc02de4fbfa0 (
plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreLinkRequest;
use App\Http\Requests\UpdateLinkRequest;
use App\Models\Link;
class LinkController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
return view('links.index', ['links' => Link::all()]);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('links.create');
}
/**
* Store a newly created resource in storage.
*/
public function store(StoreLinkRequest $req)
{
//TODO tag ids
$validated = $req->validate([
'label' => 'min:2|max:255',
'url' => 'min:3'
]);
$link = Link::create([
'label' => $validated['label'],
'url' => $validated['url'],
'description' => $validated['description'],
]);
return redirect()->route('links.index')->with('success', 'link added');
}
/**
* Display the specified resource.
*/
public function show($id)
{
$link = Link::findOrFail($id);
return view('links.show', [
'link' => $link
]);
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Link $link)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateLinkRequest $request, Link $link)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Link $link)
{
//
}
}
|