laravel-4

Laravel 4 - db transaction on save while automatically creating other model

ⅰ亾dé卋堺 提交于 2019-12-08 11:09:14
问题 I have two models: UserPayout and UserTransaction where UserTransaction is polymorph and needs to know which model it belongs to. Whenever a user creates a payout, a transaction should automatically be made. If something went wrong in this process, both should get rolled back. My actual solution is as follows: Controller: $user_payout = new UserPayout($input); $user->payouts()->save($user_payout); UserPayout: public function save(array $options = Array()) { DB::beginTransaction(); try{ parent

Routing Issue, Calling Controller based on Variables in URL- Laravel 4

白昼怎懂夜的黑 提交于 2019-12-08 10:24:51
问题 I am developing an application with Laravel 4 what I need to do is this: let's say I have the following route: Route::get('/myroute/{entity}/methodname', ); Inside it I need to decide based on the entity variable which Controller and method should be called for example: 'MyNameSpace\MyPackage\StudentController@methodname' if the entity == Student and call the 'MyNameSpace\MyPackage\StaffController@methodname' if the entity == Staff how in can be done in Laravel 4 routing is it possible at all

Loading multiple select options into array

不打扰是莪最后的温柔 提交于 2019-12-08 09:46:04
问题 I have a Select menu in my reports view that should allow a user to select multiple 'status', then in my controller the query results should be in all the selected 'status'. However I am unsure how to format the ->whereIn to include those statuses. Any Ideas on what I need to do, I am just getting started with Laravel. This is the part in the query where I am trying to use the array. also the controller public function reportFailedPayments(){ $paymentstatus = Input::get('PaymentStatus');

Laravel 4 refuses to load iframe due to 'X-Frame-Options' to 'SAMEORIGIN'

孤街醉人 提交于 2019-12-08 09:33:03
问题 I am building a chrome extension in which I am showing an iframe on a popup from the Gmail home page. As Gmail home page is in HTTPS , my iframe should also be in https. I configured apache2 by enabling mod_ssl and got HTTPS working on apache2. I made a native PHP page and tried to show that on the frame which is on Gmail page. I had no problems it was loading the page from localhost. But when I wanted to use a Laravel backend, it showed me error. Refused to display 'https://localhost/laravel

Laravels neat testing helpers in workbench?

筅森魡賤 提交于 2019-12-08 09:25:46
问题 Looking at the laravel testing documentation, you get an idea of all the cool helpers I'd love to use in workbench. Sadly I'm unable to do so. Illuminate\Foundation\Testing\TestCase seems to be unavailable when running my tests from the package directory and therefore i can't extend it. <?php namespace Acme\Foo; class TestCase extends \Illuminate\Foundation\Testing\TestCase { /** * Creates the application. * * @return \Symfony\Component\HttpKernel\HttpKernelInterface */ public function

Using passwords hashed in CakePHP in Laravel environment

為{幸葍}努か 提交于 2019-12-08 09:23:37
问题 Currently I am working on rebuilding an existing website, the old site was written in CakePHP but the new one is in Laravel. The old users will have to be able to login with the same password as they used on the old site, but those passwords were hashed in CakePHP. My question is: Is there a method which would enable me use the CakePHP way of passwordhashing in Laravel? I have tried looking for a package that could accomplish this, but to no avail. 回答1: I had a similar issue with a migration

Laravel rest path

对着背影说爱祢 提交于 2019-12-08 08:21:14
问题 I have this route.php file: Route::group(array('prefix' => 'api'), function () { Route::resource( 'login', 'TokenController', ['only' => ['index', 'create', 'store', 'destroy']] ); }); Here is php artisen routes output: +--------+---------------------------+-------------------+-------------------------+----------------+---------------+ | Domain | URI | Name | Action | Before Filters | After Filters | +--------+---------------------------+-------------------+-------------------------+---------

Laravel4 route pattern error

筅森魡賤 提交于 2019-12-08 07:24:27
问题 I´m using laravel 4 for a cms project, and i´m having some problems with my routes... These are my current routes Route::get('/', 'IndexController@showNews'); Route::get('/logout', 'UserController@logout'); Route::resource('/login', 'UserController'); Route::resource('/user', 'UserController@index'); Route::resource('/user/{route}', 'UserController'); // Routes that shows us the pages... Route::get('/{page}', 'IndexController@showPage'); Route::get('/{page}/{id}', 'IndexController@showPage');

How to make controllers, models, views outside app folder in Laravel 4?

时光毁灭记忆、已成空白 提交于 2019-12-08 06:21:13
问题 I want to make a structure folder like this: root/ admin/ controllers/ AdminController.php BaseController.php models/ views/ app/ ... etc I updated composer.json: "autoload": { "classmap": [ "app/commands", "app/controllers", "app/models", "admin/controllers", "admin/models", "admin/views", "app/database/migrations", "app/database/seeds", "app/tests/TestCase.php" ] }, And then run 2 commands: composer dump-autoload , php artisan dump-autoload and create a route: Route::get('/admin',

Laravel - Change Database Connection for a specific URL?

∥☆過路亽.° 提交于 2019-12-08 06:13:27
问题 I am fairly new to using laravel framework. I have the following requirement. I have a domain - example.com, and its entire code stack is running in laravel. Lets say in the config default database connection is - 'db1' Now, if the url becomes - example.com/country - I want the default database connection to become - 'db2' And also I want the base URL to be changed to example.com/country, since all the modules are going to be the same. Only the database connection is going to change here.