php - Where is the best place to make query call in Laravel 4? -
first of all, kind of confusing. there few tutorials , complete documentation feel not working way should. i'm little bit confused , discouraged. learned how write forms, how make views blade. how menage migrations , seeds. know how create new controller , simple routes.
but guys... need advice if answer...
i created form view example form:
{{form::open(array('url' => 'person/confirm'))}} {{form::label('firstname', 'firstname:')}} {{form::text('firstname')}} {{form::label('lastname', 'lastname:')}} {{form::text('lastname')}} {{form::label('company_name', 'company name:')}} {{form::text('company_name')}} {{form::label('mail', 'mail:')}} {{form::text('mail')}} {{form::label('phone', 'phone:')}} {{form::text('phone')}} {{form::label('additional_phone', 'additional phone:')}} {{form::text('additional_phone')}} {{form::label('city', 'city:')}} {{form::text('city')}} {{form::label('postalcode', 'postalcode:')}} {{form::text('postalcode')}} {{form::label('address', 'address:')}} {{form::text('address')}} {{form::label('notes', 'notes:')}} {{form::text('notes')}} {{form::submit('submit')}} {{form::close()}}
nothing fancy, basic form. if call submit, take me person/confirm route. , this:
route::post('person/confirm', function(){ $input = input::all(); db::table('humanity')->insert( array('firstname' => $firstname); ); }
i know wrong.
how values $input?
how insert table correctly , safely?
where best place make query call?
it better make query before routing starts or when next route execute?
it create query in controller function , execute in route redirect "message: success"?
what classes , models , how can use them?
i plan write system , day day makes me more sicker satisfied. call me had hitched wagon star.
thank in advice.
ok first off suggest eloquent. laravels orm (http://laravel.com/docs/eloquent).
eloquent allow this:
$human = new human(input::all()); $human->save();
but can come that, first question here how use input class. real documentation can found under requests in laravel documentation, here's brief guide.
input::get('firstname'); //gets first name input::get('lastname'); //get doesn't refer method, "get" retrieve post or get. input::all(); //will input array - don't forget validate input::except(array('csrf_token')); //will except 'csrf_token' array
one of best ways laravel through laravel irc channel, community great.
#laravel place many developers hang out , discuss framework. many people pop heads in looking help.
but, real-time chat nature of irc can refreshing contrast posting on forum , waiting reply.
the official community hub laravel
laravel.io has forums along plethora or useful tools such pastebin, should become friends.
the other resource suggest taylor's book
it's not free it's worth it.
written creator of laravel, definitive guide advanced application development laravel 4. learn dependency injection, interfaces, service providers, solid design, , more while exploring practical, real-world code examples. whether you're building robust, large application laravel framework, or want sharpen software design chops, book of great value , team.
Comments
Post a Comment