laravel-4

Redirect to external URL with return in laravel

送分小仙女□ 提交于 2019-12-20 10:19:30
问题 I am trying to send one time password to a user using SMS INDIA HUB API. For that purpose I need to redirect to a URL format: http://cloud.smsindiahub.in/vendorsms/pushsms.aspx?user=abc&password=xyz&msisdn=919898xxxxxx&sid=SenderId&msg=test%20message&fl=0&gwid=2 If we load this URL, it will return some message. I need to get that message to. I tried like this $url = "http://cloud.smsindiahub.in/vendorsms/pushsms.aspx?user=wwww&password=eee&msisdn=9197xxxxx&sid=yyyyy&msg=rrrrr&fl=0&gwid=2";

Laravel Pass Parameter from Route to Filter

为君一笑 提交于 2019-12-20 10:13:37
问题 I am using the laravel framework. If I have the following route: Route::get('/test/{param}', array('before'=>'test_filter', 'SomeController@anyAction')); And this filter: Route::filter('test_filter', function() { $param = [Get the parameter from the url]; return "The value is $param"; }); How can I pass parameters to the filter so that when visiting /test/foobar I would get a page saying: "The value is foobar"? 回答1: Filters can be passed parameters, like the Route object or the Request:

Need to set a 1 to many relationship in the same table in Laravel 4

ぐ巨炮叔叔 提交于 2019-12-20 10:04:27
问题 I have the following models Category: <?php class Category extends Eloquent { protected $table = "category"; protected $fillable = array('title','parent','metatit','metadsc','metake','metaurl','image'); public function categoryitems(){ return $this->hasMany('CategoryItem','catid'); } public function parent(){ return $this->hasMany('category','parent'); } public function child(){ return $this->belongsTo('Category','parent'); } } Need to set a 1 to many relationship in the category table Ex

Laravel 4: How to apply a WHERE condition to all queries of an Eloquent class?

戏子无情 提交于 2019-12-20 10:00:31
问题 I'm trying to implement an "approved' state for a table I have, it's pretty straightforward, basically, if the row's approve column equals 1; that row should be retrieved, otherwise it shouldn't. The problem is, now I have to go through the whole codebase and add a WHERE statement(i.e., function call) which is not only time consuming but also inefficient(if I ever want to remove that feature, etc.) How can I do that? Is it as easy as adding $this->where(..) inside the Eloquent child class'

First Shot at Testing Laravel 4 apps (PHPSpec/BDD vs. PHPUnit/TDD)

戏子无情 提交于 2019-12-20 09:56:18
问题 I have been wrestling with this question for far too long now. I know I need to just jump into one or the other since they are both obviously viable/useful tools, but have been stuck on the fence, researching both, for weeks. PHPUnit vs. PHPSpec - Which one may lead to better long-term maintainability and programming practices? I have talked to several seasoned PHPUnit -> PHPspec converts/users who now swear by PHPspec, claiming that it promotes better design thanks to its BDD approach.

Unable to execute Laravel artisan commands

无人久伴 提交于 2019-12-20 09:51:54
问题 I just installed the latest version of Laravel and tried to run the following command from my Git Bash: php artisan migrate:make create_users_table --table=users --create This triggers the following error: Could not open input file: artisan I have tried a number of things I found here on this site, but nothing seems to work. Any suggestions on how to make it work? 回答1: tl;dr Run composer install in your project's root folder. Explanation This happens when you create a project by downloading

laravel is not recognized as an internal or external command

人走茶凉 提交于 2019-12-20 09:48:44
问题 I'm trying to start laravel, Found the following line in their tutorial: Make sure to place the ~/.composer/vendor/bin directory in your PATH so the laravel executable is found when you run the laravel command in your terminal. I don't understand what I should do ? I added ~/.composer/vendor/bin to my system variables, and then tried using 'laravel new blog' in the command line but got the following message : laravel is not recognized as an internal or external command what should I do? 回答1:

Install dependency (doctrine/dbal) on composer laravel

僤鯓⒐⒋嵵緔 提交于 2019-12-20 09:46:34
问题 I am trying to execute a migration to rename some columns and I got an exception. As I read on the documentation I have to add the doctrine/dbal dependency to my composer.json file. How do I do that? Which is the correct composer.json file. I have many in my application. Is the one that is on the same level as the folders app,bootstrap, public and vendor. If so how do I add that dependency. Do I have to download anything? By the way im using easyphp, not wamp! Edit 1 After doing that the

Multiple Projects using single laravel instance

…衆ロ難τιáo~ 提交于 2019-12-20 09:37:36
问题 I am new to Laravel. As per my research on this framework I find it quite useful for my projects. However I am facing difficulty in customizing it to use a single instance of Laravel framework for multiple projects. I do not want to follow the multi site approach as available in Laravel i.e., using directory structure in models and controllers for projects because I won't be able to push my project related changes in a single step in Git. I want something like this. common Laravel framework

Input::file() returning null Laravel

删除回忆录丶 提交于 2019-12-20 08:49:22
问题 I've been writing an uploading script and even though I'm using the Laravel built in function Input::file() it still returns null. I am going to post my Home Controller code. public function handleUpload() { $user = Auth::user(); $username = $user->username; $userId = $user->id; $path_to_users = "users"; $user_profile_img = 'users/'.$username.$userId.'/'.$username.'image001.jpg'; $user_path_profile = "users/$username$userId"; $user_image_name = $username.'image001.jpg'; if(file_exists($path