Generating controller with resources via artisan command

Generate controller with php artisan command

To generate a plain controller in Laravel use below command on terminal

artisan make controller --plain

Generate controller with resources

In order to generate a controller in Laravel with CRUD resource below artisan command is used

		php artisan make:controller PhotoController --resource
		
		
	

Above code will generate a new controller in app/Http/Controllers folder with below code

		
		namespace AppHttpControllers;
		
		use IlluminateHttpRequest;
		
		class PhotoController extends Controller
		{
		    /**
		     * Display a listing of the resource.
		     *
		     * @return IlluminateHttpResponse
		     */
		    public function index()
		    {
		        //
		    }
		
		    /**
		     * Show the form for creating a new resource.
		     *
		     * @return IlluminateHttpResponse
		     */
		    public function create()
		    {
		        //
		    }
		
		    /**
		     * Store a newly created resource in storage.
		     *
		     * @param  IlluminateHttpRequest  $request
		     * @return IlluminateHttpResponse
		     */
		    public function store(Request $request)
		    {
		        //
		    }
		
		    /**
		     * Display the specified resource.
		     *
		     * @param  int  $id
		     * @return IlluminateHttpResponse
		     */
		    public function show($id)
		    {
		        //
		    }
		
		    /**
		     * Show the form for editing the specified resource.
		     *
		     * @param  int  $id
		     * @return IlluminateHttpResponse
		     */
		    public function edit($id)
		    {
		        //
		    }
		
		    /**
		     * Update the specified resource in storage.
		     *
		     * @param  IlluminateHttpRequest  $request
		     * @param  int  $id
		     * @return IlluminateHttpResponse
		     */
		    public function update(Request $request, $id)
		    {
		        //
		    }
		
		    /**
		     * Remove the specified resource from storage.
		     *
		     * @param  int  $id
		     * @return IlluminateHttpResponse
		     */
		    public function destroy($id)
		    {
		        //
		    }
		}
		
		
		
	

Leave a Reply

Your email address will not be published. Required fields are marked *