2016-12-03 1 views
1

InfyOm Laravel Generator를 사용하여 컨트롤러, 모델, 뷰 등을 만들었습니다.InfraOm Laravel Generator로 Laravel의 새로운 기능을 읽는 방법?

나는 실행

<?php 

namespace App\Http\Controllers; 

use App\Http\Requests\CreatehotelRequest; 
use App\Http\Requests\UpdatehotelRequest; 
use App\Repositories\hotelRepository; 
use App\Http\Controllers\AppBaseController; 
use Illuminate\Http\Request; 
use Flash; 
use Prettus\Repository\Criteria\RequestCriteria; 
use Response; 

class hotelController extends AppBaseController 
{ 
    /** @var hotelRepository */ 
    private $hotelRepository; 

    public function __construct(hotelRepository $hotelRepo) 
    { 
     $this->hotelRepository = $hotelRepo; 
    } 

    /** 
    * Display a listing of the hotel. 
    * 
    * @param Request $request 
    * @return Response 
    */ 
    public function index(Request $request) 
    { 
     $this->hotelRepository->pushCriteria(new RequestCriteria($request)); 
     $hotels = $this->hotelRepository->all(); 

     return view('hotels.index') 
      ->with('hotels', $hotels); 
    } 

    /** 
    * Show the form for creating a new hotel. 
    * 
    * @return Response 
    */ 
    public function create() 
    { 
     die('hotel view'); 
     return view('hotels.create'); 
    } 

    public function test() 
    { 
     die('test view'); 
    } 

    /** 
    * Store a newly created hotel in storage. 
    * 
    * @param CreatehotelRequest $request 
    * 
    * @return Response 
    */ 
    public function store(CreatehotelRequest $request) 
    { 
     $input = $request->all(); 

     $hotel = $this->hotelRepository->create($input); 

     Flash::success('Hotel saved successfully.'); 

     return redirect(route('hotels.index')); 
    } 

    /** 
    * Display the specified hotel. 
    * 
    * @param int $id 
    * 
    * @return Response 
    */ 
    public function show($id) 
    { 
     $hotel = $this->hotelRepository->findWithoutFail($id); 

     if (empty($hotel)) { 
      Flash::error('Hotel not found'); 

      return redirect(route('hotels.index')); 
     } 

     return view('hotels.show')->with('hotel', $hotel); 
    } 

    /** 
    * Show the form for editing the specified hotel. 
    * 
    * @param int $id 
    * 
    * @return Response 
    */ 
    public function edit($id) 
    { 
     $hotel = $this->hotelRepository->findWithoutFail($id); 

     if (empty($hotel)) { 
      Flash::error('Hotel not found'); 

      return redirect(route('hotels.index')); 
     } 

     return view('hotels.edit')->with('hotel', $hotel); 
    } 

    /** 
    * Update the specified hotel in storage. 
    * 
    * @param int    $id 
    * @param UpdatehotelRequest $request 
    * 
    * @return Response 
    */ 
    public function update($id, UpdatehotelRequest $request) 
    { 
     $hotel = $this->hotelRepository->findWithoutFail($id); 

     if (empty($hotel)) { 
      Flash::error('Hotel not found'); 

      return redirect(route('hotels.index')); 
     } 

     $hotel = $this->hotelRepository->update($request->all(), $id); 

     Flash::success('Hotel updated successfully.'); 

     return redirect(route('hotels.index')); 
    } 

    /** 
    * Remove the specified hotel from storage. 
    * 
    * @param int $id 
    * 
    * @return Response 
    */ 
    public function destroy($id) 
    { 
     $hotel = $this->hotelRepository->findWithoutFail($id); 

     if (empty($hotel)) { 
      Flash::error('Hotel not found'); 

      return redirect(route('hotels.index')); 
     } 

     $this->hotelRepository->delete($id); 

     Flash::success('Hotel deleted successfully.'); 

     return redirect(route('hotels.index')); 
    } 
} 

I : http://labs.infyom.com/laravelgenerator/docs/5.3/getting-started#generator-commands

그것은 컨트롤러, 모델, 뷰 등

이 같은 컨트롤러의 호텔을 생성 : 나는에서이 명령을 받았습니다

php artisan infyom:scaffold Hotel URL을 http://localhost/adminlte-generator/public/hotels/create과 같이 호출하면 결과는 다음과 같습니다. 호텔보기

새로운 기능을 추가합니다. 기능은 테스트입니다. 그런 다음 URL을 http://localhost/adminlte-generator/public/hotels/test과 같이 호출합니다. 테스트보기가 표시되지 않습니다.

내 문제를 해결하는 솔루션이 있습니까?

답변

1

https://laravel.com/docs/5.3/routing

당신은 당신의 노선에

예를 등록해야합니다 라우팅 laravel를 살펴 보자

Route::get('adminlte-generator/public/hotels', ['uses' => '[email protected]']);

(이 경로/web.php에 적용해야한다)

나는 /create이 (가) 어떻게 작동하는지에 대해 의문이 있습니다. 아마도 artisan 명령을 실행할 때 route :: resource를 제공했을 것입니다. 그것에 대해 확실하지 않아.

Route::get('adminlte-generator/public/hotels', function() { 
    echo 'Working.'; 
}); 

액세스 경로를 당신은 작업 표시되는 경우 :

편집

먼저이보십시오. 컨트롤러에 문제가 있습니다.

은 try

는 경로에이를 추가 :이/당신이 찾는 데 도움이 오류를 식별 할 수

public function test() { 
    echo 'Working in controller.'; 
} 

.

희망이 있습니다.

+0

나는 내 경로에 등록했다. 하지만 작동하지 않습니다 –

+0

@samueltoh 무엇이 오류입니까? –

+0

오류가 없습니다. 하지만'http : // localhost/adminlte-generator/public/hotels/test'를 호출하면'test view'가 표시되지 않지만'http : // localhost/adminlte-generator/public/hotels'로 돌아갑니다 –

관련 문제