laravel-4

PHP Laravel recursive function with nested array

。_饼干妹妹 提交于 2019-12-11 13:48:35
问题 I am using Laravel 4 with MySQL back-end. I want to store records of a nested array into database using recursive function . The input array is as below : Array ( [0] => Array ( 'id' => 561, 'type' => 'q', 'subtype' => 'boolean', 'title' => 'Did you..?', 'parent' => 560, 'created_at' => '2014-07-09 09:45:50', 'updated_at' => NULL, 'deleted_at' => NULL, 'children' => Array ( [0] => Array ( 'id' => 562, 'type' => 'o', 'subtype' => NULL, 'title' => 'Yes', 'parent' => 561, 'created_at' => '2014

Upgrade to Laravel 4.1 error

回眸只為那壹抹淺笑 提交于 2019-12-11 13:31:56
问题 I believe I have all my dependencies ready for 4.1, but I get the following errors when I use composer update: Generating autoload files Script php artisan clear-compiled handling the post-update-cmd event returned with an error: Script php artisan optimize handling the post-update-cmd event returned with an error: My composer file is as follows: { "require": { "laravel/framework": "4.1.*", "jasonlewis/basset": "dev-master", "twbs/bootstrap": "dev-master", "frozennode/administrator": "dev

Laravel 4 Eloquent/Model Relationships

☆樱花仙子☆ 提交于 2019-12-11 13:24:24
问题 I am setting up several Models an want to know the correct approach to table structure and Model relationships. Let's assume we have a shop containing products, each with properties size and color. Table products id size_id color_id price Table sizes id name Table colors id name Models class Product extends Eloquent { public function size() { return $this->hasOne('Size', 'id'); } public function color() { return $this->hasOne('Color', 'id'); } } class Size extends Eloquent { public function

2 Laravel apps, only one can login

前提是你 提交于 2019-12-11 13:11:41
问题 I'm creating a web app and I need to deploy it as multiple web app instance Let's say I'm deploying app as root |_ app1 |_ app2 |_ app3 Both app2 dan app3 are cloned from app1 via git. After that I do composer install and let them installs.. everything went fine when I log in to app1 , but after logging in to app2 , My app1 login was logged-out without clear reason. My first verdict was the session colliding, but I don't find any lead changing Laravel session key... So I tried changing the

Updating previous Session Array Laravel

99封情书 提交于 2019-12-11 12:59:28
问题 I have an issue on how can I update my Previous array ? What currently happening to my code is its just adding new session array instead of updating the declared key here's my code: foreach ($items_updated as $key => $added) { if ($id == $added['item_id']) { $newquantity = $added['item_quantity'] - 1; $update = array( 'item_id' => $items['item_id'], 'item_quantity' => $newquantity, ); } } Session::push('items', $updated); 回答1: $items = Session::get('items', []); foreach ($items as &$item) {

Defining content outside the controller?

大憨熊 提交于 2019-12-11 12:51:41
问题 In Laravel, every method in the controller will contain $heading['panelText'] For example: public function pageName1() { $heading['panelText'][] = "Content Here one"; $heading['panelText'][] = "Content Here Two"; $heading['panelText'][] = "Content Here Three"; return View('mockup/pagename1', compact('heading')); } public function pageName2() { $heading['panelText'][] = "Some Random one"; $heading['panelText'][] = "Some Random Line Two"; return View('mockup/pagename2', compact('heading')); }

Laravel cannot find class of a package

左心房为你撑大大i 提交于 2019-12-11 12:41:29
问题 Hello I have created a new Package for a Laravel project I am working on, I am new to the concept of packages and laravel itself, but here is the code I have come up with, /workbench/cycs/proofhq/src/Cycs/Proofhq/ProofhqServiceProvider.php public function boot() { $this->package('cycs/proofhq'); } /** * Register the service provider. * * @return void */ public function register() { $this->app->booting(function() { $loader = \Illuminate\Foundation\AliasLoader::getInstance(); $loader->alias(

Laravel Roles & Permissions with Authority

我只是一个虾纸丫 提交于 2019-12-11 12:41:08
问题 From my research, I have found that the Authority package (https://github.com/machuga/authority-l4) is best for implementing a role/permissions based user auth system while maintaining flexibility. I am having trouble understanding exactly how to use this package. The documentation covers it's functions and configuration, but does not explain a few things. Was hoping someone could point me in the right direction. What is the purpose of the config file? To specify permissions? Are these not

Routes collision in Laravel 4

送分小仙女□ 提交于 2019-12-11 12:19:30
问题 I am working on a project using Laravel 4, I have a "user route" to show user profiles by their username: Route::get("user/{username}", array( 'as' => 'userProfile', 'uses' => 'UserController@getProfile') ); But here I have another route which shows a user's messages. Route::get('user/messages', array( 'as' => 'userMessages', 'uses' => 'MessageController@getMessages') ) But there is a collision here. Laravel thinks "messages" is a username because of first Route. How can I work around this?

get current path outside of Route

安稳与你 提交于 2019-12-11 12:14:25
问题 In this URL: http://siteName/html/test I want to catch test , of course inside the route. This works great: Route::get('test', function() { return Route::getCurrentRoute()->getPath(); }); But I want to access the path outside of any route and in my route.php file like this: // routes.php return Route::getCurrentRoute()->getPath(); Route::get('test', function() { ... }); 回答1: In case you try to catch all routes. Add this as your last route. Route::any('{all}', function($uri) { return Route: