laravel-4

Controller method not found - laravel 4

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-11 05:00:09
问题 I have this message whine trying to run any controller Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException Controller method not found. I have this Code in my Route file Route::controller("/","HomeController"); Route::controller("users","UsersController"); and this code in my Controller <?php class UsersController extends BaseController { protected $layout = "layouts.main"; public function __construct() { $this->beforeFilter('csrf', array('on' => 'post')); $this->beforeFilter

Laravel 4 custom pagination: go to first/last page and show a fixed number of links

你离开我真会死。 提交于 2020-01-10 20:07:31
问题 I'm using the default Bootstrap slider navigation in Laravel 4 and it works very nice: but now I'd like improve it with two customizations, and I have no clue how: 1: Add a "go to first page" at the beginning, disabled if we are in the first page; and an analogous "go to last page" at the end, disabled if we are in the last page (please see how the arrows are changed compared to default Laravel stuff! I'd like to use "double arrows" (« and ») for "go to first/last", and a single arrow (‹ and

Laravel Validation custom message

偶尔善良 提交于 2020-01-10 13:53:20
问题 I am facing a problem with laravel custom validation message, here is what I have: $rules = [ 'first_name' => 'required|alpha|min:2', 'last_name' => 'required|alpha|min:2', 'email' => 'required|email|unique:users,email,' . Input::get('id') . ',id', 'password' => 'alpha_num|between:6,12|confirmed', 'password_confirmation' => 'alpha_num|between:6,12', 'address' => 'regex:/^[a-z0-9- ]+$/i|min:2', 'city' => 'alpha|min:2', 'state' => 'alpha|min:2|max:2', 'zip' => 'numeric|min:5|max:5', 'phone' =>

Laravel: Run migrations on another database

允我心安 提交于 2020-01-10 13:09:42
问题 In my app every user has its own database that created when user registered. Connection and database data (database name, username, password) are saved in a table in default database. try{ DB::transaction(function() { $website = new Website(); $website->user_id = Auth::get()->id; $website->save(); $database_name = 'website_'.$website->id; DB::statement(DB::raw('CREATE DATABASE ' . $database_name)); $websiteDatabase = new WebsiteDatabase(); $websiteDatabase->website_id = $website->id;

Laravel: Run migrations on another database

不羁岁月 提交于 2020-01-10 13:05:17
问题 In my app every user has its own database that created when user registered. Connection and database data (database name, username, password) are saved in a table in default database. try{ DB::transaction(function() { $website = new Website(); $website->user_id = Auth::get()->id; $website->save(); $database_name = 'website_'.$website->id; DB::statement(DB::raw('CREATE DATABASE ' . $database_name)); $websiteDatabase = new WebsiteDatabase(); $websiteDatabase->website_id = $website->id;

How I can install the PHPExcel library in laravel?

十年热恋 提交于 2020-01-10 10:16:06
问题 I'm trying to use this library to create excel files but not how to install it. I was considering to download the library from its home page (http://phpexcel.codeplex.com/wikipage?title=Examples) but also do not know what folder should I place it. How I can install? 回答1: You should use composer: Add "phpexcel/phpexcel": "dev-master" to your composer.json "require": { "phpexcel/phpexcel": "dev-master" } Then execute composer update . So you can use it as normal: public function import($path){

How do I create a RESTful API in Laravel to use in my BackboneJS app

扶醉桌前 提交于 2020-01-10 02:16:26
问题 I want to create a RESTful API in Laravel 4 to use in my BackboneJS apps. What is the best way for doing this? Does the Laravel 4 framework provides a good solution for this. 回答1: This is an example for creating an API that stores bookmarks. It uses the Route::resource() method. Creating a RESTful controller in Laravel 4 POST = store() (Create a new entry) DELETE = destroy($id) (Delete an entry) GET = index() (Get all entries) GET = show($id) (Get one entry) PUT = update($id) (Update an entry

How to set a default attribute value for a Laravel / Eloquent model?

风格不统一 提交于 2020-01-09 02:17:09
问题 If I try declaring a property, like this: public $quantity = 9; ...it doesn't work, because it is not considered an "attribute", but merely a property of the model class. Not only this, but also I am blocking access to the actually real and existent "quantity" attribute. What should I do, then? 回答1: An update to this... @j-bruni submitted a proposal and Laravel 4.0.x is now supporting using the following: protected $attributes = array( 'subject' => 'A Post' ); Which will automatically set

Session has value but is not recognised

倖福魔咒の 提交于 2020-01-07 07:43:46
问题 I was wondering why does the Session doesn't seem to remain it's value but it actually prints its value? I print out the the value of the Session but when I access the same page on a different tab it doesn't recognize that it has a value. Also when the page is refreshed Session becomes null...? And another thing I'm not sure if what I did in the Log Out button is correct This is what I have in my LogInController.php <?php class LogInController extends BaseController { public function

Session has value but is not recognised

不问归期 提交于 2020-01-07 07:43:18
问题 I was wondering why does the Session doesn't seem to remain it's value but it actually prints its value? I print out the the value of the Session but when I access the same page on a different tab it doesn't recognize that it has a value. Also when the page is refreshed Session becomes null...? And another thing I'm not sure if what I did in the Log Out button is correct This is what I have in my LogInController.php <?php class LogInController extends BaseController { public function