laravel-5.5

Laravel 5.5 validate with custom messages

余生颓废 提交于 2020-08-24 10:42:48
问题 I'm working on a pw change form in my laravel app. I want to use the validator with custom error messages. My code looks like this: $rules = [ 'username' => 'required|max:255', 'oldpassword' => 'required|max:255', 'newpassword' => 'required|min:6|max:255|alpha_num', 'newpasswordagain' => 'required|same:newpassword', ]; $messages = [ 'username.required' => Lang::get('userpasschange.usernamerequired'), 'username.max:255' => Lang::get('userpasschange.usernamemax255'), 'oldpassword.required' =>

How to mention the postgres schema in laravel request file

℡╲_俬逩灬. 提交于 2020-08-11 02:49:46
问题 I'm using Laravel 5.5 and I want to define a unique validation for a table column column_x located inside a Postgres schema schema_x , I've tried : public function rules() { return [ 'column_x' => 'required|unique:schema_x.table_x' ]; } But the following error keeps raising : SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "table_x" does not exist I can't find any information about this case in the official documentation ( Validation Section ). 来源: https://stackoverflow.com/questions

limit text using str_limit function in Laravel 5.5

﹥>﹥吖頭↗ 提交于 2020-08-07 20:00:36
问题 I have been trying to limit my blog content text with str_limit that works fine until I apply limit of characters on it. kindly see what is missing in the code of my blade file: {!! str_limit($blog->content) !!} works fine with the default limit, showing limited text on the view. But when I apply any custom limit i.e. {!! str_limit($blog->content, 20) !!} it do not show any text on the view. 回答1: The str_limit function has been deprecated, but you can use Str::limit($text) Laravel doc. In the

Validate UUID with Laravel Validation

人盡茶涼 提交于 2020-07-19 03:33:08
问题 Is there a built-in way to validate UUID with a validation rule? I did not found anything about this in the "Available Validation Rules" documentation. 回答1: You can extend the validator helper in Laravel to add your custom validation rules, for example I've created my own validation rule to validate location using regex as follow: Validator::extend('location', function ($attribute, $value, $parameters, $validator) { return preg_match('/^-?\d{1,2}\.\d{6,}\s*,\s*-?\d{1,2}\.\d{6,}$/', $value); }

Cannot find module “laravel-echo”

自作多情 提交于 2020-05-29 03:11:48
问题 I am learning to configure Laravel Echo Socket.js and following an article here Code in bootstrap.js is below import Echo from "laravel-echo" window.Echo = new Echo({ broadcaster: 'socket.io', host: window.location.hostname + ':6001' }); When I run the above code, it says, Cannot find module "laravel-echo" I am not using pusher and redis. In the above reference page, I think, there is no installation guidelines given for only socket.io Can somebody explain if I am missing anything? 回答1: I

Failed validation returns default error message even though custom messages supplied

百般思念 提交于 2020-05-10 03:24:09
问题 I'm not getting the response I expect. This is the controller code for a Location web-service request: <?php namespace App\Http\Controllers; use App\Location; use Illuminate\Http\Request; class LocationController extends Controller { /** * Action method to add a location with the supplied Data * * @param \Illuminate\Http\Request $p_oRequest Request * * @return JSON */ public function add(Request $p_oRequest) { try { $p_oRequest->validate( array( 'name' => 'required|alpha_num', 'user_id' =>

Json Assert Fails Laravel 5.5

痴心易碎 提交于 2020-04-17 22:12:32
问题 I am making a flash cards app with laravel 5.5 So I am trying to make the first tests but I can't make it pass. Failed asserting that an array has the subset Array &0 ( 'data' => Array &1 ( 'id' => 2020 ) ). --- Expected +++ Actual @@ @@ - [data] => Array - ( - [id] => 2020 - ) - /Users/marcosantana/devel/cards/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:290 /Users/marcosantana/devel/cards/tests/Unit/CardTest.php:26 FAILURES! Tests: 1, Assertions: 1, Failures: