laravel-4

Laravel validation: unique rule 4th parameter

…衆ロ難τιáo~ 提交于 2019-12-12 04:57:00
问题 Having a look through the Laravel docs, API documents and source code I am wondering if anyone knows what the 4th parameter id in the following unique rule is for? 'email' => 'unique:users,email_address,NULL,id,account_id,1' My current understanding of this rule is: users - looking in this table email_address - checking against this column NULL - would be where we could specify a primary key/ID value to ignore, but we haven't bothered so this parameter is essentially ignored id - unsure

Activating error messages in laravel 4.2

天涯浪子 提交于 2019-12-12 04:53:53
问题 I am using laravel 4.2 . It is basically a fresh installation. However, when receiving an error I get a page with: Whoops, looks like something went wrong. How to activate detailed error messages during development? I appreciate your answer! 回答1: It's not the way you should do. You should use environments for that. Go to bootstrap\start.php . In: $env = $app->detectEnvironment(array( 'local' => array('yourpcname'), )); Put your PC name here. Now in app/config/app.php make sure you have:

“Class not found” error even after dump-autoload?

雨燕双飞 提交于 2019-12-12 04:38:30
问题 I keep getting the "Class not found" error with newly created models. I know the syntax is absolutely correct. I went over it multiple times and I copied and pasted variables to avoid spelling errors. I also ran php artisan dump-autoload mulitple times, but still no luck. This happens in every file, and it only happens to the newly created models. 回答1: Try using composer instead. php composer dump-autoload If you are not generating the models don't forget to add the folder in the composer

Laravel after composer update model method call undefined

泪湿孤枕 提交于 2019-12-12 04:25:50
问题 I am working on a project with Laravel 4.2 and I created some models and controllers and called model function from controller, the problem is after composer update command it displays this error: Call to undefined method Department::getAllParent() but before composer update it works fine. You think what is the problem with this issue? thanks in advance Model code: class Department extends Eloquent{ /** * The database table used by the model. * * @var string */ protected $table = 'department'

how can redirect domain non-www to www in laravel 4?

泪湿孤枕 提交于 2019-12-12 04:11:23
问题 Hello I try to redirect my domain name from non-www to www via .htaccess file. My previous htaccess code was <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_URI} !^public RewriteRule ^(.*)$ public/$1 [L] </IfModule> I replace it by the code RewriteEngine on RewriteCond %{HTTP_HOST} !^www\.forexfunction\.com RewriteRule (.*) http://www.forexfunction.com/$1 [R=301,L] but i face 404 errors after replacing this code. How can i solve my problem? Thanks in advance. 回答1: This is the

Laravel 4 - change order of items

ぐ巨炮叔叔 提交于 2019-12-12 04:06:51
问题 I have two tables fichas and actividads related in a pivot table called actividad_ficha . In this pivot table I've created another column called orden_actividad (to short the 'activities' in every 'ficha'). I have a View where I show all the 'activities' related with one specific 'ficha'. I would like to be able to drag-and-drop my list of 'actividads' and save the new order automatically. I'm using some jQuery in my application, but AJAX resists to me. Do you know how can I get it? or maybe

Set hasOne relation to new instance of child model

跟風遠走 提交于 2019-12-12 03:56:26
问题 Using Laravel 4.2, how can I set a hasOne relation on a model to an instance of a new model without touching the database? I want to do the following, but Laravel is treating the instance as a property, not a child relation. class ParentClass extends \Eloquent { public function child() { return $this-hasOne('ChildClass', 'child_id', 'parent_id'); } } $parent = new ParentClass(); $parent->child = new ChildClass(); 回答1: To get through my problem, I have created a Trait class that I added to my

Querying Relations Laravel Eloquent ORM

心不动则不痛 提交于 2019-12-12 03:19:50
问题 I have an issue understanding pretty well the Relationships, let's go to the point I have 3 tables, with its proper models receipt - id - date items_sold - id - receipt_id - item_id items - id - name The problem I have is that receipt "has many" items through items_sold, but I can't use "hasManyThrough" because eloquent use the wrong "id" of "items_sold", even if I put manually the keys class Receipt extends Eloquent { public function items() { return $this->hasManyThrough('Items', 'ItemsSold

I lose my bootstrap styles when passing variable (get) to route->Controller->View in Laravel 4

南笙酒味 提交于 2019-12-12 03:18:29
问题 I am integrating a Bootstrap template to laravel 4 and I am having an issue when passing variables through the GET method. My final View renders without any style applied. Let's say I have a link like this: <a href="{{url('offer')}}">Oferta 2015</a> caught by a route like this> Route::get('offer','HomeController@showOffer'); And the controller like: public function showOffer() { $Cursos = Curso::paginate(10); return View::make('cursos.offer')->with('cursos',$Cursos); } That works just fine

Using existing Eloquent models (and possibly other Laravel4 features) in CLI scripts?

痴心易碎 提交于 2019-12-12 03:09:30
问题 I'm working on a project based on the Laravel 4 framework. The framework is awesome, the website works great, no problem with that. But I also have to write several scripts, mostly DB maintenance tasks that will be scheduled in a crontab. I'm looking for a way to write these scripts in the same flavour as the web-site code. Or at least, re-use the models and if possible some other framework features. Is there a way to do that ? Thanks in advance :) Answer : Artisan Commands are indeed the way