laravel-5.4

How to validate array in Laravel?

て烟熏妆下的殇ゞ 提交于 2019-12-17 04:47:16
问题 I try to validate array POST in Laravel: $validator = Validator::make($request->all(), [ "name.*" => 'required|distinct|min:3', "amount.*" => 'required|integer|min:1', "description.*" => "required|string" ]); I send empty POST and get this if ($validator->fails()) {} as False . It means that validation is true, but it is not. How to validate array in Laravel? When I submit form with input name="name[]" 回答1: Asterisk symbol (*) means that you want to check VALUES in the array, not the actual

Migrate only once with Laravel dusk

偶尔善良 提交于 2019-12-14 03:45:18
问题 According to the "Database Testing" documentation I can reset the database after each test (first option). Second option is to run test using Transactions. It seems a better approach to me, but if I want to run with transaction, the migration does not run. Is there any way to run the migration once for all the test process? In other words, I want to run the migration, run every tests with transaction, then rollback. I tried with what the documentation says, but I think something is missing.

Laravel File Storage Error

大憨熊 提交于 2019-12-14 03:22:10
问题 I am developing a Laravel 5.4 app and deployed it to Heroku running on free dyno.I am using Google Drive as my cloud storage.I am trying to upload large file,size of 200-300 mb or small file of 10-12 kb to my cloud storage using nao-pon/flysystem . While uploading file,I am getting this error: (1/1) ErrorException A non well formed numeric value encountered in GoogleDriveAdapter.php (line 1143) at HandleExceptions->handleError(8, 'A non well formed numeric value encountered', '/app/vendor/nao

Laravel “Wrong password” error message

浪子不回头ぞ 提交于 2019-12-13 12:16:20
问题 I'm creating a login function in Laravel 5.4 and I want to show error message in the view when the password is incorrect. Also I have a custom message for account approval so it makes things a bit difficult for me. Meanwhile I put those messages together but is not very user-friendly. How can I separate them? This is my controller: public function login(Request $request) { // validate the form data $this->validate($request, [ 'email' => 'required|email|exists:users,email', 'password' =>

Laravel 5.4 Credit, Debit and Balance Calculation

社会主义新天地 提交于 2019-12-13 09:26:14
问题 Now I am doing Invoice Application using Laravel Framework 5.4. I Save Credit and Debit Amount in Transaction Table. I want to Display Credit amount, Debit amount, Balance Amount in Blade Template (same as like below) 回答1: In your Controller : $transaction = DB::table('transaction')->get(); In your Blade : <?php $tbalance=0; ?> @foreach($transaction as $trans) <tr> <td>{{$invaccstatements->ref_no}} </td> <td>{{number_format($invaccstatements->credit, 2)}}</td> <td>{{number_format(

I have a form and i want to add all the is not equal to zero

╄→尐↘猪︶ㄣ 提交于 2019-12-13 09:13:10
问题 This is my desired output. I want the date will be equals to 1 and add in the total input and in class there's an additional x. <div class="form-group{{ $errors->has('day1') ? ' has-error' : '' }}"> <label for="day1" class="col-md-4 control-label">Day 1</label> <div class="col-md-6"> <div class='input-group date' id='day1'> <input type='text' class="form-control" name="day1" value="0" readonly="readonly" /> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"> </span> <

How to convert mysql to laravel query builder [closed]

偶尔善良 提交于 2019-12-13 08:26:45
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . Hi all i have this raw query in mysql i need to translate to laravel 5.4 query builder select * from pages where (phase_id, type) in (select max(phase_id),type from pages where phase_id<=2 and actived=1 group by type) and actived=1 i don't know how to convert in query builder

Not work id getter in model (i use uuid type)

倖福魔咒の 提交于 2019-12-13 07:37:53
问题 I make the primary key as uuid in Model. Migration with uuid primary key: Schema::create('brands', function (Blueprint $table) { $table->uuid('id')->unique()->primary(); $table->string('title'); $table->timestampsTz(); }); Checking model: Psy Shell >>> $x = App\Models\Brand::find('e025b8aa-c71e-42ca-b87c-7ee27695b83a'); => App\Models\Brand {#720 id: "e025b8aa-c71e-42ca-b87c-7ee27695b83a", title: "Batman", created_at: "2017-04-28 23:51:41+10", updated_at: "2017-04-28 23:51:41+10", } When

Query exception laravel 5.4

﹥>﹥吖頭↗ 提交于 2019-12-13 03:34:26
问题 When i will do a login sometimes on my laravel application i face this error: Someone knows what could be this? PS: this not happen all times; I'm using xampp on a x64 machine with windows 10 home, with a core i5 processor, and 8 GB of RAM. Also using a virtual server to run on development mode. 回答1: The error actually does not come from MySQL, but from Windows itself: When a connection is closed, on the side that is closing the connection, the tuple {Protocol, Local IP, Local Port, Remote IP

How to select BLOB files in PHP using Laravel

℡╲_俬逩灬. 提交于 2019-12-13 03:01:30
问题 I have 50 images stored in SQL Database (BLOB). How can i select it and show it as an image in a view. I have tried something like this Route::get('/', function () { $pics = DB::table('Employees')->get(); return $pics; //just to test if i get something return from the db //return view('welcome', compact("pics")); }); When i return the db query i get a very long string for an image. FFD8FFE1001845786966000049492A00080000000000000000000000FFEC00114475636B7900010004000000500000FFE1031D687.... I