laravel-4

Why Laravel uses wrong database file after setting environment?

自闭症网瘾萝莉.ら 提交于 2020-01-04 01:59:09
问题 In bootstrap/start.php I have the following: $env = $app->detectEnvironment(function() { if($myenv = getenv('APPLICATION_ENV')): return $myenv; else: return 'local'; endif; }); Ok so I setup a local folder and put in a database.php file with my local connections. Just to make sure its picking up the correct environment I put in the template: {{ App::environment(); }} which outputs local . But when making a DB call its giving me error: Undefined index : DB1_HOST My base (production) database

404 error laravel 4 routing

我与影子孤独终老i 提交于 2020-01-04 01:29:05
问题 I am having troubles getting laravel to find a page when I route to it. My route is setup and being recognized as when I create link using URL::route('account-create') laravel will successfully parse that into '/account/create' as to where I want the link to go to. But upon clicking it I get a 404 error. My route Route::get('/account/create', array( 'as' => 'account-create', 'uses' => 'AccountController@getCreate' )); My controller class AccountController extends BaseController { // view the

Using Auth to get the role of user in a pivot table

只愿长相守 提交于 2020-01-04 00:28:07
问题 I have the following database structure a users & roles table joined using a pivot table: The users table contains all the info such as email and password, while the roles table defines the different roles : roles table 1 -> admin 2 -> encoder 3 -> salesman 4 -> tech Now the roles are defined many-to-many because, there are some encoders that are assigned also as an admin. Others may have an salesman+admin role, or even encoder+salesman. Basically it multiple roles can be assigned to someone.

Laravel - Modify and return variable from @include

て烟熏妆下的殇ゞ 提交于 2020-01-03 21:49:08
问题 I'm including multiple templates in a loop by using @include('template.included') Before including this template I define $page = 0; and inside the template, multiple times it calls $page++; Inside the included template, the value correctly increments, however outside the template it seems like the $page variable stays the same - it's looking like @include creates it's own copy of each var you use. I need this $page variable to update from inside those templates, and have it's value returned

Can Eloquent models retrieve metadata on their rows?

柔情痞子 提交于 2020-01-03 20:04:17
问题 Is it possible for an Eloquent-based model in Laravel to introspect/reflect on the underlying table and retrieve information (type, size, unsigned, default values, etc) about the columns? Or is this intentionally left out? I feel like it would be useful to be able to determine the column type (to do things like intelligently assign some validations, or help infer a form input type and/or populate a default). 回答1: I don't think you can do this "out of the box" in Laravel, though it would be

Can Eloquent models retrieve metadata on their rows?

﹥>﹥吖頭↗ 提交于 2020-01-03 20:02:01
问题 Is it possible for an Eloquent-based model in Laravel to introspect/reflect on the underlying table and retrieve information (type, size, unsigned, default values, etc) about the columns? Or is this intentionally left out? I feel like it would be useful to be able to determine the column type (to do things like intelligently assign some validations, or help infer a form input type and/or populate a default). 回答1: I don't think you can do this "out of the box" in Laravel, though it would be

Laravel 4 Call to undefined method Illuminate\Database\Eloquent\Collection::links()

安稳与你 提交于 2020-01-03 16:56:16
问题 I tried to implement codes in the book entitled "Learning Laravel 4 Application Development" . A simple use CRUD app as following, Controller $users = User::all(); return View::make('users.index', compact('users')); View <!--an simple table ...--> <div class="pagination"> {{ $users->links() }} </div> And it shows an error: Call to undefined method Illuminate\Database\Eloquent\Collection::links() Could someone give me an hint?. 回答1: You are using pagination, so User::all() won't work because

Laravel core method confusion

我的未来我决定 提交于 2020-01-03 16:17:28
问题 I have been digging in the core of Laravel because I would like to understand how it works. But I come up with a method that I just cannot wrap my head around even after 3 days. In start.php the app is binded to itself. So far so good. But when I check the $app->share method I am lost. public function share(Closure $closure) { return function($container) use ($closure) { // We'll simply declare a static variable within the Closures and if // it has not been set we'll execute the given Closure

How can I straighten out Laravel blade @extends order of execution?

偶尔善良 提交于 2020-01-03 12:34:48
问题 In my attempts to find a way to pass a variable by reference to a blade @include, I built a simple test case which also demonstrates that the template order of execution is quite volatile. Is there a way to use blade templates with a variable where the order of execution matters (specifically with regard to sections)? Test Case: testLayout.blade.php <!DOCTYPE html> <html> <head> </head> <body> {{"this is the layout: ".++$tabindex."<br>"}} @include('testInclude') {{"this is the layout after

How can I straighten out Laravel blade @extends order of execution?

孤街浪徒 提交于 2020-01-03 12:34:07
问题 In my attempts to find a way to pass a variable by reference to a blade @include, I built a simple test case which also demonstrates that the template order of execution is quite volatile. Is there a way to use blade templates with a variable where the order of execution matters (specifically with regard to sections)? Test Case: testLayout.blade.php <!DOCTYPE html> <html> <head> </head> <body> {{"this is the layout: ".++$tabindex."<br>"}} @include('testInclude') {{"this is the layout after