這裏是我的控制器代碼:localhost的頁面不laravel工作
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Route;
use Input;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\models\Designation;
use Validator;
class Cdesigination extends Controller
{
public $flight;
public function __construct(){
$this->flight = new Designation;
}
public function index(request $request)
{
$this->flight->name = $request->name;
$this->flight->detail = $request->detail;
$this->flight->token_key = $request->_token;
$data=$this->flight->save();
if($data){
return Redirect::to('posts')->withInput()->with('success', 'Inserted Successfully.');
}
else {
return Redirect::to('posts')->withInput()->with('success', 'Not inserted Successfully.');
}
return view('designation');
}
}
這裏是航線代碼:
Route::get('/posts', '[email protected]');
哪裏是麻煩,如何解決呢?
我認爲重定向關鍵字創造麻煩,因爲當我放棄redirect:: to
關鍵字,然後工作正常。
當你說'本地主機不工作'時,你是什麼意思。您的測試頁是否顯示?通過raze你的意思是擦除? –
當我評論這段代碼時,返回Redirect :: away('posts') - > withInput() - > with('success','Inserted Successfully。'); }其他{ return('posts') - > withInput() - > with }工作正常否則顯示本地主機頁面不工作 –
刪除withInput()並嘗試 –