laravel-5.2

Passing page URL parameter to controller in Laravel 5.2

喜欢而已 提交于 2020-01-01 15:03:21
问题 In my application I have a page it called index.blade , with route /index . In its URL, it has some get parameter like ?order and ?type . I want to pass these $_get parameter to my route controller action, query from DB and pass its result data to the index page. What should I do? 回答1: If you want to access the data sent from get or post request use public function store(Request $request) { $order = $request->input('order'); $type = $request->input('type'); return view('whatever')->with(

Laravel Validation If checkbox ticked then Input text is required?

邮差的信 提交于 2020-01-01 11:37:51
问题 I have been reading Laravel validation documentation. I am not clear how to combine two rules. For example: <input type="checkbox" name="has_login" value="1"> <input type="text" name="pin" value=""> If has_login checkbox is ticked then Input text pin value is required. If has_login is not ticked then Input text pin is not required. Laravel Validation: public function rules() { return [ 'has_login' => 'accepted', 'pin' => 'required', ]; } 回答1: Use required_with or required_if required_with:foo

Laravel Form validation with logic operators

最后都变了- 提交于 2020-01-01 10:48:15
问题 When a user fill Message (textarea) he/she can't fill Date,Time,Venue values. Those three fields will consider only when Message is empty and all those three fields are filled. How to do this using Laravel form validation? Is it possible to define these logic in Request's rule method? I am new for Laravel. Thanks in advance 回答1: You can achieve this (serverside) by using conditional validation rules: required_if:anotherfield,value,... required_unless:anotherfield,value,... required_with:foo

How to work with cookies in Laravel 5.2

て烟熏妆下的殇ゞ 提交于 2020-01-01 09:14:49
问题 I'm setting cookie on some click event. Then after storing value in cookie, I want to Check for existence of cookie Get cookie values I have developed a function by referring Laravel official docs. Console shows that cookies have been set. But after that, I can not solve two point (mentioned in above list) for view(Blade Template). It always shows (Cookie::get('cookie.clients')) 'null'. But browser console displays that cookie . If anyone knows answer, it will be appreciated. Here is my code.

Laravel - CNAME + Subdomain Routing

百般思念 提交于 2020-01-01 03:55:29
问题 I have my routes set up as follows: <?php Route::group([ 'domain' => '{username}.u.'.env('APP_DOMAIN'), ], function () { Route::get('/', 'FrontendController@site'); }); Route::group([ 'domain' => env('APP_DOMAIN'), ], function () { // Regular site routes }); Route::group([ 'domain' => '{domain}', ], function () { Route::get('/', 'FrontendController@domain'); }); What I'm trying to achieve is allowing users to have their own sites, e.g. hello.u.domain.com, and for those sites to also be served

laravel new command with older version

守給你的承諾、 提交于 2019-12-31 03:43:08
问题 When I try to create new Laravel project using below commands: laravel new --5.2 blog laravel new blog --5.2 Gives me following error: Crafting application... [GuzzleHttp\Exception\ClientException] Client error: `GET http://cabinet.laravel.com/latest-52.zip` resulted in a `404 Not Found` response: <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name="robots" content="noindex,nofollow (truncated...) new [--dev] [--5.2] [--] [<name>] I am running the command under XAMPP 5.6.28 >

Allow multiple subdomain in laravel without making subdomain as route variable?

左心房为你撑大大i 提交于 2019-12-30 14:51:08
问题 My subdomains are domain1 = dev1.myapp.com, domain2 = dev2.myapp.com, domain3 = dev3.myapp.com ... Using below code causing problem with first parameter in laravel controller, > Route::group(array('domain' => '{account}.myapp.com'), function() { > Route::get('/get_data/{id?}', 'DataController@getData'); > }) I am getting subdomain value( dev1 , dev2 , dev3 ) instead of $id value in controller in getData method. How to update my code to allow all subdomain, without making subdomain as first

Laravel 5 schedule job every 30 seconds

青春壹個敷衍的年華 提交于 2019-12-30 13:41:57
问题 I am using Laravel schedule to run cron jobs. In my crontab I have added (with correct path to my project): * * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1 Now my App\Console\Kernel.php looks like: protected function schedule(Schedule $schedule) { $schedule->command('investments:calculate_interests')->everyMinute(); $schedule->call('\App\Http\Controllers\UsersController@testEvent')->everyMinute(); } Using it like that I successfully run jobs every minute. But how I can change it

Laravel 5 schedule job every 30 seconds

て烟熏妆下的殇ゞ 提交于 2019-12-30 13:41:30
问题 I am using Laravel schedule to run cron jobs. In my crontab I have added (with correct path to my project): * * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1 Now my App\Console\Kernel.php looks like: protected function schedule(Schedule $schedule) { $schedule->command('investments:calculate_interests')->everyMinute(); $schedule->call('\App\Http\Controllers\UsersController@testEvent')->everyMinute(); } Using it like that I successfully run jobs every minute. But how I can change it

Laravel 5.2 Service provider not booting

强颜欢笑 提交于 2019-12-30 01:56:05
问题 I have a weird issue with a service provider. I have a ComposerServiceProvider with a dd("I'm loaded"); in the boot() function. Nothing is happening. I also have App\Providers\ComposerServiceProvider::class in config/app.php. I ran composer dump-autoload several times. Can anybody help? <?php namespace App\Providers; use Illuminate\Support\ServiceProvider; class ComposerServiceProvider extends ServiceProvider { /** * Bootstrap the application services. * * @return void */ public function boot