vendredi 2 décembre 2016

Laravel Insert Query

I am not able to insert a record to my table 'properties' through Laravel Eloquent. Pls help codes are given below

Controller Code:
-----------------

    public function store(Request $request)
    {

      $this->validate($request, [
        'name' => 'required|max:35',
        'address' => 'required|max:120',
        'area' => 'required|max:20',
        'city' => 'required|max:20',
        'pin' => 'required|max:6',
        's_id' => 'required',
        'c_id' => 'required',
        'rooms' => 'required|numeric',
        'telno' => 'required',
        'mobile1' => 'required',
        'mobile2' => 'required',
        'email1' => 'required|email',
        'email2' => 'required|email',
        'email3' => 'required|email',
        'website' => 'required',
      ]);

      $record = new Properties;
      $record->name = $request->name;
      $record->pt_id = $request->type;
      $record->rating = $request->rating;
      $record->address = $request->address;
      $record->area = $request->area;
      $record->city = $request->city;
      $record->pin = $request->pin;
      $record->s_id = $request->s_id;
      $record->c_id = $request->c_id;
      $record->rooms = $request->rooms;
      $record->telno = $request->telno;
      $record->mobile1 = $request->mobile1;
      $record->mobile2 = $request->mobile2;
      $record->email1 = $request->email1;
      $record->email2 = $request->email2;
      $record->email3 = $request->email3;
      $record->website = $request->website;
      $record->checkin = $request->checkin;
      $record->checkout = $request->checkout;
      $record->children = $request->children;
      $record->pets = $request->pets;
      $record->pickup = $request->pickup;
      $record->drop = $request->drop;
      $record->internet = $request->internet;
      $record->parking = $request->parking;
      $record->breakfast = $request->breakfast;
      $record->bk_id = $request->bk_id;
      $record->acno = $request->acno;
      $record->acname = $request->acname;
      $record->acbranch = $request->acbranch;
      $record->acifs = $request->acifs;
      $record->acswift = $request->acswift;
      $record->lat = $request->lat;
      $record->lng = $request->lng;
      $record->panno = $request->panno;
      $record->vatno = $request->vatno;
      $record->stno = $request->stno;
      $record->ltno = $request->ltno;
      $record->activities = isset($request->act) ? implode(',', $request->act) : '';
      $record->foodndrinks = isset($request->fnd) ? implode(',', $request->fnd) : '';
      $record->poolnspa = isset($request->spa) ? implode(',', $request->spa) : '';
      $record->transport = isset($request->transport) ? implode(',', $request->transport) : '';
      $record->hotelcode = $request->hotelcode;
      $record->authcode = $request->authcode;
      $record->active = $request->active;
      //dd($record);
      $record->save();
      Session::flash('success', 'Property is saved successfully.');
      return redirect()->route('properties.show', $record->id);
    } // end of store()

dd($record) show me below details but $record->save() show nothing
Properties {#317 ▼
  #table: "properties"
  #connection: null
  #primaryKey: "id"
  #keyType: "int"
  #perPage: 15
  +incrementing: true
  +timestamps: true
  #attributes: array:45 [▼
    "name" => "Bilal Ahmed"
    "pt_id" => "1"
    "rating" => "1"
    "address" => "na"
    "area" => "Sakinaka"
    "city" => "mumbai"
    "pin" => "400072"
    "s_id" => "21"
    "c_id" => "76"
    "rooms" => "12"
    "telno" => "na"
    "mobile1" => "na"
    "mobile2" => "na"
    "email1" => "na@gmail.com"
    "email2" => "na@gmail.com"
    "email3" => "na@gmail.com"
    "website" => "http://www.minqar.com"
    "checkin" => "12:00:00"
    "checkout" => "12:00:00"
    "children" => "Yes"
    "pets" => "No"
    "pickup" => "No"
    "drop" => "No"
    "internet" => "Not Available"
    "parking" => "No"
    "breakfast" => "No"
    "bk_id" => ""
    "acno" => "na"
    "acname" => "na"
    "acbranch" => "na"
    "acifs" => "na"
    "acswift" => "na"
    "lat" => "19.0759837"
    "lng" => "72.87765590000004"
    "panno" => "na"
    "vatno" => "na"
    "stno" => "na"
    "ltno" => "na"
    "activities" => "Tennis Court,Ping Pong"
    "foodndrinks" => "Restaurant,Bar"
    "poolnspa" => "Indoor Pool,Outdoor Pool"
    "transport" => "Bikes Available (free),Airport Shuttle (surcharge)"
    "hotelcode" => "na"
    "authcode" => "na"
    "active" => "y"
  ]
  #original: []
  #relations: []
  #hidden: []
  #visible: []
  #appends: []
  #fillable: []
  #guarded: array:1 [▶]
  #dates: []
  #dateFormat: null
  #casts: []
  #touches: []
  #observables: []
  #with: []
  +exists: false
  +wasRecentlyCreated: false
}

If I analyse Database log it shows me only Prepare insert query but not Execute statement.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire