方法App \ Http \ Controllers \ ConfigSplitCleansingController :: show不存在

时间:2019-12-17 10:32:34

标签: javascript laravel

我收到此错误,但似乎找不到该错误。

这是我控制器中的功能。

class ConfigSplitCleansingController extends Controller
{
public function storeNewArea(Request $request)
            {

              $setArea = $request->setNewArea;

              $decode = json_decode($setArea, true);
              $activity = Activities::where('activityCode', $request->activityId)->first();

              $lastrow = PubCleansingScheduleStreet::join('pubcleansingschedule_activity','pubcleansingschedule_street.pubCleansingActivityId', '=', 'pubcleansingschedule_activity.id')
              ->select('pubcleansingschedule_street.rowOrder')
              ->where('pubcleansingschedule_activity.pubCleansingScheduleParkId',$request->scheduleparkId)
              ->where('pubcleansingschedule_activity.activityId',$activity->id)
              ->orderBy('pubcleansingschedule_street.rowOrder','desc')
              ->limit(1)->first();

              $row = $lastrow->rowOrder;

              foreach ($decode as $key => $value) {
                $row = $row + 1;
                if($value['id'] == 0){
                  $schedulestreet = PubCleansingScheduleStreet::find($request->schedulestreetId);

                  $newsplit = new CleansingSplit;
                  $newsplit->pubCleansingId =$schedulestreet->pubCleansingId;
                  $newsplit->streetId =$schedulestreet->streetId;
                  $newsplit->activityCode =$schedulestreet->activityCode;
                  $newsplit->serviceType =$schedulestreet->serviceType;
                  $newsplit->value =$value['value'];
                  $newsplit->frequency =$schedulestreet->frequency;
                  $newsplit->save();


                  $newstreet->pubCleansingActivityId =$schedulestreet->pubCleansingActivityId;
                  $newstreet->pubCleansingId =$schedulestreet->pubCleansingId;
                  $newstreet->streetId =$schedulestreet->streetId;
                  $newstreet->streetName =$schedulestreet->streetName;
                  $newstreet->streetType =$schedulestreet->streetType ;
                  $newstreet->activityCode =$schedulestreet->activityCode;
                  $newstreet->serviceType =$schedulestreet->serviceType;
                  $newstreet->value =$value['value'];
                  $newstreet->frequency =$schedulestreet->frequency;
                  $newstreet->frequency_PJ =$schedulestreet->frequency_PJ;
                  $newstreet->rowOrder =$row;
                  $newstreet->save();
                }
                else {

                  $newstreet = CleansingSplit::find($value['id']);
                  $newstreet->value = $value['value'];
                  $newstreet->save();

                  }

              }

              return response()->json($newstreet);

            }
}

这是我的模特

<?php

namespace App\Models;


use Illuminate\Database\Eloquent\Model;

class CleansingSplit extends Model
{
    //
    protected $table = 'publiccleansingsplit';
   protected $fillable = [
       'id',
       'pubCleansingId',
       'streetId',
       'activityCode',
       'serviceType',
       'value',
       'frequency'
   ];


}

路线

Route::post('splitpembersihan/storeNewArea', ['as' => 'storeNewArea', 'uses' => 'ConfigSplitCleansingController@storeNewArea']);

这是ajax

$.ajax(
              {

                url: '{{url("splitpembersihan/storeNewArea")}}',
                type: 'post',
                data: {
                  "setNewArea": setarray,
                  "scheduleparkId": scheduleparkId,
                  "schedulestreetId": schedulestreetId,
                  "splitId": splitId,
                  "activityId" : @if(isset($schedulestreet->activityCode))"{{ $schedulestreet->activityCode}}"@endif,
                  "_token": token
                },
                success: function (data)
                {
                  alert("success");

                  window.location.replace('/splitpembersihan/splitBin/'+ PubCleansingID +'/splitValueArea');
                },

                error: function (data)
                {

                  alert("error");


                }
              });

错误正好相反。数据存储成功。但是,它显示错误警报而不是成功警报。而且,如果我只按了提交按钮却没有提交任何东西,它会显示成功警报。

0 个答案:

没有答案