“Laravel Resource Route” Kod odpowiedzi

Laravel Resource Route

use App\Http\Controllers\PhotoController;

Route::resource('photos', PhotoController::class)->only([
    'index', 'show'
]);

Route::resource('photos', PhotoController::class)->except([
    'create', 'store', 'update', 'destroy'
]);
Mohamad

Laravel Utwórz kontroler zasobów

php artisan make:controller PhotoController --resource --model=Photo
Leonardo Dal Ronco

Jak nazwać Laravel zasobów trasy

Route::resource('faq', 'ProductFaqController', [
    'names' => [
        'index' => 'faq',
        'store' => 'faq.new',
        // etc...
    ]
]);
yusuf_fazeri

Laravel 8 kontrolera trasy zasobów

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class BlogController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}
Angry Ape

Laravel trasy zasobów

<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\ProductController;

Route::get('/', function () {
    return view('welcome');
});

Route::resource('product',ProductController::class);
Strange Shark

Zasób Route Laravel 8

use App\Http\Controllers\BlogController;
Route::resource('blogs', BlogController::class);
Angry Ape

Odpowiedzi podobne do “Laravel Resource Route”

Pytania podobne do “Laravel Resource Route”

Więcej pokrewnych odpowiedzi na “Laravel Resource Route” w PHP

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu