laravel-4

Laravel 4 query builder - with complicated left joins

霸气de小男生 提交于 2019-12-09 16:28:48
问题 I'm new to Laravel 4. I have this query: SELECT a.id, active, name, email, img_location, IFNULL(b.Total, 0) AS LeadTotal, IFNULL(c.Total, 0) AS InventoryTotal FROM users AS a LEFT JOIN ( SELECT user_id, count(*) as Total FROM lead_user GROUP BY user_id ) AS b ON a.id = b.user_id LEFT JOIN ( SELECT user_id, count(*) as Total FROM user_inventory GROUP BY user_id ) AS c ON a.id = c.user_id WHERE a.is_deleted = 0 How can I convert it to Laravel query builder? I'm confused on how to use the

Migrating users table with hashed password from old php app to new laravel app

僤鯓⒐⒋嵵緔 提交于 2019-12-09 16:11:27
问题 I am working on an old php app and the password of the users are hashed with the md5() function. So the passwords are stored like: c0c92dd7cc524a1eb55ffeb8311dd73f I am developing a new app with Laravel 4 and I need suggestions on how to migrate the users table without losing the password field. 回答1: Lose the password field as fast as you can, but if you don't want risking to lose users, you can do something like this on your auth method: if (Auth::attempt(array('email' => Input::get('email')

Laravel unit testing emails

旧街凉风 提交于 2019-12-09 15:47:03
问题 My system sends a couple of important emails. What is the best way to unit test that? I see you can put it in pretend mode and it goes in the log. Is there something to check that? 回答1: There are two options. Option 1 - Mock the mail facade to test the mail is being sent. Something like this would work: $mock = Mockery::mock('Swift_Mailer'); $this->app['mailer']->setSwiftMailer($mock); $mock->shouldReceive('send')->once() ->andReturnUsing(function($msg) { $this->assertEquals('My subject',

Class 'Mockery' not found

一世执手 提交于 2019-12-09 15:14:18
问题 I use laravel (4.1) framework and i read "Laravel-testing-decoded", it's a ebook by Jeffrey Wey. I want to test my modal User and my method setPasswordAttribute($password) My unit-testing : <?php class UserTest extends TestCase { public function testHashesPasswordWhenSet(){ Hash::shouldReceive('make')->once()->andReturn('hashed'); $user = new User; $user->password = 'food'; $this->assertEquals('hashed', $user->password); } } But when i launch CLI : phpunit it return me a error : Fatal error:

Laravel 4 mail class, how to know if the email was sent?

家住魔仙堡 提交于 2019-12-09 14:30:56
问题 I'm using the new mail class in Laravel 4, does anybody know how to check if the email was sent? At least that the mail was successfully handed over to the MTA... 回答1: If you do if ( ! Mail::send(array('text' => 'view'), $data, $callback) ) { return View::make('errors.sendMail'); } You will know when it was sent or not, but it could be better, because SwiftMailer knows to wich recipients it failed, but Laravel is not exposing the related parameter to help us get that information: /** * Send

Laravel sessions regenerating on every load

£可爱£侵袭症+ 提交于 2019-12-09 14:30:47
问题 I'm having a lot of problems and I really can't seem to find a solution. Yesterday, I finished up doing some work on a vagrant box in Laravel. When I shut down the computer, login functionality was working fine. On opening everything up today I find sessions are no longer working. I've tried everything I can think of but I cannot log in now and flash data doesn't work. Every page load a new session is created - e.g using the native driver, if I login, it creates two sessions - one for the

IronMq + Laravel4: How make it working

六眼飞鱼酱① 提交于 2019-12-09 13:46:25
问题 I have a problem concerning the fact that my queues are received by IronMQ but not fire off. Like i ask in this question: https://stackoverflow.com/questions/19200285/laravel4-ironmq-queue-are-not-executed But i see that inside my Iron dashboard, after i subscribe a new domain, then it is not added in any list. Probably IronMQ should display a list of Domains subscribed, isn't it? And this is probably the reason why my queues are not fire off. How can i fix the issue? Thanks! 回答1: I'm not

Laravel 4 Class not found in bootstrap/compiled.php

天涯浪子 提交于 2019-12-09 13:44:47
问题 I have created a new branch using Git, applied some updates to my code, checked out that branch on my staging server and I now can't run anything composer related. I've added some new packages to composer.json which work on my development environment, but as soon as I try composer update on the staging environment I get class not found errors relating to the classes it's not yet downloaded. I've tried composer update composer dump-autoload php artisan clear-compiled php artisan dump-autoload

Autocomplete text field in laravel using database

醉酒当歌 提交于 2019-12-09 13:30:08
问题 I am trying to make a autocomplete form like below but the form do not show the suggestion as my database query is ok. Form cole: Controller method code: Routes: When I search on the link I get the query result like this: Shows the result: [{"id":1,"value":"sourav hossen"},{"id":2,"value":"sourav hossen"},{"id":3,"value":"sourav hossen"},{"id":4,"value":"a b"},{"id":5,"value":"a a"}] 回答1: Try this change, some time will work. source: "{{URL::route('autocomplete')}}", 回答2: I tried to do it

Affect on security of Laravel 5 when change folder structure to remove public folder

两盒软妹~` 提交于 2019-12-09 13:11:12
问题 I'm new in Laravel 5. I found this Laravel 5 - Remove public from URL on Stack Overflow to remove public folder from my Laravel 5 App. Only I have a question about the security. When I am removing public from URL, then I have to change the basic folder structure of Laravel 5. Yes, it's working fine without the public from the URL. But what's about the security of Laravel, because I am changing the default folder structure? Is it secure to use? 回答1: You should be pointing your Apache host root