Use {!! !!} instead of {{ }}.
[L5] Input, HTML, Form facades etc
Just tried installing L5 with great pleasure but then moved some code over from L4.2 to :5 but I need to use the Input::, {{ Form::open() }} stuff
I pulled in illuminate/html: ~5.0" as I saw in a previous post but then the app breaks.
So more videos from @JeffreyWay on these type of subjects would be great, in that case I'm going to stick to 4.2 for now on a new project until I can get time ti toy with L5.
Done that too, sorry forgot to mention that.
I can login but then I get:
FatalErrorException in LoginController.php line 12: Class 'Trax\Http\Controllers\Input' not found
in LoginController.php line 12
at HandleExceptions->fatalExceptionFromError(array('type' => '1', 'message' => 'Class 'Trax\Http\Controllers\Input' not found', 'file' => '/home/vagrant/code/trax/app/Http/Controllers/LoginController.php', 'line' => '12')) in HandleExceptions.php line 116
at HandleExceptions->handleShutdown()
Add this to the composer.json file and run composer update.
"illuminate/html": "4.3.*
register the ServiceProvider
'Illuminate\Html\HtmlServiceProvider'
add the facades
'Form'=> 'Illuminate\Html\FormFacade',
'HTML'=> 'Illuminate\Html\HtmlFacade'
and it should work just fine.
Also @MThomas i believe TO changed the escape method.
Yep that seems to have worked! I'm now logged in so I guess I just have to use "old" stuff
Whenever you use "Redirect, Input, Validator", you need to import it.
Namespace does that ^ :)
@bashy it is namespaced, but not having the "use" statements doesn't work
<?php namespace Trax\Http\Controllers;
use Input;
use Auth;
use Redirect;
class LoginController extends Controller {
public function login()
{
return view('login');
}
public function authenticate()
{
$username = Input::get('username');
$password = Input::get('password');
if (Auth::attempt(array('username' => $username, 'password' => $password, 'status' => 'Active'), false)) {
return Redirect::intended('dashboard')->with('flash_success', 'You are now logged in.');
}
else {
return Redirect::to('/')
->with('flash_error', 'The details you entered where incorrect.<br />Please check and try again')
->withInput();
}
}
public function dashboard()
{
return view('dashboard');
}
}
You must import them, also you can replace that line with
use Input, Auth, Redirect;
So namespacing doesn't import, or is there a better way to do this, still new to L5 and not really played with it until now and really want to use it on this new project I have got, specially for method injection.
Also I copied the .env.example file and named it .env.local.php with the following inside it
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
DB_HOST=localhost
DB_DATABASE=erp
DB_USERNAME=homestead
DB_PASSWORD=secret
And this didn't get picked up and was still showing as production when I did php artisan env
@lstables First question, i believe there's no other way to do it, this is how namespacing works.
Second question, rename your file to .env.local without .php extension.
I don't mind/have no issue doing "use" if that's how its to be so that's fine. Has for .env files will that be .env.local and .env.production respectively?
Reason I ask i have no changed to .env.local and when I php artisan env it still states "production"
Weird issue, what's your .env.local file contents?
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
DB_HOST=localhost
DB_DATABASE=erp
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
SESSION_DRIVER=file
But if I echo out like so {{ getenv('APP_ENV') }} it does show local, but doing php artisan shows production!
I literally have no clue, it's working fine for me, I am sorry.
It's just .env, wherever you put it. Use APP_ENV=local within the .env file to specify the environment.
@opb that's the one yes it's just .env
Next question would be what about Form model binding? for editing a page with values filled with stuff from the db?
what about it? The idea of Form model binding is that you can pass the data to a form and it'll automatically get filled with the data that matches the inputs names.
yes how does this work in L5 ? in L4 we did things like
{{ Form::model($user, ['method' => 'PUT', 'route' => ['product.update', $user->id], 'class' => 'form-horizontal']) }}
Reason I ask all these questions is @JeffreyWay hasn't updated new videos with this stuff on and Taylor is updating this docs this week as far as I know.
As far as i know, Form model binding in L5 is same as L4, Jeff is working on L5 tutorials.
Ah right that's cool then, I know Jeff is working on these I meant to say he's not at this point yet.
Yeah, he already started putting L5 screencasts, but he stopped until L5 is ready, now that it'll go beta in a week or two
he decided to continue teaching L5.
Yeah i've seen the couple hes done already
I didn't mean namespacing "does" it for you, meant if you namespace classes, you have to start importing things to be able to use them :)
Please or to participate in this conversation.