laravel-5.2

Laravel Form validation with logic operators

萝らか妹 提交于 2019-12-04 08:28:19
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 You can achieve this (serverside) by using conditional validation rules: required_if:anotherfield,value,... required_unless:anotherfield,value,... required_with:foo,bar,... required_with_all:foo,bar,... required_without:foo,bar,... required_without_all:foo,bar,... I would

How to place vue variable inside a laravel bracket

余生颓废 提交于 2019-12-04 08:17:16
I am having problem displaying the vue variable output when using it together with laravel. Below is my code. <input type="text" class="form-control search-bar__input" placeholder="Search Courses, Interests, Schools or Institutions" autocomplete="on" autofocus="on" v-model="query" v-on:keyup="search"> <ul class="list-group"> <li class="list-group-item" v-for="course in courses"> <a href="{{ route('courses.show', '{{ course.id }}') }}">@{{ course.title }}</a> </li> </ul> In the above code I make used of @{{course.id}} inside the route in the a element. However it seems it is not working. Can

Laravel 5: PHPUnit and no code coverage driver available

♀尐吖头ヾ 提交于 2019-12-04 08:13:11
问题 I would like to use PHPUnit to create code coverage reports. I have tried a lot of installation setups found on the web. But nothing seems to work out. I use the latest version of Laravel 5 (>5.2) and PHPUnit v. 5.0.10. Further, I use MAMP on Mac OS X 10.9.5 running PHP 7. When I run PHPUnit that is integrated in my Laravel distribution, I receive the following error. $ vendor/bin/phpunit -v PHPUnit 5.0.10 by Sebastian Bergmann and contributors. Runtime: PHP 7.0.0 Configuration: /Applications

Laravel Access to XMLHttpRequest at from origin has been blocked by CORS policy

﹥>﹥吖頭↗ 提交于 2019-12-04 07:38:34
问题 When I Send a Call from Angular Application to Laravel I am getting the below issue Access to XMLHttpRequest at 'http://localhost:8083/api/login_otp' from origin 'http://localhost:4200' has been blocked by CORS policy: Request header field ip is not allowed by Access-Control-Allow-Headers in preflight response. i found a solution and did the below changes in CROS.php public function handle($request, Closure $next) { return $next($request) ->header('Access-Control-Allow-Origin', '*') ->header(

Laravel Validation - How to check if a value exists in a given array?

吃可爱长大的小学妹 提交于 2019-12-04 06:17:47
So, okay i tried a lot of rules from validation docs but all give me same error saying Array to string conversion Here is how I add the array: $this->validate($request,[ 'employee' => 'required|in:'.$employee->pluck('id')->toArray(), ],[ 'employee.in' => 'employee does not exists', ]); Any hint on how to achieve this? i created a custom validator but still passing array seems to be not possible Ohgodwhy Implode the array as a string and join it on commas. 'employee' => 'required|in:'.$employee->implode('id', ', '), This will make the correct comma separated string that the validator expects

Combine 5 tables in Laravel and sort by created_at

北慕城南 提交于 2019-12-04 06:03:00
问题 I'm making website for advertisements and people can publish things they are selling. So I have tables: cars , technology , real_estate , pets etc. All these tables have different columns except "created_at" column which is common for all tables. Example: CARS: [Model, Type, fuel type..., created_at] PETS: [Name, Description..., created_at] So if cars has 5 rows and pets has 7 and real_estate has 3 I need in return 15 rows sorted by created_at . I need to merge all 5 (or more) tables and sort

PHP Artisan Tinker not working with Laravel 5.5.16

时光总嘲笑我的痴心妄想 提交于 2019-12-04 05:19:34
问题 I run php artisan tinker but it didn't work it just show a message like this c:\xampp\htdocs\app_tpa>php artisan tinker [ErrorException] rmdir(C:\Users\KIMUNG~1\AppData\Local\Temp\php-xdg-runtime-dir-fallback-): Directory not empty I tried to run composer require laravel/tinker , but it doesn't fix my problem 回答1: This issue is now resolved as per these github issues: laravel/tinker#29 bobthecow/psysh#430 The proper solution now is to do composer update 来源: https://stackoverflow.com/questions

Request Errors not accessible in blade (Laravel 5.2)

蓝咒 提交于 2019-12-04 03:44:29
It had been many months since I'm using laravel but never faced such problem. I have made a simple Request class to validate the the update user request which works fine if validation rules are followed. If validation rule fails we should come back to the previous page and display all errors in html. According to me I have written everything correctly as I used to write in other applications but the $errors seems to be inaccessible in blade Following are my required code snippets to debug: routes.php Route::group(['middleware' => ['web']], function () { Route::get('/users/{id}/edit',

How to work with cookies in Laravel 5.2

[亡魂溺海] 提交于 2019-12-04 03:34:04
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. Controller use App\Client; use App\Http\Requests; use Illuminate\Http\Request; use Validator; use App

TokenMismatchException for API in Laravel 5.2.31

北慕城南 提交于 2019-12-04 03:28:32
问题 What Am I trying? I already have a website and I am trying Token based authentication for an API in same code and below is the start for sample authentication code I created a controller below is the code. class AccountController extends \App\Http\Controllers\Controller { public function apilogin($UserData) { return json_decode($UserData); } } My route config is below. Route::group(['prefix' => 'api/v1', 'middleware' => 'auth.api'], function () { Route::post('/apilogin', 'API\User\Account