laravel-4

Laravel 4 validation in bootstrap modal

拜拜、爱过 提交于 2019-12-06 14:38:59
I'm a newbie to Laravel 4, and I'm trying to get a form validation in bootstrap modal. My modal have a form with a text input and a submit button, and I want that when the validation fails, the modal show me the error. But the modal, after the validation and the page refresh, is closed. Here is the code from the controller and the view: Controller code: public function postAvatar() { $avatar_rules = array( 'avatar_src' => 'url', ); $validator = Validator::make(Input::all(), $avatar_rules); $validator->setAttributeNames(User::$names_attr); if ($validator->passes()) { $avatar_src = (Input::get(

Creating the database on fly

孤街醉人 提交于 2019-12-06 14:27:30
问题 I am working on laravel 4 app, In that i wan to allow the user to register for the app and when they register the app should allow a new empty database to the registered user,I am using mysql for backend I know the following code to set the database connection Config::set('database.connections', ConnectionArray); And to set it as default Config::set('database.default', ConnectionKey); To connect another database manually i can use this way 'mysql' => array( 'driver' => 'mysql', 'host' =>

Getting the current row's rank with Laravel

扶醉桌前 提交于 2019-12-06 13:55:39
In my Laravel 4 app, my users table has a votes column. I'd like to find the current user's rank. I can already get the top 10 users with User::orderBy('votes', 'desc')->take(10) , but I'd like to display the current user's rank below that list. Ideally, this would go something like: Auth::user()->rank('orderBy', 'votes', 'desc'); I get the logged in user, I ask for his rank assuming I order the users table by votes. Does anybody know if there's some way I can do this with Eloquent? Although still somewhat hacky you can do it via a custom getter (mutator) in Eloquent. public function

How to create an Hstore column type in Laravel 4?

大憨熊 提交于 2019-12-06 13:18:56
I'm using the Schema Builder inside of Migrations in Laravel 4 to manage my Postgres database during development. I've run into a problem. I want to utilize the Postgres Hstore column type in my table but I can't figure it out. There doesn't seem to be a "custom" column type in the Schema Builder (that I can find), so this was my attempt inside of a migration. This didn't work for me. Schema::create('entities', function(Blueprint $table) { $table->bigIncrements('id'); $table->string('type'); $table->string('name'); $table->text('data')->nullable(); $table->timestamps(); $table->softDeletes();

Where should I put this code in Laravel?

青春壹個敷衍的年華 提交于 2019-12-06 13:01:19
问题 I'm building a site using Laravel4. This is my first Laravel project so I'm still learning how everything fits together and where it should all go. I just added in the Laravel-Mandrill-Request bundle to my site. I'm able to send out emails from a method in my test Controller that looks like this: public function sendMeSomething(){ $payload = array( 'message' => array( 'subject' => 'Greetings!!', 'from_email' => 'xxxx@yyyy.com', 'to' => array( array('email'=>'aaaa@bbbb.com'), array('email' =>

Laravel - Method link_to_route does not exist

北慕城南 提交于 2019-12-06 12:45:01
I get an error when i use HTML::link_to_route, but not when i use HTML::Link Why? {{ HTML::decode(HTML::link_to_route('homepage', '<div class="logo"></div>')) }} The same for: {{ HTML::link_to_route('about', 'WHAT IS IT') }} The error: BadMethodCallException Method link_to_route does not exist. Version 4.0.x Fixed it, it seems that the documentation is really out-dated, or that laravel 4.0 is just really new ;) replaced "link_to_route" with "linkRoute". Found it by looking into the vendor files. Just FYI, or next searcher For the latest Release (4.1) the text will be encoded itself. to get the

How to pass value to Password field in Laravel

痴心易碎 提交于 2019-12-06 12:29:43
问题 I am trying to fetch value of the password field and display it in current form for one of the update pages {{ Form::label('Password')}} {{ Form::password('password',array('class' => 'form-control') }} Laravel blade's password field syntax does not allow parameter for input like it does for text fields for example, {{ Form::label('Email or Username')}} {{ Form::text('email',$useremaildata,array('class' => 'form-control')) }} Now I found one solution of using placeholders like that but it is

Laravel 4 - Use a controller action in other controllers?

自古美人都是妖i 提交于 2019-12-06 12:25:49
well I had a few controllers that were doing my jobs, now I created a few more controllers; some where in middle of an action in new controller, I just remembered that I've written the proper code in old controllers. so for e.g. in oldController@handyAction some_good_codez(); and in newController@newAction $myOldController = Load::controller('oldController'); // I wish Laravel had this? $myOldController->handyAction(); This is wrong. Controllers have to have just one responsibility: receive a http request, get some data from your models and pass it away to a view. If your controllers have to

Multiple where queries, using orWhere, in fields of model and related models

廉价感情. 提交于 2019-12-06 12:20:33
I have many tables (user facing, not SQL) with filter boxes per column. The columns have not only the tables' fields but fields of related models. I'm trying to add a feature where one can use a comma as an OR separator when filtering data. I need to do it generally as I have a rather large amount of tables, fields and relations. Plus some tables are built dynamically. The code that adds the where clauses for the models own fields is this: foreach ($filters as $column => $filter) { $q->where(function ($q) use ($filter, $model, $column) { $first = array_pop($filter); $q->where("$model.$column",

Typeahead remote with Laravel 4 - Individual pieces working I think, but not working together

好久不见. 提交于 2019-12-06 12:06:58
问题 I'm relatively green with Laravel and PHP. I'm learning Laravel by way of the documentation and SO/Google. I've clicked on every typeahead/laravel question I could find here, and I just can't seem to find an example that quite fits. This question comes very close. I actually don't see any glaring differences. But then again, that OP was having trouble with remote as well. I think I'm close, as my various pieces seem to be working individually. Let me explain... I have a form... <div class=