laravel-4

Laravel 4 Form Validation, Extending the __call() method

假如想象 提交于 2019-12-18 09:53:50
问题 I want to extend the Form validation class to support array form elements like described here for L3 in L4. First, I changed the Validator alias with this in my app/config/app.php : 'Validator' => 'app\lib\Support\Facades\Validator', Then , I saved these codes as app/lib/Support/Facades/Validator.php <?php namespace app\lib\Support\Facades; class Validator extends \Illuminate\Support\Facades\Validator { public function __call($method, $parameters) { if (substr($method, -6) === '_array') {

Laravel, You need to specify a file path to store the seed

余生长醉 提交于 2019-12-18 09:26:57
问题 I have copy my new Laravel project in my new directory. But my project is not included with "vendor" directory. So I run command: composer install And everything run smoothly vendor direcotory created and filled in with packages. Then I refresh my web page, suddenly I get an error. But usually I do like this without error. You need to specify a file path to store the seed The error was in file D:\www\laravel\myproject\vendor\symfony\security\Symfony\Component\Security\Core\Util\SecureRandom

How can I change the timezone of the outputted date in Laravel 4?

心已入冬 提交于 2019-12-18 09:25:47
问题 I have a database with an entity table and a users table. The entity table has fields for created_at and updated_at . The users table has a timezone field with a default value of America/Toronto . In my view, I can output the date in the format I want with the following code: $entity->created_at->format('M j, Y \\a\\t g:i A') Now, how can I output the date using the timezone field in the users table? Something like ... $entity->created_at->format('M j, Y \\a\\t g:i A', Auth::user()->timezone)

Laravel, You need to specify a file path to store the seed

最后都变了- 提交于 2019-12-18 09:25:14
问题 I have copy my new Laravel project in my new directory. But my project is not included with "vendor" directory. So I run command: composer install And everything run smoothly vendor direcotory created and filled in with packages. Then I refresh my web page, suddenly I get an error. But usually I do like this without error. You need to specify a file path to store the seed The error was in file D:\www\laravel\myproject\vendor\symfony\security\Symfony\Component\Security\Core\Util\SecureRandom

order of route declarations in laravel package

老子叫甜甜 提交于 2019-12-18 09:05:50
问题 I have made a laravel package which contains a route, it is a special route that catches a large number of possible urls. I don't want my route to take precedence over other packages or routes declared in the main application. How can I ensure that my route is the last route declared? 回答1: Routes are evaluated in the order that they are listed in routes.php. Simply making sure this route is the last one in the array should do it. update I believe you could just register the route in the App:

Laravel 4 validation email unique constraint

余生长醉 提交于 2019-12-18 08:32:12
问题 I'm writing a Laravel 4 app that has a users table with the usual contact info. In my users model, my validation for the email specifies 'email'=>'required|email|unique:users', which works fine when registering new users. My question is how to handle the user edit form-- when the form is submitted, I'd like for the unique email constraint to only be fired if it's not the same as the old email-- otherwise you can't save your profile, since the email (your email) is already inuse. Thanks 回答1:

Laravel Access denied for user 'root'@'localhost' (using password: YES) in laravel 4.2

自古美人都是妖i 提交于 2019-12-18 08:27:37
问题 I have old project which built using Laravel 4.2.I am getting following error PDOException (1045) SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) I have googled and tried every think but i couldn't able to fix it .env file APP_KEY=az9tq5VHQCV9g5m2CsgY89jtijrCMgEA DB_HOST=localhost DB_DATABASE=billing DB_USERNAME=root DB_PASSWORD=1234 database.php 'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'billing', 'username' => 'root',

Laravel - Auth Session not expiring after browser close

帅比萌擦擦* 提交于 2019-12-18 08:21:13
问题 I am having a problem about sessions, or cookies, I didn't understand the reason. I log on to my site with Auth::attempt($userdata, false) , which means Laravel should not remember my login, but it remembers whether I use true or false in attempt function. in app/config/session.php , variables are determined as 'lifetime' => 120, 'expire_on_close' => true, Also, when I log in with Auth::attempt($userdata, true) , 'Auth::viaRemember()' function returns false . Edit: Question solved. Cause of

Blade Comments in Laravel are crashing apache

本秂侑毒 提交于 2019-12-18 07:44:30
问题 any comments included in a blade are causing apache to crash when I try to load said page. The project I'm working on uses blade comments for notes and everything, so removing them isn't an option. I'm using xampp on windows. Anyone have any ideas? 回答1: You must ensure that your blade opening and closing tags are correct and don't use the @ character in the comment: {-- Should work --} {-- @will crash --} {-- that @doesn't work either --} 来源: https://stackoverflow.com/questions/28174162/blade

Laravel pagination not working with group by clause

情到浓时终转凉″ 提交于 2019-12-18 06:09:27
问题 It seems Laravel pagination deos not working properly with group by clause. For example: $users = Subject::select(DB::raw('subjects.*, count(user_subjects.id) as total_users')) ->join('user_subjects', 'user_subjects.subject_id', '=', 'subjects.id') ->whereNull('user_subjects.deleted_at') ->groupBy('subjects.id') ->orderBy('subjects.updated_at', 'desc') ->paginate(25); Produced select subjects.*, count(user_subjects.id) as total_users from `subjects` inner join `user_subjects` on `user