laravel-3

PHP: Instantiating a class from a variable oddly fails

久未见 提交于 2019-12-24 03:12:53
问题 I'm trying to instantiate a class (a Laravel3 Eloquent model) by a variable, and I'm getting an error saying that the class is not found. When I hardcode the class name, though, it works just fine. (FYI, in the code below $contact_type is expected to either be Phone, Fax, or Email.) Here's what I'm playing with at the moment: foreach( $input AS $contact_type => $contact_info ) { foreach( $contact_info AS $data ) { $obj = new $contact_type( (array)$data); echo'<pre>Obj: ',print_r($obj),'</pre>

Should I include underscore in session cookie name?

最后都变了- 提交于 2019-12-23 11:00:34
问题 I'm curious if there is anyone using Laravel since version 3 running into problems setting cookies in various version of IE when there is an underscore in the cookie name. I came across this problem with my project (an eCommerce site built on CI). The problem was fixed removing the underscore in cookie name. While I'm currently porting the project to Laravel, I just want to check if I should remove the underscore from session cookie as well. 回答1: I would definitely recommend removing any

Check for active user state with laravel

拜拜、爱过 提交于 2019-12-22 09:39:29
问题 This is pretty standard login function and validation that works nicely. But I also want to check that the user is active. I have set up a column in my users table with 'active' set to either 0 or 1. public function post_login() { $input = Input::all(); $rules = array( 'email' => 'required|email', 'password' => 'required', ); $validation = Validator::make($input, $rules); if ($validation->fails()) { return Redirect::to_route('login_user') ->with_errors($validation->errors)->with_input(); }

Laravel 3 HTTP and HTTPS routes

女生的网名这么多〃 提交于 2019-12-21 23:14:14
问题 I have the following code: Route::get('/', function() { return 'non secure page'; }); Route::get('/', array('https' => true, function() { return 'secure page'; })); What I expected to happen is that these two routes would be treated differently. The first is for http://example.com requests and the second for https://example.com. Respectively, these pages should show the text 'non secure page' and 'secure page'. What actually happens is that both show the text 'secure page'. This must mean

Laravel extending class

六眼飞鱼酱① 提交于 2019-12-21 22:44:48
问题 Are there any other steps required to extend a class in Laravel 3? I created application/libraries/response.php : class Response extends Laravel\Response { public static function json($data, $status = 200, $headers = array(), $json_options = 0) { $headers['Content-Type'] = 'application/json; charset=utf-8'; if(isset($data['error'])) { $status = 400; } dd($data); return new static(json_encode($data, $json_options), $status, $headers); } public static function my_test() { return var_dump(

Laravel Migrations - Table Prefix Issue

做~自己de王妃 提交于 2019-12-21 22:14:04
问题 I'm building a dummy site to test Laravel 3.x. I'm creating my site migrations right now. Everything was doing just fine until the following error showed up: SQLSTATE[42s02]: Base table or view not found: 1146 Table 'databasenamehere.prefix_laravel_migrations' doesn't exist The issue is that laravel all of a sudden started to prefix the 'laravel_migrations' table (when it is supposed to do it only with the other ones). I wonder if I'm doing something wrong or if it is a known issue. I'm

Laravel 3 - How to validate checkbox array, for at least 1 checked?

泪湿孤枕 提交于 2019-12-21 18:39:42
问题 I'm starting to learn Laravel and still on the learning curve. Now I'm starting with Laravel 3 but will most probably switch my project into Laravel 4 once I get something working. Now the question being, how to validate an array of checkbox, I want to validate that at least 1 inside the group is enable(checked). I read somewhere on Laravel forum that we just validate them using a required, but when I dd(input::all()) I don't see anything else but the inputs field and checkbox are not part of

Laravel (3) Pagination Sorting & Filtering

送分小仙女□ 提交于 2019-12-21 05:09:06
问题 I have a list of all the "servers" in my "servers" table returned in my view with pagination. I have been struggling to figure out how to get sorting (asc & desc if possible) and filtering (searching within results) working. Here is my controller code: $servers = Server::paginate(5); return View::make('servers.list') ->with('game', '') ->with('servers', $servers); Here is my view code for the sorting: <ul class="nav"> <li class="active"><a href="#"><i class="icon-angle-down"></i>{{ Lang::line

How to retrieve a result set from a raw query as an array instead of an object in Laravel 3

有些话、适合烂在心里 提交于 2019-12-21 03:13:04
问题 By default, Laravel's raw query methods return results as arrays of stdClass objects: Array ( [0] => stdClass Object ( [id] => 1 [username] => admin [password] => admin123 [email] => admin@admin.com [created_at] => 2012-12-06 18:57:19 [updated_at] => 2012-12-06 00:00:00 ) [1] => stdClass Object ( [id] => 2 [username] => userna [password] => user [email] => user@gmail.com [created_at] => 2012-12-06 00:00:00 [updated_at] => 2012-12-05 00:00:00 ) ) The question is how to have Laravel return an

Breakpoints not hit with xdebug, PhpStorm and Laravel 3 / mod_rewrite

我的梦境 提交于 2019-12-20 09:58:05
问题 I'm pretty desperate and running out of ideas: I've configured xdebug and PhpStorm for a Laravel 3 project. Running the project locally on Mac OS X Apache, so PhpStorm and the web application run on the same machine. Configured a virtual host so that localhost.lt points to Laravel's public directory. Relevant xdebug entries in php.ini: zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so [xdebug] xdebug.idekey="PHPSTORM" xdebug.remote_enable=1 xdebug.profiler_enable=1