laravel-4

laravel one to one relationship

淺唱寂寞╮ 提交于 2020-01-16 19:15:34
问题 I have xml_document table with these columns: id general_information_id I have general_information table with these columns: id domain log_file The relationship between them is one to one. Have I build the relationship correctly? Or I need to add xml_document_id column to the general_information table. Secondly: I have added a row to the xml_doucment and now I want to add a row to the general_information and link this new row to the xml_document I tried this: $xmlDocument = XmlDocument::find

Multiple routes defaults to controller in Laravel

陌路散爱 提交于 2020-01-16 18:42:53
问题 I want to be able to get to an article by a short-link, like this articles/ID , but I also want to get there with the full link articles/ID/category/slug . But I can not get the following to work: // Route file: Route::pattern('id', '[0-9]+'); Route::pattern('cat', '^(?!create).*'); Route::pattern('slug', '^(?!edit).*'); Route::get('articles/{id}/{cat?}/{slug?}', ['as' => 'articles.show', 'uses' => 'ArticlesController@show']); // Controller file: public function show($id, $cat = null, $slug =

Multiple routes defaults to controller in Laravel

≡放荡痞女 提交于 2020-01-16 18:42:11
问题 I want to be able to get to an article by a short-link, like this articles/ID , but I also want to get there with the full link articles/ID/category/slug . But I can not get the following to work: // Route file: Route::pattern('id', '[0-9]+'); Route::pattern('cat', '^(?!create).*'); Route::pattern('slug', '^(?!edit).*'); Route::get('articles/{id}/{cat?}/{slug?}', ['as' => 'articles.show', 'uses' => 'ArticlesController@show']); // Controller file: public function show($id, $cat = null, $slug =

Artisan-commands need different hostname in db-config than Laravel itself

情到浓时终转凉″ 提交于 2020-01-16 18:41:52
问题 This is a strange one I've never been able to solve ever since I started using Laravel. When I issue artisan-commands like 'php artisan migrate' in my db-config (I'm using MySQL via MAMP) the host line has to be: 'host' => 'localhost:8889', However when loading a page in the web-browser I get: SQLSTATE[HY000] [2005] Unknown MySQL server host 'localhost:8889' It magically works when I change it to: 'host' => 'localhost', On the live-server I'm running the application on I don't have this

Artisan-commands need different hostname in db-config than Laravel itself

夙愿已清 提交于 2020-01-16 18:41:11
问题 This is a strange one I've never been able to solve ever since I started using Laravel. When I issue artisan-commands like 'php artisan migrate' in my db-config (I'm using MySQL via MAMP) the host line has to be: 'host' => 'localhost:8889', However when loading a page in the web-browser I get: SQLSTATE[HY000] [2005] Unknown MySQL server host 'localhost:8889' It magically works when I change it to: 'host' => 'localhost', On the live-server I'm running the application on I don't have this

Paypal REST PHP SDK giving me a 400 error (laravel library)

五迷三道 提交于 2020-01-16 18:27:07
问题 I'm using the paypal REST SDK for PHP, using the laravel wrapper which gives me a 400 error (bad input from what I understand) I mostly copied from the example found at: enter link description here Yet I'm getting a 400 error sent back. I can't figure out what I'm doing wrong: here's the code. $payer = Paypalpayment::Payer(); $payer->setPayment_method("paypal"); $item1 = Paypalpayment::Item(); $item1->setName('Lavender 6 oz') ->setCurrency('USD') ->setQuantity(1) ->setPrice('7.50'); $itemList

How to pass a value from a JS function to a laravel controller?

喜欢而已 提交于 2020-01-16 14:54:13
问题 I am having trouble with JQ and laravel controller. As this is a JS file which need to call a controller with a value in it. function follow_or_unfollow(id,action) { either route call myUrl = "{{ route('follows.show','id') }}" ; or controller call myUrl = "{{ action('FollowsController@show', 'id') }}" ; bla bla bla ! } What I need is : to send the value of the id by printing there at the place where 'id' is mentioned. at this moment it is printing as id instead of value of the id. I have

Laravel Unit Tests cannot find namespaced class

时光毁灭记忆、已成空白 提交于 2020-01-16 05:51:30
问题 I have a pretty basic Laravel setup that I am starting to test. I have my own library files in the folder app/framework and all the files are under the namespace "CompanyName\Framework". I added these files to the composer.json file to have it autoloaded in my app. My composer.json is then : "autoload": { "classmap": [ "app/commands", "app/controllers", "app/models", "app/database/migrations", "app/database/seeds", "app/tests/TestCase.php", "app/framework" ] In my controller I can use my

Regex temperature validation

允我心安 提交于 2020-01-16 05:11:04
问题 How will the temperature validation in regex be ? The temperature could be both integer and decimal but not text. I am not setting any limits of how many digits, simple as it could be both integer and decimal. This is the regex for XX,XX format: 'regex:/[\d]{2},[\d]{2}/' 回答1: You could do this, it matches XX and XX,XX for any number of digits on either side of ',' : 'regex:/[\d]*,?[\d]*/' Optionally, you can do this for the units as well: (132.0 C) or (32.0000 F) or (32. K) 'regex:/[\d]*,?[\d

Laravel 4 php artisan migration not working

做~自己de王妃 提交于 2020-01-16 04:12:28
问题 I am trying to follow a tutorial about the basics of Databases and i am at the part of setting up Sentry 2. I added all the exceptions as requested. But on step four of the documentation page on the Sentry 2 website. I am getting the following error {"error":{"type":"ErrorException","message":"Undefined index: collation","file":"\/var\/www\/db_test\/vendor\/laravel\/framework\/src\/Illuminate\/Database\/Connectors\/MySqlConnector.php","line":22}} I tried a few things as noted in my ssh screen