LARAVEL VALIDATION FUNCTIONALITY

CUSTOM LARAVEL VALIDATION : 

  $validator = Validator::make($request->all(), [

            'profile_photo'=>'image|mimes:jpeg,jpg,png,gif|required|max:10000',
            'licence_front'=>'image|mimes:jpeg,jpg,png,gif|required|max:10000',
            'license_back'=>'image|mimes:jpeg,jpg,png,gif|required|max:10000',
            'driving_licence_validity_date'=>'required|date_format:Y-m-d',
            'insurance_validity_date'=>'required|date_format:Y-m-d',
            'photo_car_back'=>'image|mimes:jpeg,jpg,png,gif|required|max:10000',
            'photo_car_front'=>'image|mimes:jpeg,jpg,png,gif|required|max:10000',
            'insurance_front'=>'image|mimes:jpeg,jpg,png,gif|required|max:10000',
            'insurance_back'=>'image|mimes:jpeg,jpg,png,gif|required|max:10000',
            'car_registration_front'=>'image|mimes:jpeg,jpg,png,gif|required|max:10000',
            'car_registration_back'=>'image|mimes:jpeg,jpg,png,gif|required|max:10000',

        ],[
            'photo_car_back.max' => 'The car back image size is greater than 10 MB. Maximum size upload is 10 MB.',
            'photo_car_front.max' => 'The car front image size is greater than 10 MB. Maximum size upload is 10 MB.',
            'insurance_front.max' => 'The car insurance front image size is greater than 10 MB. Maximum size upload is 10 MB.',
            'insurance_back.max' => 'The car insurance back image size is greater than 10 MB. Maximum size upload is 10 MB.',
            'car_registration_front.max' => 'The car registration front image size is greater than 10 MB. Maximum size upload is 10 MB.',
            'car_registration_back.max' => 'The car registration back image size is greater than 10 MB. Maximum size upload is 10 MB.',
            'profile_photo.max' => 'The profile image size is greater than 10 MB. Maximum size upload is 10 MB.',
            'licence_front.max' => 'The licence front image size is greater than 10 MB. Maximum size upload is 10 MB.',
            'license_back.max' => 'The licence back image size is greater than 10 MB. Maximum size upload is 10 MB.',

            // 'type.required' => 'You have to choose type of the file!'
        ]);

        if ($validator->fails()) {
            return response()->json(['success' =>false,'message'=>$validator->errors()->first()], 200);
        }





NEW MESSAGES:
Messages:
Profile updated successfully.
Profile picture updated successfully.
The car registration front image size is greater than 10 MB. Maximum size upload is 10 MB.
Profile activated successfully.
Currently, You don't have any ride request.
This ride is already allocated by other driver.
You currently have an ongoing ride and cannot accept a new ride at this time. Please complete your current ride before accepting any new requests.
Ride accept successfully.
Your code verified successfully.
Your verify code is wrong.
Already canceled by rider.
Ride canceled.
Toll added successfully.
The record cannot be deleted. Ensure that the ongoing ride has been completed or canceled.
The record cannot be deleted. It's already verified, let's complete the ride.
Deleted Successfully.
Stoppage time saved successfully.
Waiting time saved successfully
Profile inactivated successfully.
Commissions not get.
Booking data not get.
Ride completed successfully.
Location Save successfully.
Booking car reached pickup location.
Your ride vehicle has reached the pickup location.


LARAVEL URL METHOD CALL TO SEND WITH SEARCH FIELD



<a href="{{ URL::to('admin') }}/projects?name=&status=6"  class="small-box text-info">
                <div class="inner">
                    <h3>{{$advertised_project}}</h3>
                    <p> Advertised Projects</p>
                </div>
                <div class="icon">
                <i class="nav-icon fa fa-file-alt" aria-hidden="true"></i>
                </div>
            </a>


SELECT BOX WITH TEXT SUGGESTIONS

IN REACT JS:
    <Row className="mb-3">
                                    <Form.Group md={12} controlId="formGridEmail">
                                        <Form.Control className='f-inp' type="text" placeholder="select sub category" name='subcategory' list="subcategorylist"/>
                                        <datalist id="subcategorylist">
                                        {
                                                    subcategoryList.map(subcat =>
                                                        <option key={subcat._id} value={subcat.name}>{subcat.name}</option>
                                                    )
                                                }
                                                </datalist>
                                    </Form.Group>
                                </Row>


IN HTML:
<div class="text-container">
            <input type="text" list="programmingLanguages" 
                        placeholder="Enter Here" />
            <datalist id="programmingLanguages">
                <option value="Objective C">Objective C</option>
                <option value="C++">C++</option>
                <option value="C#">C#</option>
                <option value="Cobol">Cobol</option>
                <option value="Go">Go</option>
                <option value="Java">Java</option>
                <option value="JavaScript">JavaScript</option>
                <option value="Python">Python</option>
                <option value="PHP">PHP</option>
                <option value="Pascal">Pascal</option>
                <option value="Perl">Perl</option>
                <option value="R">R</option>
                <option value="Swift">Swift</option>
            </datalist>
        </div>



Using Closure 
Using  Http::asForm()->post
Error: The use statement with non-compound name 'Closure' has no effect
Solution: Remove use Closure from web.php route files.

Error: Argument 2 passed to ... {closure}() must be an instance of App\Http\Controllers\mixed, string given
Solution: Write function like this, function ($attribute, $value,  $fail)

"g-recaptcha-response"=> ["required",  function ($attribute, $value,  $fail) {
                        $g_response = Http::asForm()->post("https://www.google.com/recaptcha/api/siteverify", [
                            'secret' => config('services.recaptcha.secret_key'),
                            'response' => $value,
                            'remoteip' => \request()->ip()
                        ]);
                       
                        if (! $g_response->json('success')) {
                            $fail("The {$attribute} is invalid.");
                        }
                    },
                ],



LARAVEL URL FULL AND IF ANY EXTRA URL DATA COMES, THEN REDIRECT 


 $currenturl = url()->full();
        $currenturl = explode('/',$currenturl );
        // if(count($currenturl)>7) //local
        if(count($currenturl)>5) //server
        {
            return redirect('/');
        }

it's now not working.. 
so changes , 

 public function luxaflex($dep_link = 'main', $page = null)
    {
        if(isset($page)){
            $position = strpos($page, 'page-');
            $le = strlen($page);
            if(!str_contains($page,'page-') || !is_numeric($page[$le-1])){
                return redirect('/');
            }
        }
... function code

web.php
Route::get('{dep_link}/luxaflex/{page}',  [HomeController::class, 'luxaflex'])->name('luxaflex_page');
Route::any('{dep_link}/luxaflex/{page}/{any}', function() { return redirect('/'); })->where('any', '.*');

for any redirect to home, otherwise, if not ends with numeric then returns home page.








Comments

Popular posts from this blog

[[ ROYAL CAR ]] CHANGE PASSWORD - DYNAMIC BANNER - MULTIPLE IMAGE - LOGIN LOGOUT BACK BUTTON MIDDLEWARE STOP - MAIL DIRECTLY WITH FEEDBACK WITH SAVE IN SQL DB - ADMIN REPLY EXISTING MAILS - DYNAMICALLY CSS CHANGE

Sahari

Linux Terminal