laravel-4

Extending the Validator class in Laravel

*爱你&永不变心* 提交于 2019-12-24 03:39:08
问题 I wanted extend the Validator class in Laravel. However in all examples the make method is used to create a new instance which I can't find in the Validator source code. How can I override this method? The constructor requires a TranslatorInterface instance so that doesn't seem to be an option? 回答1: The make method is actually in Illuminate\Validation\Factory. If you want to extend this method then you'll need to swap out the IoC binding. Just overload the binding in the container. App:

Simple Validation Rule inside the Model

那年仲夏 提交于 2019-12-24 03:13:00
问题 I refered here Laravel 4.2 Validation Rules - Current Password Must Match DB Value Here is my Rule for Password Confirmation : public static $ruleschangepwd = array( 'OldPassword' => array( 'required'), // need to have my rule here 'NewPassword' => 'required|confirmed|alphaNum|min:5|max:10' ); But I am having my rules in the Model As i saw the below given custom rule in the question Validator::extend('hashmatch', function($attribute, $value, $parameters) { return Hash::check($value, Auth:

Laravel 4: Create a default route

不想你离开。 提交于 2019-12-24 02:42:15
问题 I'm trying to create a default route in my Laravel 4 REST API, that hits, when none of my other defined routes matches the request, to return a specific error to the caller. Is this possible? Unfortunately, I found nothing in the docs, so I played around and tried using a wildcard ( * ) as the last Route definition in my routes.php but that doesn't work. Route::when("*", function(){ throw new CustomizedException('Route not found...'); }); When I have this route and do an artisan routes , I

Laravel 4 from contact form to admin email

房东的猫 提交于 2019-12-24 01:57:16
问题 I'm trying to use Laravel's Mail class for the first time and am having some difficulties. I have a simple contact form that should be sent as an email to the admin. Here is what I have tried Controller (Will be refactored into Model once I can get it working) public function store() { $validation = new Services\Validators\Contact; if($validation->passes()) { $fromEmail = Input::get('email'); $fromName = Input::get('name'); $subject = "Email from user at website.com"; $data = Input::get(

redirect when route doesn't exist laravel 4

冷暖自知 提交于 2019-12-24 01:45:20
问题 I'm using laravel 4 and when i have my project in production mode, i get "Sorry, the page you are looking for could not be found." when i hit a non existing route... When i grep my code it's found in two places: ./vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php:129: $title = 'Sorry, the page you are looking for could not be found.'; ./vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php:52: $this->assertContains('Sorry, the page you are looking for

Laravel templates/controllers not updating on save

徘徊边缘 提交于 2019-12-24 01:24:38
问题 I'm running a Laravel 4 for a simple app on OS X. Basically, changes to controllers and templates don't take effect for a long time after I save changes to those files. For example, I add a word to /app/views/index.blade.php, and don't see any change when constantly refreshing my browser for another minute or so. This makes iterative development understandably painful. I have tried to chmod 777 app/storage/ and all enclosed files, which has no effect. I have also verified this is not a

saving permissions as json in Administrator for this error-> Cannot JSON_decode permissions [Admin]

穿精又带淫゛_ 提交于 2019-12-24 00:34:54
问题 I am using Administrator (frozennode) with Sentry . for permission part when I want to create new group I dont know how should I save the text "user.update" like {"user.update":1} . I have to .because sentry's methods work just with json data. but when I import different kind of permissions or groups how do this? how should I change the Administrator save() method to force it do that just for "permission" field? the save() function -> http://laravel.io/bin/qkr76 thanks for your time 来源: https

Using relationship table's ID in other tables

守給你的承諾、 提交于 2019-12-24 00:05:55
问题 I have 2 entities which are related using a relationship table (ManyToMany) And then I have a pricing table which has pricing information for a service of a hospital. This table can have different pricing for the same service if the hospital linked to the service is different. hospitals: id name services: id name hospital_service: hospital_id service_id service_pricing: id hospital_id service_id weight_range_id LH_price SH_price service_duration: id hospital_id service_id weight_range_id LH

Laravel basic-auth

你说的曾经没有我的故事 提交于 2019-12-23 22:51:32
问题 I want to use basic.auth for my web page but authentication donst work routes.php admin - authentication Route::get('admin', array('before' => 'auth.basic', function() { return 'Top secret'; })); create - create test user Route::get('create', function() { $user = new User; $user->email = 'test@test.com'; $user->username = 'test'; $user->password = Hash::make('password'); $user->save(); }); config app/config/app - has defined key (that created Laravel installation) app/config/auth - has

Laravel Option Select - Default Issue

依然范特西╮ 提交于 2019-12-23 21:50:21
问题 Here is my Select Box, Here All Company will be loaded, But i want to display the Particular company as default selected which i have it in session. Here is my Code $sessioncompany = 'ABCcompany' $comp[''] = 'Company'; @foreach($company_list as $row) <?php $comp[$row->CompanyID] = $row->CompanyName; ?> @endforeach {{ Form::select('CompanyID', $comp, '', array('id' => 'seCompanyID')); }} What i tried is {{ Form::select('CompanyID', $comp, '', array('id' => 'seCompanyID'), array(id=>