lundi 21 août 2017

laravel Ajax success function not working

I send a store request to my laravel application through AJAX. The controller function works properly, but either I cannot get a success message in my ajax function, or the function on success is not working.

Ajax code:

    type: "POST",
    url: '',
    data: {
        description: description,
        offset_top: offset_top,
        offset_left : offset_left
    success: function(msg){

Controller's store function:

public function store(Request $request)
    echo $request;
    if (Auth::check()) {
        $user = Auth::user();
        $dream = new Dream($request->all());
        if ($dream) {
            $response = array(
              'dream' => $dream,
              'status' => 'success',
              'msg' => 'Setting created successfully',
            return \Response::json($response);
        return \Response::json(['msg' => 'No model']);
    } else {
      return \Response::json('msg' => 'no auth');

from Newest questions tagged laravel-5 - Stack Overflow

Custom column not getting updated

I'm facing the issue with my custom column form_id into users table.

I'm trying to update using save() but it didn't update it.

I'm begginer for laravel and need your help.

Any help would be appreciated. Thanks

from Newest questions tagged laravel-5 - Stack Overflow

WhereBetween function in not working properly Laravel 5.0

$dt = \Carbon::now();
$tomorrow = Carbon::tomorrow();
$yesterday = Carbon::yesterday();
$data = $this->model->select('id', 'description')
 ->whereBetween($dt, array($yesterday, $tomorrow))->get();

It is returning an error saying "An error occurred in database operation."

from Newest questions tagged laravel-5 - Stack Overflow

how can i deploy project from bitbucket to multiple domain?

I have a billing web application & that application is used form different domain by different client. in my local server i am regularly upgrading feature of that web application. then after upgrading one feature i have to login each domain's cpanel or ftp then update particular code that i have changed. this is very much embarrassing for me to update all different domain. is there any easiest way to do that from bitbucket or any version control? or any other easiest way? Thanks is advance.

from Newest questions tagged laravel-5 - Stack Overflow

Method validate does not exist - Laravel 5.4

I have a very weird problem. When I'm submitting the form, it throws an error with server-side validation.

Here is my simple controller:

namespace App\Http\Controllers;

use Newsletter;
use Illuminate\Http\Request;

class SubscriptionController extends Controller
    public function subscribe(Request $request)
            'email' => 'required|email',

Submitting the form gives me:

BadMethodCallException Method validate does not exist.

it should work according to:

from Newest questions tagged laravel-5 - Stack Overflow

creating default object from empty value in laravel 5

I'm trying to make two functions in controller that have post action and that are in the same page. My Controller

public function store(Request $request)

    $status = DB::table('analytics')->where('dienstleistung', '!=', '')->get();
    //Save data
        $rules = [          
        'site_id'       => 'required',
        'dienstleistung'        => 'required',
        'objekt'        => 'required',
        'zimmer'        => 'required',
        'vorname'       => 'required',
        'name'      => 'required',
        'strasse'       => 'required',
        'ort'       => 'required',
        'plz'       => 'required',
        'tel'       => 'required',
        'email'     => 'required|email',
        'reinigungstermin'      => 'required',
        'gekommen'      => 'required',
        'message'       => 'required',
        'status'        => 'required',
        'answer'        => 'required',
        'notiz'         => 'required',
        'userId'        => 'required',

                $validator = Validator::make(Input::all(), $rules);

                if($validator->fails()) {
                    return Redirect::to('anfrage')
                else {
                    $anfrage = new Analytic();                      
                    $anfrage->site_id = Input::get('site_id');
                    $anfrage->dienstleistung = Input::get('dienstleistung');
                    $anfrage->objekt = Input::get('objekt');
                    $anfrage->zimmer = Input::get('zimmer');
                    $anfrage->vorname = Input::get('vorname');
                    $anfrage->name = Input::get('name');
                    $anfrage->strasse = Input::get('strasse');
                    $anfrage->ort = Input::get('ort');
                    $anfrage->plz = Input::get('plz');
                    $anfrage->tel = Input::get('tel');
                    $anfrage->email = Input::get('email');
                    $anfrage->reinigungstermin = Input::get('reinigungstermin');
                    $anfrage->gekommen = Input::get('gekommen');
                    $anfrage->message = Input::get('message');
                    $anfrage->status = Input::get('status');
                    $anfrage->answer = Input::get('answer');
                    $anfrage->notiz = Input::get('notiz');
                    $anfrage->userId = Input::get('userId');
                    try {

                        return Redirect::to('anfrage');

                    } catch (\Exception $e) {
                        return Redirect::to('anfrage')


 public function editItem(Request $request) {
    $anfrages = Analytic::find($request['id']  );

        $anfrages->status = $request->status;
    $anfrages->answer = $request->answer;
    $anfrages->notiz = $request->notiz;
    return response ()->json( $anfrages );

My route:

Route::post('anfrage', 'AnfrageController@store');
Route::post ( 'anfrage', 'AnfrageController@editItem' );

EditItem function is OK, it makes changes when I want to edit data, but when I want to store data, message being displayed is:
creating default object from empty value

So, I need to leave active only one of these function, both are not working.

from Newest questions tagged laravel-5 - Stack Overflow

route issue when I host my laravel 5 website on a Shared hosting

hello everyone I'm new on laravel. I build my website which is perfectly working on the development machine but when I put it on my shared hosting it is just one route which is working ("/"). all the order routes are not working.

web.php (the first route is working)


Route::get('/', function () {
return view('index');}); 

Route::group(['prefix' => '{lang}'], function(){
Route::get('index', function(){
    return view('index');

Route::get('t', function(){
    return view('construction');

Route::get('post', function(){
    return view('post');

Route::get('posts', 'postController@index');

index.blade.php is in the folder views of ressources and the lang files exist. if anyone can help me it will be great

from Newest questions tagged laravel-5 - Stack Overflow