vendredi 27 décembre 2019

uploading multple image in laravel and vue this code not work perfectly

  1. I tried so many time but it's not working correctly. when I upload 3 images but its only upload 2 images but when I upload 4 Image its only upload 2 images. How many images above 1 I upload it's only work for two images

    Laravel Code

    [I think laravel code does not work][1] $multipleImages=$request['sub_image']; for($i=1; $iresize(200,200); $public_path=public_path()."/sub-Image/"; $image->save($public_path.$name); }

    Vue JS Code :[its working correctly][2]  SubimageUpload(e) {
      for (let i= e.target.files.length-1; i>=0; i--) {
      var fileReader = new FileReader();
       fileReader.readAsDataURL(e.target.files[i]);
        fileReader.onload = e => {
        this.form.sub_image[i] = e.target.result;
      };
    
      }
      console.log(this.form);
      },
    

    [1]: https://i.stack.imgur.com/i8wGW.png [2]: https://i.stack.imgur.com/QCHHj.png



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

Access variable across methods Laravel PHP

Hey all actually I too facing the problem but I couldn't understand any of the above methods. Please help me to understand those stuffs and help t fix my problem.

I have two methods method1 and method2, where I receive some value in method 1 which needs to used in method 2. I created a variable on class level but I couldn't access the variable below is the code snippet.

class testController extends controller { 
        public $isChecked = false;
        public $isSelectedValue = 0;
public function ValidateValue(Request $req) {
        $isChecked = $req->checked;
        $isSelectedValue = $req->value;
     }
public function UsethoseValues() {
        if($isChecked) { // I can't use the variable here it throws run time error. I need help on this please help.
           }
     }
}


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

how to get laravel response the same page after login with ajax?

i have a login form to login a user i want to know about how to get laravel response in ajax success function. if submit the form i was got a object('status':'msg') in http://127.0.0.1:8000/login page. but i want to just redirect user correct page after login with macing alert. please help me to learn laravel with ajax function.

form

<form id="loginForm" method="POST" action="">
       @csrf
 <input id="email" type="email" class="form-control  name="email" value="" 
   required autocomplete="email" autofocus>

 <input id="password" type="password" class="form-control name="password" required 
    autocomplete="current-password">

 <button type="submit" class="btn btn-primary">LOGIN</button>
</form>

ajax: after document ready

$('#loginForm').submit(function(e){
    e.preventDefault();
    var formInput = $(this);
        $.ajax({
                type:'POST',
                url: 'login',
                data: formInput.serialize(),
                dataType: 'json',
                cache: false,
                success:function(status){
                    if(status== "success"){ 
                          alert("your in");
                       }
                        },
                        error:function(status){
                        if(status== "error"){ 
                          alert("no data found");
                       }
                        }
                    })
                });     

Route:

Route::post('login','loginController@login')->name('loginData'); 

Controller:

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Auth;
use Session;
class loginController extends Controller
{
    public function login(Request $request){
        $credentials = $request->only('email', 'password');
        if (Auth::attempt($credentials)) {
          //  print_r($request->all());

            session()->put('role', Auth::user()->Role);

            $request->session()->flash('message', 'New customer added successfully.');
            $request->session()->flash('message-type', 'success');
           return response()->json(['status'=>'success']);
           return back();

        }else{
            $request->session()->flash('message', 'you have entered an invalid email address or password. please try again');
            $request->session()->flash('message-type', 'danger');
            return response()->json(['status'=>'error']);
            return back();
        }

    }
}


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

How to show on heatmap(lat and long) above one lakh in vue js? Heatmap not showing all record. below my code

please see screen. lat-long not showing above one lac record on heatmap. https://i.stack.imgur.com/DvMS7.png



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

Trait method hasTooManyLoginAttempts has not been applied

I have upgraded my project from 5.2 to 5.3 in laravel. after that, I have the following error:-

Trait method hasTooManyLoginAttempts has not been applied, because there are collisions with other trait methods on App\Http\Controllers\Auth\AuthController in D:\xampp1\htdocs\clubmart_frontend\ app\Http\Controllers\Auth\AuthController.php on line 19

Following is the code of my AuthController:-

<?php

namespace App\Http\Controllers\Auth;

use App\Contracts\Repositories\UserRepositoryInterface;
use App\Http\Controllers\Controller;
use App\Models\User;
use App\Models\Voucher;
use App\Services\CartManager;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Validator;
use Illuminate\Http\Request;
use App\Events\UserWasRegistered;
use Event;
use Auth;

class AuthController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Registration & Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users, as well as the
    | authentication of existing users. By default, this controller uses
    | a simple trait to add these behaviors. Why don't you explore it?
    |
    */

    use AuthenticatesUsers, RegistersUsers {
        AuthenticatesUsers::redirectPath insteadof RegistersUsers;
        AuthenticatesUsers::guard insteadof RegistersUsers;
    }

    use ThrottlesLogins;

    public $guard = 'web';

    /**
     * Where to redirect users after login / registration.
     *
     * @var string
     */
    protected $redirectTo = '/';

    /** @var UserRepositoryInterface */
    protected $userRepository;

    /**
     * Create a new authentication controller instance.
     *
     * @param UserRepositoryInterface $userRepository
     */
    public function __construct(UserRepositoryInterface $userRepository)
    {
        $this->userRepository = $userRepository;
        $this->middleware($this->guestMiddleware(), ['except' => 'logout']);
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array $data
     *
     * @return Validator
     */
    protected function validator(array $data)
    {
        return Validator::make(
            $data,
            [
                'first_name' => 'required|max:255',
                'last_name'  => 'required|max:255',
                'email'      => 'required|email|max:255|unique:users',
                'password'   => 'required|min:6|confirmed',
            ]
        );
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array $data
     *
     * @return User
     */
    protected function create(array $data)
    {
        return $this->userRepository->create(
            [
                'name'       => $data['email'],
                'first_name' => $data['first_name'],
                'last_name'  => $data['last_name'],
                'email'      => $data['email'],
                'password'   => $data['password'],
            ]
        );
    }
    protected function authenticated(Request $request, User $user)
    {
        if($user = Auth::user()) {
            if(!empty(app(CartManager::class)->getItems())) {
                return redirect()->intended('/cart');
            }
            else {
                return redirect()->intended('/');
            }
        }
        else {
            return redirect()->intended('/');
        }
    }
    //overwrite for add flash message to session
    public function postRegister(Request $request, User $user)
    {

        $validator = $this->validator($request->all());
        if ($validator->fails()) {
            $this->throwValidationException(
                $request, $validator
            );
        }

        //login the newly created user
        \Auth::login($this->create($request->all()));

        //fire up the send user email event
        $user_id =  $user->find(\Auth::user()->id);
        Event::fire(new UserWasRegistered($user_id));

        $request->session()->flash('alert-success', 'Registration successful!');
        if(!empty(app(CartManager::class)->getItems())) {
            return redirect()->intended('/cart');
        }
        else {
            return redirect($this->redirectPath());
        }
    }

    /**
     * Log the user out of the application.
     * overwrite for clear user from session
     * @return \Illuminate\Http\Response
     */
    public function logout(Request $request)
    {
        if($request->session()->has('user_id'))
            $request->session()->forget('user_id');

        \Auth::guard($this->getGuard())->logout();

        return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
    }


}

This is the code of Controller.php:-

<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
// use Illuminate\Foundation\Auth\Access\AuthorizesResources;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

Any help will be appreciated. thanks in advance.



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

Undefined index: COMMENTS

Basically i want to get column listings and types I’m using $this->getConnection()->getSchemaBuilder()->getColumnListing(‘table’); To get column listing and it’s working without any problem, however when i tried to get column type using

$this->getConnection()->getSchemaBuilder()->getColumnType(‘table’,’column’);

It didn’t work at first, then i installed dbal package now i am getting this error

Undefined index: COMMENTS Vendor\doctrine\dbal\lib\Doctrine\DBAL\Schema\OracleSchemaManager.php:402

I have no clue what’s wrong, comments is not anything in my db!!!



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

DatePicker for Laravel 5.8

I am looking for a recommendation on your datepicker for Laravel 5.8. Currently I am using a pure css datepicker which is ugly. I am having a hard time integrating datepickers for my project because it always indicate

datepicker is not defined

I tried installing this via NPM

https://www.npmjs.com/package/js-datepicker

and implemented this in my js file but I still get the undefined error:

    datepicker(document.querySelector('#date_search'));


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