How to use SHA1 encryption instead of BCrypt in Laravel 4?

You’ll have to rewrite the Hash module. Thanks to Laravel’s ideas of following IoC and Dependency Injection concepts, it’ll be relatively easy. First, create a app/libraries folder and add it to composer’s autoload.classmap: “autoload”: { “classmap”: [ // … “app/libraries” ] }, Now, it’s time we create our class. Create a SHAHasher class, implementing Illuminate\Hashing\HasherInterface. … Read more

Laravel blank white screen

Apache Does this answer describe or help your situation? Upgrading to Apache 2.4 come with some changes in Apache configuration. Laravel Are you checking Laravel’s logs or Apache’s logs? Since upgrading to Laravel 4.1, I’ve had white screen “errors” (WSOD) when the application could not write to the log location. I’ve always solved this by … Read more

How to create multilingual translated routes in Laravel

First step: Go to app/lang directory and create here translations for your routes for each language. You need to create 3 routes.php files – each in separate language directory (pl/en/fr) because you want to use 3 languages For Polish: <?php // app/lang/pl/routes.php return array( ‘contact’ => ‘kontakt’, ‘about’ => ‘o-nas’ ); For English: <?php // … Read more

Download files in laravel using Response::download

Try this. public function getDownload() { //PDF file is stored under project/public/download/info.pdf $file= public_path(). “/download/info.pdf”; $headers = array( ‘Content-Type: application/pdf’, ); return Response::download($file, ‘filename.pdf’, $headers); } “./download/info.pdf”will not work as you have to give full physical path. Update 20/05/2016 Laravel 5, 5.1, 5.2 or 5.* users can use the following method instead of Response facade. … Read more

How to install Laravel 4 to a web host subfolder without publicly exposing /app/ folder?

So I figured out how to do this. I’ll explain with an example. Suppose you a domain, http://domain.example. Here’s an example of the structure you might be using: domain.example/ (the root of your web hosting) |– yourlaravel4_base/ |– [some other folders…] |– public_html/ (where your html files and such go) | |– [some other folders…] … Read more

Laravel – Route::resource vs Route::controller

RESTful Resource controller A RESTful resource controller sets up some default routes for you and even names them. Route::resource(‘users’, ‘UsersController’); Gives you these named routes: Verb Path Action Route Name GET /users index users.index GET /users/create create users.create POST /users store users.store GET /users/{user} show users.show GET /users/{user}/edit edit users.edit PUT|PATCH /users/{user} update users.update DELETE … Read more

Laravel orderBy on a relationship

It is possible to extend the relation with query functions: <?php public function comments() { return $this->hasMany(‘Comment’)->orderBy(‘column’); } [edit after comment] <?php class User { public function comments() { return $this->hasMany(‘Comment’); } } class Controller { public function index() { $column = Input::get(‘orderBy’, ‘defaultColumn’); $comments = User::find(1)->comments()->orderBy($column)->get(); // use $comments in the template } } … Read more