samedi 5 mars 2022

Laravel not validating array input

I'm trying to validate some input array fields in Laravel. My application reports back the field is required, even though it has been filled out.

The validation code I have is:

$this->validate($request, [
        'first_name'        => 'required',
        'last_name'         => 'required',
        'telephone'         => 'required',
        'email'             => 'unique:contacts,email,' . $request->id,
        'address'           => 'required',
        'address.0.address_line_1'         => 'required',
    ]);

The posted array is:

Array
(
[0] => Array
    (
        ['address_line_1'] => aa
        ['address_line_2'] => 
        ['city'] => 
        ['county'] => 
        ['postcode'] => 
        ['property_type'] => site
    )

)

I'm getting the validation message error:

The address.0.address line 1 field is required.

Anyone know what's wrong here?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/hFAU7lQ
via IFTTT

how can i store all details on login base

This is user profile when user click on refund button then store all data of user in another table how its possible?

this is my controller

 public function refundstore(Request $request)
{
    
   $user_id = Auth::user()->id
    $refund = new Refund(); 

$refund->user_id = $id;
$refund->refund_id = $refund->id; 

$refund->save();
    return view('front.user.profile', compact('user_id', 'refund'));
}

This is view

 <form action="" method="post">
              @csrf
            <button class="applyRefund mt-2">Apply For Refund</button>
           </form>

This is route

Route::post('refundstore', ['as' => 'refundstore', 'uses' => 'RefundController@refundstore']);


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/AlyRTFx
via IFTTT

jeudi 3 mars 2022

How to display single image in slider using loop in Laravel 5.7?

I am trying to display the single image in the slider, but whenever the user will click on this then it's open a popup in data-src="multiple-images-here" where I am running the slider. But the main issue is with the single image display in for loop. It displays all the available images in the loop. Please suggest me the best solution for this.

Here is my index.blade.php file where I am trying to display the slider using this code.

<div class="container-fluid margin-gallery d-lg-block d-block position-relative">
     <div class="row">
        <div class="col-lg-12 p-0">
           <div class="demo-gallery">
              @php
              if($propertys->propertyImage!=null){
              $images =  json_decode($propertys->propertyImage->image_path, true);
              }
              else{
              $images=null;
              }
              @endphp
              <?php
              $images_prop = collect($images['property_images']);
              ?>
              <ul id="lightgallery">
              @if($images['property_images']!=null)
                 @forelse($images_prop as $img)
                 <li class="sizing-li position-relative" data-src="">
                    <a href="javascript:void()">
                       <img class="img-responsive" src="" style="width:929px; height:495px;">
                    </a>
                 </li>
                 @empty
                 @endforelse
                 @endif
              </ul>
           </div>
        </div>
     </div>
  </div>

I want to display the first image from for loop here

<img class="img-responsive" src="" style="width:929px; height:495px;">


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/qTPCinc
via IFTTT

Laravel - validate input to be in the interval [-1, 10] without 0. not_in not working properly?

As the title says, I'm having trouble validating an input field like I said in the title.

I tried it this way:

$request->validate([
            'nota' => 'min:-1|not_in:0|max:10',
        ]);

Basically, I want this "nota" field to have values in the interval [-1, 10] without 0.

But I can still enter 0.

Why doesn't it work and how can I fix it?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/gPuvpnY
via IFTTT

How to create a record in the database base on email received to my site?

I have Laravel web application for my portfolio. https://www.bunlongheng.com

Under the portfolio section, you will see this

enter image description here

Right now, I have a CRUD for admin only to create them, but a thought come to my mind ...

I would like to create this automated email to just email myself to create a new record to the database.

Example

Anyone email to : portfolio@bunlongheng.com

Subject: Title of portfolio Body:

  1. Task 1
  2. Task 2
  3. Task 3

With attachments : 2 images (example)

Goal:

I want to accept and parse that email, and create a new portfolio record

  • Subject = Title
  • Body = Description
  • Attachments = Portfolio Images

enter image description here

How do I start ?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/CWVY8Ro
via IFTTT

How can I optimize or reduce the time complexity of the following code in Laravel 5.2.45?

In users table I have following data.

id   name    parent_id 
1     A           0
2     B           1
3     C           2
4     D           3
5     E           4
6     F           1

A have four level children. E is also children of A. E is the last, it has not any children. Now I can fetch all the children of any parent like the following code.

function getChildren($Id){
   $cache = [];
   $chList = [];
   $allUser = User::orderBy('parent_id', 'asc')
        ->orderBy('parent_id', 'asc')
        ->get();
   foreach($allUser as $user) {
    $cache [$user->parent_id][] = $user;        
   }
  $children0 = empty($cache [$Id]) ? [] : $cache [$Id];
  #first level child
  foreach($children0 as $child1) {

    $chList[$child1->id] = $child1;

    if(!empty($cache [$child1->id])) {

        #Second level child
        foreach($cache [$child1->id] as $child2) {

            $chList[$child2->id] = $child2;

            if(!empty($cache [$child2->id])) {

                #third level child
                foreach($cache [$child2->id] as $child3) {

                    $chList[$child3->id] = $child3;

                    if(!empty($cache [$child3->id])) {

                        #fourth level child
                        foreach($cache [$child3->id] as $child4) {
                            #can not be parent
                            $chList[$child4->id] = $child4;
                            
                        }
                    }
                }
            }
        }
    }
}

return $chList;
}

I can get the actual result by this code. But for huge data it is time consuming. Can any one help me to reduce time complexity or optimize the code?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/HbKDC1j
via IFTTT

mercredi 2 mars 2022

laravel fetching data how to aligned in single line

I'm new in laravel and html im able to get data from table using foreach. but i get data not aliened as I required help me.

my required alignment enter image description here now I'm getting alignment enter image description here

@foreach ($Subject_Of_Examination as $user)
                                       
   <td style=" text-align: center; position: absolute; " > <font size="3"><p>,</p></font></td>
                                       
@endforeach


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/1Xd5eSo
via IFTTT