Symfony\Component\HttpKernel\Exception\NotFoundHttpException Laravel

A NotFoundHttpException exception in Laravel always means that it was not able to find a router for a particular URL. And in your case this is probably a problem in your web server configuration, virtual host (site) configuratio, or .htaccess configuration. Your public/.htaccess should look like this: <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine … Read more

Laravel quick start guide route not working

Seems like your Laravel app is accesible via an Apache HTTP alias, because your URL looks like: http://localhost/laravel/. If this is the case and assuming that http://localhost/laravel is pointing to your public directory, then follow these steps: Try to navigate to your expected route prepend it with /index.php/, in your case: http://localhost/laravel/index.php/users. If it works … Read more

How to create self referential relationship in laravel?

You can add a relation to the model and set the custom key for the relation field. Update: Try this construction class Post extends Eloquent { public function parent() { return $this->belongsTo(‘Post’, ‘parent_id’); } public function children() { return $this->hasMany(‘Post’, ‘parent_id’); } } Old answer: class Post extends Eloquent { function posts(){ return $this->hasMany(‘Post’, ‘parent_id’); … Read more

Clone an Eloquent object including all relationships?

tested in laravel 4.2 for belongsToMany relationships if you’re in the model: //copy attributes $new = $this->replicate(); //save model before you recreate relations (so it has an id) $new->push(); //reset relations on EXISTING MODEL (this way you can control which ones will be loaded $this->relations = []; //load relations on EXISTING MODEL $this->load(‘relation1′,’relation2’); //re-sync everything … Read more

How Can I Remove “public/index.php” in the Laravel Url generated? [duplicate]

Option 1: Use .htaccess If it isn’t already there, create an .htaccess file in the Laravel root directory. Create a .htaccess file your Laravel root directory if it does not exists already. (Normally it is under your public_html folder) Edit the .htaccess file so that it contains the following code: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule … Read more

Avoid public folder of laravel and open directly the root in web server

Let’s assume you have this folder structure in your server .cpanel/ public_html/ public_ftp/ .. And the laravel folder structure is app/ bootstrap/ public/ vendor/ composer.json artisan .. You can create a folder name mylaravelsite on your server inline with public_html and public_ftp folder, and copy to it the whole laravel application except the public folder … Read more

Laravel 4 : Route to localhost/controller/action

If you are looking for a more automated routing, this would be the Laravel 4 way: Route: Route::controller(‘users’, ‘UsersController’); Controller (in this case UsersController.php): public function getIndex() { // routed from GET request to /users } public function getProfile() { // routed from GET request to /users/profile } public function postProfile() { // routed from … Read more

Laravel extend Form class

To extend/swap a Laravel core class, you can create a Service Provider: File: app/App/Libraries/Extensions/FormBuilder/FormBuilderServiceProvider.php <?php namespace App\Libraries\Extensions\FormBuilder; use Illuminate\Support\ServiceProvider as IlluminateServiceProvider; use App\Libraries\Extensions\FormBuilder\FormBuilder; class FormBuilderServiceProvider extends IlluminateServiceProvider { /** * Indicates if loading of the provider is deferred. * * @var bool */ protected $defer = true; /** * Register the service provider. * * … Read more

How to create a database-driven multi-level navigation menu using Laravel

So after doing much more searching and reading from different sources this is what I came up with and it’s working fine: /app/models/Navigation.php <?php class Navigation extends Eloquent { /** * The database table used by the model. * * @var string */ protected $table=”navigation”; public function parent() { return $this->hasOne(‘navigation’, ‘id’, ‘parent_id’); } public … Read more