Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
371 views
in Technique[技术] by (71.8m points)

php - Why does nothing appear ? Laravel 8?

web.php

<?php

use IlluminateSupportFacadesRoute;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

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

Auth::routes();

Route::get('/home', [AppHttpControllersHomeController::class, 'index'])->name('home');

Auth::routes();

Route::get('/pingu/{id}', [AppHttpControllersHomeController::class, 'pingu']);

Auth::routes();

Route::prefix('jobs')->group(function(){
    Route::get('create', function () {
        return "create";
    });


    Route::get('update', function () {
        return "update";
    });
});

TaskController.php

<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;

class TaskController extends Controller

{    public function create(){
            return view ('create');
    }
}

create.blade.php`

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">{{ __('Dashboard') }}</div>

                <div class="card-body">
                    <form action="{{route('jobs.store')}}" method="POST">
                        <input type="text" name="title" class="form-control">
                        <button type="submit" class="btn btn-success">Submit</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

I did exactly what to do in the turtorial but it dind't appear , please find fix that works. I use laravel 8 i tried to config :cache clear a nd then artisan serve again butdind't work .If you know a laravel enough ( 8 ) you should know that everything is done right .

Picture 1

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The issue is with your route.

Route::prefix('jobs')->group(function(){
    Route::get('create', function () {
        return "create";
    });

That will return the word create. You most likely actually want:

Route::prefix('jobs')->group(function() {
    Route::get('create', [AppHttpControllersTaskController::class, 'create']);
});

The above tells Laravel to use the create function on your TaskController which returns your create view.

You also don't need to include Auth::routes() more than once. Include it before your routes just once.

Update

For the Did not work; here is a working example in black and white for you.

https://phpsandbox.io/n/round-morning-pqpk-dm8j1


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...