laravel

@error directive is not displaying errors in laravel view

亡梦爱人 提交于 2021-02-05 09:28:20
问题 I'm working on custom Laravel login implementation. I have returned the error from controller as follows: $credentials = $request->only('email', 'password'); if (Auth::attempt($credentials)) { // Authentication passed... return redirect()->intended('surveys'); }else { return redirect()->back()->withErrors(['email', 'The Message']); } Here is my view implementation to extract this error: <div class="col-md-6"> <input id="email" type="email" class="form-control @error('email') is-invalid

@error directive is not displaying errors in laravel view

此生再无相见时 提交于 2021-02-05 09:27:07
问题 I'm working on custom Laravel login implementation. I have returned the error from controller as follows: $credentials = $request->only('email', 'password'); if (Auth::attempt($credentials)) { // Authentication passed... return redirect()->intended('surveys'); }else { return redirect()->back()->withErrors(['email', 'The Message']); } Here is my view implementation to extract this error: <div class="col-md-6"> <input id="email" type="email" class="form-control @error('email') is-invalid

Looping through collections -Laravel

耗尽温柔 提交于 2021-02-05 08:58:26
问题 I was trying to loop through a collection based on the key What I am trying to accomplish here is to group each company based on the alphabet in my view. How do I loop through this?? $results = $companies->sortBy('name')->groupBy(function ($item, $key) { return substr($item['name'], 0, 1); }); dump($results); Controller 回答1: As an alternative to @msonowal's answer you can also use each(): $results->each(function ($collection, $alphabet) { dump($alphabet, $collection); }); However, if you're

Looping through collections -Laravel

旧时模样 提交于 2021-02-05 08:58:06
问题 I was trying to loop through a collection based on the key What I am trying to accomplish here is to group each company based on the alphabet in my view. How do I loop through this?? $results = $companies->sortBy('name')->groupBy(function ($item, $key) { return substr($item['name'], 0, 1); }); dump($results); Controller 回答1: As an alternative to @msonowal's answer you can also use each(): $results->each(function ($collection, $alphabet) { dump($alphabet, $collection); }); However, if you're

Problem with displaying pictures in laravel 7

你。 提交于 2021-02-05 08:36:27
问题 i'm working on Laravel 7 , i want to display the images added by the administrator, but they don't show up. This is the index.blade.php : @foreach ($posts as $post) <div class="col-3"> <div class="product__item"> <div class="product__item__pic set-bg" data-setbg="{{asset('product/September2020/'.$post->Photo)}}"> </div> </div> </div> @endforeach This is the adress of the pictures : C:\wamp64\www\Projectclient\storage\app\public\product\September2020 Thanks fo help 回答1: First create a symbolic

I'm getting request too large Error 413 when submiting file in laravel

丶灬走出姿态 提交于 2021-02-05 08:10:42
问题 I'm using laravel and filepond to upload some files. It works fine with files smaller than 100MB, but if I try to upload bigger (400MB) files I get 413 error. I have already increased post_max_size and upload_max_filesize in php.ini and changed client_max_body_size in nginx, but it still does not work. I'm missing something? Best regards 回答1: Its php and nginx related. Check which php.ini is used php --ini Sometimes there are multiple ones that change the original value Search in all php.ini

How Laravel handles PHP warnings?

跟風遠走 提交于 2021-02-05 08:08:47
问题 I'm trying to connect to a LDAP server using Laravel. It is important to say that I'm using the PHP functions ldap_connect and ldap_bind instead of using a package to handle it. The point is that when I provide wrong user and password, the ldap_bind function gives to us a PHP warning. I'm OK with this warning and, as is in the documentation, the function returns false when the bind does not occur. But, Laravel is throwing an exception when this warning is triggered. This is not an exception,

How Laravel handles PHP warnings?

我的梦境 提交于 2021-02-05 08:07:14
问题 I'm trying to connect to a LDAP server using Laravel. It is important to say that I'm using the PHP functions ldap_connect and ldap_bind instead of using a package to handle it. The point is that when I provide wrong user and password, the ldap_bind function gives to us a PHP warning. I'm OK with this warning and, as is in the documentation, the function returns false when the bind does not occur. But, Laravel is throwing an exception when this warning is triggered. This is not an exception,

What are the benefits of using migrations and model classes in Laravel?

一个人想着一个人 提交于 2021-02-05 07:56:13
问题 Migrate (php artisan migrate) I am using laravel for my app. I read laravel doc in which they say "If you have ever had to tell a teammate to manually add a column to their local database schema, you've faced the problem that database migrations solve." But i am working with my 2 team member and we use a live db server. Everything i changes goes to live db and all find that. If i use live db, should i use db migtration as DOC says it is useful for local db? Model Class I used model class only

Laravel encrypt cannot encrypt to database when using Update method

谁说胖子不能爱 提交于 2021-02-05 07:52:09
问题 Hi i want to encrypt some field in database when user create or edit data. IF create, the encryption work, but when user edit data, the value that save in database will be normal text not encrypted <?php namespace App\Traits; use Crypt; trait Encryptable { public function toArray() { $array = parent::toArray(); foreach ($array as $key => $attribute) { if (in_array($key, $this->encryptable) && $array[$key]!='') { try { $array[$key] = Crypt::decrypt($array[$key]); } catch (\Exception $e) { } }