2

Laravel - Controllers without routing

 2 years ago
source link: https://www.codesd.com/item/laravel-controllers-without-routing.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Laravel - Controllers without routing

advertisements

I am newbie to laravel. I created new controller - book. This is my code -

class BookController extends BaseController {

    public function index()
    {
        return View::make('book.index');
    }

    public function insert()
    {

        return View::make('book.insert');
    }

}

My routes.php -

Route::get('book/', 'BookController@index');
//Route::any('book/insert', array('uses' => 'BookController@insert'));

When i uncomment 2nd line, i can access insert page. Is it possible to access pages without add them to routes.

Now it produce this error

QL3M7.png

You may read about resource controller.

Execute this on terminal:

php artisan controller:make BookController

This command will generate BookController.php in your app/controllers folder. Read the code for more information.

Define in your routes.php file:

Route::resource('book', 'BookController');

Actions Handled By Resource Controller:

rVk0F.png

Related Articles

Test controllers without routing

I'm trying to test my controller's action chain in isolation. Specifically, I want to ensure my desired behavior is applied to all my controller's actions. For example, test that all my actions require authentication: context "when not authenticated&

Laravel 5.1 - Routes Error - NotFoundHttpException in RouteCollection.php line 143:

This error happen in my laravel 5.1 project, when trying to access http://localhost:8000/dashboard.user.update after I click Submit on my edit form. NotFoundHttpException in RouteCollection.php line 143: This error happen when I run update function i

Route planning without Route :: controller

Route::controller deprecated in Laravel 5.3, Now I want to design my routes but I don't know how can I do this without Route::controller because I don't want define Route::get for each route and I want handle the parameters in my controller . for exa

Laravel Forms without using a blade

Is it possible to build a laravel application without using Blade to create the forms? I write the application's code, and my designer takes care of all the visual elements/css. He uses Dreamweaver and other software to generate the forms. Now is it

Communicating between Controllers without Events

I am wondering what would be the best way communicating between controllers without events.(It looks like $emit and $broadcast all involved with events.) I have this line of code and if hospitalList length != 0, I want to assign true in other control

How do I add common actions to controllers without using inheritance?

I need to add common actions to a number of my controllers without using inheritance. All our controllers extend an Abstract controller and the functionality I want to include does not make sense in the abstract controller. My initial idea was to use

Is it possible to do TCP / IP between PCs without router

Is it possible to connect two PCs without a router using just an ethernet cable end-to-end and do socket communications over TCP/IP? I need a solution which works on windows preferably.yes it is possible to that all you need to do is if you are a usi

Angularjs: routes and controllers without templateURLs?

Is it possible to use Angularjs's routing and controller without the templateURL? For instance, below is my current routes, controllers, and template urls, return app.config(['$routeProvider', function ($routeProvider) { $routeProvider .when("/"

Laravel 5.3 Route :: resource without REST

I upgrade Laravel 5.1 to 5.3 and have some problem with routes. In Laravel 5.1 I have route like: Route::controllers([ 'pages/{page_type}' => 'Admin\AdminPagesController', ]); And in controller I have methods like: getIndex($type) postIndex($type, Re

Laravel Creating dynamic routes to controllers from the Mysql database

I have the following table: group_pages in mysql database with page name route name : id name route -------------------- 0 About about 1 Contact contact 2 Blog blog what I am trying to do is to create dynamic routes in my : routes.php ? Where if I go

Can you pass parameters to controllers via routes.rb without appearing in the URL?

Suppose I want www.example.com/profile to redirect a user to his or her profile page. So what I want to do is match "/profile" to "users#show" but also let the controller know who the current user is. Is there any way I can set params[

How to link to an action without route help

How do I link to an action without a route helper? I have a route get '/batches/:id/creation_wizard/add_funds' => 'batch::creation_wizard#add_funds' If I do in the Rails console include Rails.application.routes.url_helpers default_url_options[:host]

Laravel 5.4 routing for the same prefix group, but a different middleware giving an error

I need all the route under same prefix manager with one middleware for guest manager_guest and another for logged in user manager_auth. This code bellow is my route web.php file is there any other way ? My Route: Error after executing php artisan rou

Laravel 5.1 route error message

Working with laravel 5.1 Whenever i go to mywebsite.com/home i get redirected to auth/login path but it loads this error message. Im not sure whats causing this issue, everything is still pretty much out of the box. Im not sure what im overlooking Me

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK