laravel-4

One of my migrations is not running with the php artisan command in Laravel 4

匆匆过客 提交于 2019-12-10 21:37:56
问题 I have several migrations I am running in Laravel 4. I use the php artisan migrate:rollback and php artisan migrate commands to populate the tables. Interestingly enough, one of my migrations has stopped working (cannot roll back). All of the others are working fine. I haven't changed anything to my knowledge. The migration in question is named: 2013_06_19_050252_create_artists_table.php And it looks like so: <?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema

Cannot run raw Query in Laravel 4

守給你的承諾、 提交于 2019-12-10 21:34:56
问题 I need to get total count to show in my page. I can run this & loop through & get the total number DB::table('table1') ->select((DB::raw('MAX(score)'))) ->where('status', 1) ->groupBy('user_id') ->get(); But this query would give me the count in just a single query & I don't need run any extra loop to get the total. SELECT COUNT( * ) FROM ( SELECT MAX( score ) FROM table1 WHERE status =1 GROUP BY user_id ) AS totalCounter How am I suppose to run this RAW query in Laravel 4? 回答1: As mentioned

laravel 4 auth::attempt password in plaintext

落花浮王杯 提交于 2019-12-10 21:09:05
问题 How do you tell the laravel auth::attempt that the password field is stored in plaintext instead of it assuming that it is hashed? With-in the guard.php public function attempt(array $credentials = array(), $remember = false, $login = true) { $this->fireAttemptEvent($credentials, $remember, $login); $user = $this->provider->retrieveByCredentials($credentials); // If an implementation of UserInterface was returned, we'll ask the provider // to validate the user against the given credentials,

Install Laravel behind proxy

…衆ロ難τιáo~ 提交于 2019-12-10 21:05:13
问题 Im trying to install Laravel on a windows machine. I followed this guide up to point 11. http://www.wikihow.com/Install-Laravel-Framework-in-Windows I also ran two commands already (which I got from https://stackoverflow.com/a/18852026/2240163) set http_proxy=<your_http_proxy:proxy_port> set https_proxy=<your_https_proxy:proxy_port> But on running composer install i am met with a message C:\wamp\www\LARAVEL>composer install Loading composer repositories with package information [Composer

using touch() to update timestamp of custom timestamp field in laravel

狂风中的少年 提交于 2019-12-10 21:04:18
问题 Is there a way to use touch() for updating timestamp of is_online field in table instead of updating created_at field in laravel Eloquent ORM At present I am using User::where('id',$senderId )->update(array('is_online' => date('Y-m-d H:i:s'))); 回答1: No, the touch method isn't written for updating anything other than the built in timestamps, but you could write your own function in your User Model, if you want to. Something like this class User extends Eloquent implements UserInterface,

Contact form Laravel 4

社会主义新天地 提交于 2019-12-10 20:54:32
问题 Im a noob with Laravel 4 and the contact form things is giving me some trouble to make it work. Found few things, all using controllers but I just need it in the route. How to do the route for a simple contact form (name,email and message) to send the datas to an admin email box? Cheers 回答1: Here's a quick and dirty way to send e-mails using just your routes: Create your routes Route::get('contact', function() { return View::make('contact'); }); Route::post('contact', function() { $fromEmail

laravel first0rNew Integrity Constraint Violation

牧云@^-^@ 提交于 2019-12-10 20:39:38
问题 I'm using Laravel Eloquent's firstOrNew() function to retrieve a DB record based on 3 criteria: $summary = $this->firstOrNew(array( 'date' => $date, 'product_id' => $product_id, 'store_id' => $store_id, )); I also have a unique composite key of those 3 fields. Even though the record exists, the function doesn't retrieve it, so when I update an attribute and run $summary->save() I get the wonderful SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry >'2015-01-02-6-23' for key

Parse Error when deploying on shared hosting ( Laravel 4 )

三世轮回 提交于 2019-12-10 20:28:21
问题 I for some reason am getting an error when trying to deploy my app to a shared host. I am getting this error : Parse error: syntax error, unexpected '[' in public_html/dev/vendor/laravel/framework/src/Illuminate/Support/helpers.php on line 411 function class_uses_recursive($class) { $results = []; foreach (array_merge([$class => $class], class_parents($class)) as $class) { $results += trait_uses_recursive($class); } return array_unique($results); } I am aware that Laravel 4 needs PHP >= 5.4

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

自闭症网瘾萝莉.ら 提交于 2019-12-10 20:25:34
问题 I know this is a common problem but don't know what's wrong here. As you can see there's this //return $user and it shows an valid id. Checked that in database as well. $user = new User; $user->first_name = $data['first_name']; $user->last_name = $data['last_name']; $user->email = $data['email']; $user->phone_no = $data['phone_no']; $user->created_from = 'Web App'; $user->save(); // return $user; Session::put('user_id',$user->id); // return $user->id; $address = new Address; $address->user_id

Laravel query builder: Select all fields except for a few

旧时模样 提交于 2019-12-10 20:09:48
问题 With the Laravel query builder, it is easy to select or alias fields with ->select() . How do I select all fields except for a few? For example, I wish never to return the id of my record back to the front end. 回答1: http://laravel.com/docs/4.2/eloquent If you don't mind still technically selecting them, you can suppress fields from Laravel's default array/JSON conversion: class User extends Eloquent { protected $hidden = ['password', 'id', ...]; } 来源: https://stackoverflow.com/questions