laravel-4

Are laravel query results encoded?

喜你入骨 提交于 2019-12-11 08:15:18
问题 In my laravel app, I am trying to trim a result that I get from database. The trim() is not removing the last space in the string. The code is this $institutes = Institute::all(); foreach ($institutes as $institute) { $str = $institute->name; $str = trim($str); //doesn't remove the trailing space $len = strlen($str); } Now, first of all, the length of $str is 1 more than what it should be. It should be 20 but it somehow shows 21 . Another thing, the last character is a space according to my

Laravel saving post variable when there is validation error?

a 夏天 提交于 2019-12-11 08:07:05
问题 I am using laravel 4 , and I have a form with checkboxes and on sumbitting the form , it goes through the validation error process, if there is error how do I make it save the post values of these check boxes? AdminRolesController: public function postActions($action = NULL) { // Allowed post actions.. $allowed = array('add', 'edit'); $action = in_array($action, $allowed) ? $action : NULL; // check if action is not null if(is_null($action)) return Redirect::to('admin/roles'); else { // POST

Laravel4: How to pass Datepicker into a form?

筅森魡賤 提交于 2019-12-11 07:59:19
问题 For proper validation i have to rewrite into Laravel4 all the form fields i have, the main reason is that i need to add Input::old to all the fields. So far it went good with text, textarea and checkbox. But i don't know how to deal with the calendar data. It is Datepicker, a pretty nice JQuery plugin: https://github.com/eternicode/bootstrap-datepicker There are two fields, one for the arrival, the other for the outgoing. This is the html properly working: <div class="input-append date "> <p>

Laravel rename routing resource path names

最后都变了- 提交于 2019-12-11 07:51:47
问题 Can we rename routing resource path names in Laravel like in Ruby on Rails? Current /users/create -> UsersController@create /users/3/edit -> UsersController@edit .. I want like this; /users/yeni -> UsersController@create /users/3/duzenle -> UsersController@edit I want to do this for localization. Example from Ruby on Rails; scope(path_names: { new: "ekle" }) do resources :users end 回答1: I know this is an old question. I'm just posting this answer for historical purposes: Laravel now has the

phpcs - class must be in a namespace of at least one level - how to fix?

∥☆過路亽.° 提交于 2019-12-11 07:21:29
问题 I am using laravel 4.2. Lets say there is such class: class BShopsController extends ShopsController To fix this, I try to use name space lets say this: namespace app\controllers; and then it does not find ShopsController so I add use \ShopsController; Then I get error: Class BShopsController does not exist What namespace should I use first of all so it would not break anything? Edit: BShopsController and ShopsController are in folder Shops 回答1: As your files are inside the Shops folder and I

Laravel 4, jQuery .ajax, No post input received

我们两清 提交于 2019-12-11 07:20:11
问题 I must be missing something, didn't think this would have been a issue. I have a login form that has no connection to laravel form, although its on the same domain, and a POST route with laravel at "login". I can change it to GET and everything works, but I would like to use POST. /online/index.html $("#login").click(function(e){ console.log( $("#loginForm").serialize() ); var request = $.ajax({ url: "../login/", type: "POST", data: { test : "someuser" }, dataType: "json" }); request.done

Laravel subdomain 500 error

家住魔仙堡 提交于 2019-12-11 07:04:08
问题 We are running on shared hosting and running laravel on main domain that is example.com , everything is working perfectly fine. We have crated a sudbomain test.example.com by vising Subdomains manager in cPanel and pointed it's document root to /public_html/test As soon as we visit test.example.com we get 500 Internal Server Error Initial laravel's .htaccess is <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On # Redirect Trailing Slashes...

Laravel environment config not loading, migration fails - SQLSTATE[HY000] [2002] No such file or directory

陌路散爱 提交于 2019-12-11 07:03:49
问题 My app/config/database.php has been setup like this: 'mysql' => array( 'driver' => 'mysql', 'host' => getenv('DB_HOST'), 'database' => getenv('DB_NAME'), 'username' => getenv('DB_USER'), 'password' => getenv('DB_PASS'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ), I have updated my env detection code like this in bootstrap/start.php : $env = $app->detectEnvironment(function() { return file_exists(dirname(__FILE__) . '/../.env.production.php') ? 'production' :

Adding more constrain in sentry 2 authentication processs

…衆ロ難τιáo~ 提交于 2019-12-11 06:59:40
问题 Do you have any ideas, how to add some more constrain while authentication in sentry 2, I have a company table and users belongs to a company, and if the company is disabled(set the active to 0 to mark it as disabled in the company table) then the user should not be able to login. In short while logging some users it should check for the company they belongs to and check if it is active or not, if not then do not log them in or throw an exception. ...Please help if u have any idea about it.

Add foreign Key to Existing Table Laravel 4

淺唱寂寞╮ 提交于 2019-12-11 06:42:17
问题 I can´t added a foreign key to existing table, my first migration is: public function up() { Schema::create('clases_inventario', function($t) { $t->increments('id'); $t->integer('grupos_inventario_id'); $t->integer('laboratorio_id'); $t->string('codigo', 4); $t->string('descripcion', 64); $t->boolean('estado')->default(true); $t->timestamps(); }); } my second migration is to added the forein key is public function up() { Schema::table('clases_inventario', function($table) { $table->foreign(