diff options
Diffstat (limited to 'app/Http')
| -rw-r--r-- | app/Http/Controllers/InventoryController.php | 65 | ||||
| -rw-r--r-- | app/Http/Controllers/ItemController.php | 65 | ||||
| -rw-r--r-- | app/Http/Controllers/LinkController.php | 13 | ||||
| -rw-r--r-- | app/Http/Controllers/SiteController.php | 10 | ||||
| -rw-r--r-- | app/Http/Controllers/TransactionController.php | 65 | ||||
| -rw-r--r-- | app/Http/Controllers/WritingController.php | 20 | ||||
| -rw-r--r-- | app/Http/Requests/StoreLinkRequest.php | 4 | ||||
| -rw-r--r-- | app/Http/Requests/StoreQuoteRequest.php | 2 | ||||
| -rw-r--r-- | app/Http/Requests/UpdateLinkRequest.php | 4 | ||||
| -rw-r--r-- | app/Http/Requests/UpdateQuoteRequest.php | 2 |
10 files changed, 26 insertions, 224 deletions
diff --git a/app/Http/Controllers/InventoryController.php b/app/Http/Controllers/InventoryController.php deleted file mode 100644 index 267a032..0000000 --- a/app/Http/Controllers/InventoryController.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php - -namespace App\Http\Controllers; - -use App\Models\Inventory; -use Illuminate\Http\Request; - -class InventoryController extends Controller -{ - /** - * Display a listing of the resource. - */ - public function index() - { - // - } - - /** - * Show the form for creating a new resource. - */ - public function create() - { - // - } - - /** - * Store a newly created resource in storage. - */ - public function store(Request $request) - { - // - } - - /** - * Display the specified resource. - */ - public function show(Inventory $inventory) - { - // - } - - /** - * Show the form for editing the specified resource. - */ - public function edit(Inventory $inventory) - { - // - } - - /** - * Update the specified resource in storage. - */ - public function update(Request $request, Inventory $inventory) - { - // - } - - /** - * Remove the specified resource from storage. - */ - public function destroy(Inventory $inventory) - { - // - } -} diff --git a/app/Http/Controllers/ItemController.php b/app/Http/Controllers/ItemController.php deleted file mode 100644 index 6b049c9..0000000 --- a/app/Http/Controllers/ItemController.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php - -namespace App\Http\Controllers; - -use App\Models\Item; -use Illuminate\Http\Request; - -class ItemController extends Controller -{ - /** - * Display a listing of the resource. - */ - public function index() - { - // - } - - /** - * Show the form for creating a new resource. - */ - public function create() - { - // - } - - /** - * Store a newly created resource in storage. - */ - public function store(Request $request) - { - // - } - - /** - * Display the specified resource. - */ - public function show(Item $item) - { - // - } - - /** - * Show the form for editing the specified resource. - */ - public function edit(Item $item) - { - // - } - - /** - * Update the specified resource in storage. - */ - public function update(Request $request, Item $item) - { - // - } - - /** - * Remove the specified resource from storage. - */ - public function destroy(Item $item) - { - // - } -} diff --git a/app/Http/Controllers/LinkController.php b/app/Http/Controllers/LinkController.php index 180e6e6..9ac44d8 100644 --- a/app/Http/Controllers/LinkController.php +++ b/app/Http/Controllers/LinkController.php @@ -34,11 +34,7 @@ class LinkController extends Controller */ public function store(StoreLinkRequest $req) { - //TODO tag ids - $validated = $req->validate([ - 'label' => 'min:2|max:255', - 'url' => 'min:3' - ]); + $validated = $req->validated(); $link = Link::create([ 'label' => $validated['label'], 'url' => $validated['url'], @@ -74,12 +70,7 @@ class LinkController extends Controller */ public function update(UpdateLinkRequest $request, Link $link) { - $validated = $request->validate([ - 'label' => 'min:2|max:255', - 'url' => 'min:3', - 'description' => 'nullable|string', - ]); - + $validated = $request->validated(); $link->update($validated); $redirect = $request->input('_redirect', route('l.index')); diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php index 0d6aa6c..33d7dc3 100644 --- a/app/Http/Controllers/SiteController.php +++ b/app/Http/Controllers/SiteController.php @@ -6,7 +6,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; -use Storage; +use Illuminate\Support\Facades\Storage; use Carbon\Carbon; class SiteController extends Controller @@ -18,10 +18,7 @@ class SiteController extends Controller 'Link', 'Tag', 'Writing', - 'Inventory', - 'Item', 'Role', - 'Transaction' ]; public static $MODELS_LC_PLURAL = [ 'users', @@ -29,10 +26,7 @@ class SiteController extends Controller 'links', 'tags', 'writings', - 'inventories', - 'items', 'roles', - 'transactions' ]; //returns an env mapping to be used by client. pretty much a subset of laravel app's env, but might also have addition things @@ -83,7 +77,7 @@ class SiteController extends Controller foreach ($files as $f){ $filename = $f->getClientOriginalName(); - if (Storage::disk('public')->fileExists("${dir}/${filename}")){ + if (Storage::disk('public')->exists("${dir}/${filename}")){ $filename = Carbon::now()->timestamp.'_'.$filename; } $path = $f->storeAs( diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php deleted file mode 100644 index 2d9f3c3..0000000 --- a/app/Http/Controllers/TransactionController.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php - -namespace App\Http\Controllers; - -use App\Models\Transaction; -use Illuminate\Http\Request; - -class TransactionController extends Controller -{ - /** - * Display a listing of the resource. - */ - public function index() - { - // - } - - /** - * Show the form for creating a new resource. - */ - public function create() - { - // - } - - /** - * Store a newly created resource in storage. - */ - public function store(Request $request) - { - // - } - - /** - * Display the specified resource. - */ - public function show(Transaction $transaction) - { - // - } - - /** - * Show the form for editing the specified resource. - */ - public function edit(Transaction $transaction) - { - // - } - - /** - * Update the specified resource in storage. - */ - public function update(Request $request, Transaction $transaction) - { - // - } - - /** - * Remove the specified resource from storage. - */ - public function destroy(Transaction $transaction) - { - // - } -} diff --git a/app/Http/Controllers/WritingController.php b/app/Http/Controllers/WritingController.php index 688f478..974852f 100644 --- a/app/Http/Controllers/WritingController.php +++ b/app/Http/Controllers/WritingController.php @@ -15,11 +15,8 @@ class WritingController extends Controller */ public function index() { - Log::info('w index'); - $writings = Writing::all(); - Log::info($writings); return view('writings.index', [ - 'writings' => Writing::orderBy('created_at')->paginate(20) + 'writings' => Writing::orderBy('created_at', 'desc')->paginate(20) ]); } @@ -79,7 +76,15 @@ class WritingController extends Controller */ public function update(Request $request, Writing $writing) { - + $validated = $request->validate([ + 'title' => 'required|min:3|max:255', + 'content' => 'required|min:10', + ]); + + $writing->update($validated); + + return redirect()->route('w.show', $writing) + ->with('success', 'Writing updated successfully!'); } /** @@ -87,6 +92,9 @@ class WritingController extends Controller */ public function destroy(Writing $writing) { - return 'todo'; + $writing->delete(); + + return redirect()->route('w.index') + ->with('success', 'Writing deleted.'); } } diff --git a/app/Http/Requests/StoreLinkRequest.php b/app/Http/Requests/StoreLinkRequest.php index ff58d72..250c98d 100644 --- a/app/Http/Requests/StoreLinkRequest.php +++ b/app/Http/Requests/StoreLinkRequest.php @@ -22,7 +22,9 @@ class StoreLinkRequest extends FormRequest public function rules(): array { return [ - // + 'label' => 'required|string|min:2|max:255', + 'url' => 'required|string|min:3|max:255', + 'description' => 'nullable|string|max:255', ]; } } diff --git a/app/Http/Requests/StoreQuoteRequest.php b/app/Http/Requests/StoreQuoteRequest.php index e9859fb..68f1158 100644 --- a/app/Http/Requests/StoreQuoteRequest.php +++ b/app/Http/Requests/StoreQuoteRequest.php @@ -11,7 +11,7 @@ class StoreQuoteRequest extends FormRequest */ public function authorize(): bool { - return false; + return true; } /** diff --git a/app/Http/Requests/UpdateLinkRequest.php b/app/Http/Requests/UpdateLinkRequest.php index da864b8..22ff43c 100644 --- a/app/Http/Requests/UpdateLinkRequest.php +++ b/app/Http/Requests/UpdateLinkRequest.php @@ -22,7 +22,9 @@ class UpdateLinkRequest extends FormRequest public function rules(): array { return [ - // + 'label' => 'sometimes|string|min:2|max:255', + 'url' => 'sometimes|string|min:3|max:255', + 'description' => 'nullable|string|max:255', ]; } } diff --git a/app/Http/Requests/UpdateQuoteRequest.php b/app/Http/Requests/UpdateQuoteRequest.php index 93804a8..9a2e50d 100644 --- a/app/Http/Requests/UpdateQuoteRequest.php +++ b/app/Http/Requests/UpdateQuoteRequest.php @@ -11,7 +11,7 @@ class UpdateQuoteRequest extends FormRequest */ public function authorize(): bool { - return false; + return true; } /** |
