laravel-4

Can't pass class instance to constructor

给你一囗甜甜゛ 提交于 2019-12-05 19:20:25
I have a User eloquent model that takes in an instance of the UserMailer class in its constructor but I get this error Argument 1 passed to User::__construct() must be an instance of TrainerCompare\Mailers\UserMailer, none given, called in /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php on line 631 and defined I understand the error but can't figure out what I have done wrong but I don't udnerstanding namespacing and composer class map vs psr0 autoloading very well. I have remembered to use composer dump-autoload so it is not that relevant folder structure composer

Laravel 4 Can't find BaseController from namespaced controller

痴心易碎 提交于 2019-12-05 19:03:46
I'm trying to structure my Laravel 4 site such that (1) major application groups' components (controllers/views/etc) are coupled together and (2) Laravel's supporting code outside of in my web server's document root. The default laravel home page loads fine, but I can't get a namespaced controller to route correctly. This is the relevant file structure: / [Project Root] /laravel [full laravel install here] composer.json /app /controllers BaseController.php /dev /htdocs index.php /app /PageTypes /Home /controllers HomeController.php /views HomeView.blade.php The default laravel landing page is

How do I change the domain when using URL::action()

二次信任 提交于 2019-12-05 19:00:49
I am trying to duplicate something that was available in Laravel 3. I want to be able to specify an alternate domain name for a route. For example, I have a route that produces the following with this code: URL::action('DashboardController@something') // Produces: http://somedomain.com/dashboard/something I want to be able to specify a different domain. This used to be in the config/application.php file as 'url'. This no longer works in L4. Is there a way to specify a base url to use whenever a URL is being constructed? Laravel 4 uses the Domain specified in the HTTP Request Header Field Host

cannot use class because it is not a trait

佐手、 提交于 2019-12-05 18:47:01
问题 I have followed the tutorial here on building a validation service for laravel. I am having issues now when trying to call the validator from one of my controllers. I am seeing the error: validController cannot use Portal\Service\Validation\Laravel\AppInstancesValidator - it is not a trait here is my controller: class validController extends BaseController { use \Portal\Service\Validation\Laravel\AppInstancesValidator; public function validateInstance() { $post = Input::all(); $instVal = new

Laravel 4: Cannot send email with inline embedding

眉间皱痕 提交于 2019-12-05 18:39:13
Need help: how to send emails with inline image? The response returns 200 OK but email is not being sent. But when I removed $message->embed() everything is alright. I used {{ $message->embed('img/logo.png') }} in the view file, but the email is not sending, is it wrong location of image? (i have triedputting logo.png in public/img dir and app/views/emails/img dir, my email view file is in app/views/emails/mail.blade.php).Or is it something else? for Embeding an image try this: <img width="250px" src="{{ $message->embed(public_path('img/logo.png')) }}" alt="logo"> remember that folder img must

Laravel 4: Prevent form re-submissions

社会主义新天地 提交于 2019-12-05 18:37:30
I have gone through this question , but the answer posted their doesn't solve my problem. The problem that occurs is that if the user hits the back button of the browser to return to the submitted form, the entered data persists and the user is able to "re-submit" the form. How can I prevent this behaviour (laravel's way)? my route.php looks like Route::group(array('after' => 'no-cache'), function() { Route::get('/', 'HomeController@index'); Route::ANY('/search','HomeController@search'); Route::get('user/login',array('as'=>'user.login','uses'=>'UserController@getLogin')); Route::post('user

Laravel use Hash as Validator

不羁的心 提交于 2019-12-05 18:37:01
i'm using Hash::check() to check current password with entered password. i use this if for check this action $HashPassowrd = Hash::make(Input::get('password')); if( ! Hash::check( Input::get('currPassword') , $data->password ) ) { return Redirect::to('profile.update') ->withErrors('Current Password in Incorrect!'); } how to use that as validator ? for example in this rules $rules = array( 'name' => 'required|alpha', 'family' => 'required', 'email' => 'required|email', 'currPassword'=> 'required', 'password' => 'required|confirmed', 'password_confirmation'=>'required', ); You can add custom

htmlentities() expects parameter 1 to be string, array given

大憨熊 提交于 2019-12-05 18:24:31
I'm trying to add a class to a laravel form. The array is being passed as the third argument, as required, but I get the above error. {{ Form::input('text', $variable->name, array('class' => 'form-control')) }} If I get rid of the third argument, the form displays as expected (unstyled). I can't see what I'm doing wrong here - can anyone help? {{ Form::text('text', $variable->name, array('class' => 'form-control')) }} I can see from the api that there is another argument expected: http://laravel.com/api/source-class-Illuminate.Html.FormBuilder.html#235-246 ('text', $name, $value, $options)

How to remove save username and password in composer (laravel 4)

回眸只為那壹抹淺笑 提交于 2019-12-05 18:13:26
I have updated my laravel vendor using composer. I have bought a package which is located in a github private repo. On downloading composer ask username and password, I have entered the wrong password so it gives me an error. After that I run composer update again but this time it just keep the old wrong password it did not ask me to enter the password again, somewhat save in composer cache. How could I remove the old password in composer? In your ~/.composer , you'll have a file named config.json which contains OAuth token used to log you in GitHub. Clear your OAuth token or delete this file.

Clarify how to setup a one-to-many relationship in Laravel's Eloquent ORM

你说的曾经没有我的故事 提交于 2019-12-05 17:45:27
问题 Okay, I'm working through the Laravel 4 docs to setup a one-to-many relationship between two models. Obviously, one side should use hasMany(). But for the other side, should I use hasOne or belongsTo? Does it matter? What's difference? Why do both exist? I had thought hasOne would be for one-to-one relationships, and belongsTo would be for the one side of one-to-many. But in the docs, for inserting a related model here: http://laravel.com/docs/eloquent#inserting-related-models they are using