samedi 1 juillet 2017

search for text within string in laravel or mysql

I use my SQL as backend for my project, and I need to get all record from database where some part of inputted string is available in database string like:

table = seller

id  company_name  seller_name
1   companyname1  seller1
2   companyname2  seller2
3   companyname3  seller3
4   companyname4  seller4

Given string is 1105 companyname1 is outstanding

So i need to get id = 1 for a given string if it is possible with laravel or MySQL then please help me.



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

Type error: Too few arguments to function laravel 5.4

Hi i'm having a html href where i want to pass values to a controller method but it displays Type error: Too few arguments to function

HTML

<li><a href="">
<i class="fa fa-chevron-right"></i> all</a></li>
<li><a href="">
<i class="fa fa-chevron-right"></i> paid</a></li>
<li><a href="">
<i class="fa fa-chevron-right"></i> free</a></li>

controller

` public function show($type,$title)
   {


    //
  }`



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

customize sweetalert2 outputting raw json

I want to display a sweetalert message if registration is successful or fail (I wrote the sweetalert code in a jquery file) and included it inside the registration view page but instead of displaying the sweetalert error or success message, it keeps displaying parsed json format message.

These are the files are created. custom_file.js

$(document).ready(function () {

    var form = $('#registration');

    form.submit(function (e) {
        e.preventDefault();

        $.ajax({
                url: form.attr('action'),
                type: "POST",
                data: form.serialize(),
                dataType: "json"
            })
            .done(function (response) {
                if (response.success) {
                    swal({
                        title: "Hi " + response.name,
                        text: response.success,
                        timer: 5000,
                        showConfirmButton: false,
                        type: "success"
                    });

                    window.location.replace(response.url);

                } else {
                    swal("Oops!", response.errors, 'error');
                }
            })
            .fail(function () {
                swal("Fail!", "Cannot register now!", 'error');
            });
    });

the registraion.blade.php file

@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row">
            <div class="col-md-8 col-md-offset-2">
                <div class="panel panel-default">
                    <div class="panel-heading">AJAX Register</div>
                    <div class="panel-body">
                        <form class="form-horizontal" id="registration" method="POST" action="" data-parsley-validate="">
                            {!! csrf_field() !!}

                            <div class="form-group">
                                <label class="col-md-4 control-label">Name</label>

                                <div class="col-md-6">
                                    <input type="text" class="form-control" name="name" id="name" required="">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-4 control-label">E-Mail Address</label>

                                <div class="col-md-6">
                                    <input type="email" class="form-control" name="email" id="email" required="">

                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-4 control-label">Password</label>

                                <div class="col-md-6">
                                    <input type="password" class="form-control" name="password" id="password" required="">

                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-4 control-label">Confirm Password</label>

                                <div class="col-md-6">
                                    <input type="password" class="form-control" name="password_confirmation" id="password_confirmation" data-parsley-equalto="#password" required="">
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-md-6 col-md-offset-4">
                                    <button type="submit" class="btn btn-primary ladda-button" data-style="expand-left" data-size="s" data-color="green">
                                        <i class="fa fa-btn fa-user"></i> Register
                                    </button>
                                    <a href="{!! asset('login/facebook') !!}"> <div class="btn btn-md btn-primary ladda-button" data-style="expand-left" data-size="s" data-color="blue"> <i class="fa fa-facebook"></i> Login with Facebook </div></a>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

and this is the RegisterController.php script

public function postRegister(Request $request)
    {

        $validator = Validator::make($request->all(), [
            'email' => 'required|email|unique:users,email',
            'name' => 'required|min:2',
            'password' => 'required|alphaNum|min:6|same:password_confirmation',
        ]);

        if ($validator->fails()) {
            $message = ['errors' => $validator->messages()->all()];
            $response = Response::json($message, 202);
        } else {

            // Create a new user

            $user = new User([
                'name' => $request->name,
                'email' => $request->email,
                'password' => $request->password,
                'facebook_id' => $request->email
            ]);
            $user->save();

            Auth::login($user);

            $message = ['success' => 'Thank you for joining us!', 'url' => '/', 'name' => $request->name];
            $response = Response::json($message, 200);
        }
        return $response;
    }

}



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

Rediection in laravel not working

I am new to Laravel and want to redirect to another view using button.On clicking button I want to redirect to particular route function ansd then to controller.But I am making some mistake.I did what they showed online but couldnt rectify.Following is my code.

Controller:

class MyController extends BaseController{


    function fromSub(){
        return view('from');
    }
}

Route: Route::get('from',array('uses'=>'MyController@fromSub' , 'as' => 'from'));

View:

<html>
    <body>
        <button type="button"  onclick="window.location=''">BUTTON</button>
    </body>
</html>

Thanks in advance.



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

what is the difference between an API and a package?

We need an API for a PHP project but the API(OMDB API) is not for free so we looked for an alternative and saw this package called imdbphp(http://ift.tt/1z1oFbr). Is this package enough to be an alternative to the API or they have different functions?

Thank you very much.



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

Class 'Illuminate\Support\facades\Schema' not found

I am working with Laravel5.4. When I use socialite package to login with Facebook, I need to add this line of code(Schema::defaultStringLength(191);) to boot function of AppServiceProvider class inorder to create default password for new user. Beside that I have to add using statement at top of AppServiceProvider class like this use Illuminate\Support\facades\Schema;

Everything is working well on my localhost but when I upload all code to my share hosting, I get this error: Class 'Illuminate\Support\facades\Schema' not found.

Can anyone help me on this. I am highly appreciated your help!



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

Laravel intelligent array matches

I have a lot of relation in my laravel project. I started to make a search. Now I have more multidimensional arrays,what I need to check in all array wich value is avaible?! So my arrays:

array:4 [▼
  "bytype" => array:2 [▼
    0 => array:6 [▼
      "id" => 1
      "price" => 500
      "discount_price" => null
      "created_at" => null
      "updated_at" => null
      "pivot" => array:2 [▶]
    ]
    1 => array:6 [▼
      "id" => 3
      "price" => 1400
      "discount_price" => null
      "created_at" => null
      "updated_at" => null
      "pivot" => array:2 [▶]
    ]
  ]
  "bymake" => array:2 [▼
    0 => array:6 [▼
      "id" => 1
      "price" => 500
      "discount_price" => null
      "created_at" => null
      "updated_at" => null
      "pivot" => array:2 [▶]
    ]
    1 => array:6 [▼
      "id" => 3
      "price" => 1400
      "discount_price" => null
      "created_at" => null
      "updated_at" => null
      "pivot" => array:2 [▶]
    ]
  ]
  "bymodel" => array:1 [▼
    0 => array:6 [▼
      "id" => 2
      "price" => 1500
      "discount_price" => null
      "created_at" => null
      "updated_at" => null
      "pivot" => array:2 [▶]
    ]
  ]
  "byattribute" => array:3 [▼
    0 => array:6 [▼
      "id" => 1
      "price" => 500
      "discount_price" => null
      "created_at" => null
      "updated_at" => null
      "pivot" => array:2 [▶]
    ]
    1 => array:6 [▼
      "id" => 2
      "price" => 1500
      "discount_price" => null
      "created_at" => null
      "updated_at" => null
      "pivot" => array:2 [▶]
    ]
    2 => array:6 [▼
      "id" => 3
      "price" => 1400
      "discount_price" => null
      "created_at" => null
      "updated_at" => null
      "pivot" => array:2 [▶]
    ]
  ]
]

So how can I do this to get that value(its means that array) wich one is avaible in all of that 4 main array?

to be like that:

  "listable" => array:2 [▼
    0 => array:6 [▼
      "id" => 1
      "price" => 500
      "discount_price" => null
      "created_at" => null
      "updated_at" => null
      "pivot" => array:2 [▶]
    ]
    1 => array:6 [▼
      "id" => 3
      "price" => 1400
      "discount_price" => null
      "created_at" => null
      "updated_at" => null
      "pivot" => array:2 [▶]
    ]
  ]



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