मैं बोलने में निपुण उपयोग कर रहा हूँ मेरी मेज अवसर अद्यतन करने के लिए,Laravel बचाने() विधि सच लौटने लेकिन अपडेट नहीं हो रिकॉर्ड
अवसर मॉडल
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Opportunity extends Model {
protected $primaryKey = 'OpportunityID';
protected $table = 'opportunitys';
// relationships
public function csfs()
{
return $this->hasMany('App\Csf', 'opportunityID');
}
public function benefits()
{
return $this->hasMany('App\Benefit', 'opportunityID');
}
public function risks()
{
return $this->hasMany('App\Risk', 'opportunityID');
}
public function projects()
{
return $this->belongsTo('App\Project', 'projectID');
}
public static function createNewOpportunity($input, $projectID)
{
$opportunity = new Opportunity;
$opportunity->value = $input['value'];
$opportunity->margin = $input['margin'];
$opportunity->duration = $input['duration'];
$opportunity->tender_type = $input['tender_type'];
$opportunity->likelihood_of_success = $input['likelihood_of_success'];
$opportunity->scope_of_work = $input['scope_of_work'];
$opportunity->deliverables = $input['deliverables'];
$opportunity->projectID = $projectID;
$opportunity->high_level_background = $input['high_level_background'];
if($opportunity->save())
{
Opportunity::leadSalesOppComplete($projectID);
return true;
};
}
public static function leadSalesOppComplete($projectID)
{
$task = Lead::where('projectID', '=', $projectID)->first();
$task->sales_opp = true;
return $task->save();
}
}
public function updateOpportunity(Request $request, $id) {
मैं आईडी हो और मौका पाएं
$something = Opportunity::find($id);
मैं मर गया, और इस फेंक दिया और मैं इस
Opportunity {#259 ▼
#primaryKey: "OpportunityID"
#table: "opportunitys"
#connection: null
#perPage: 15
+incrementing: true
+timestamps: true
#attributes: array:12 [▼
"opportunityID" => 11
"value" => 0
"margin" => 0
"tender_type" => ""
"likelihood_of_success" => 0
"high_level_background" => ""
"scope_of_work" => ""
"deliverables" => ""
"duration" => ""
"projectID" => 6
"created_at" => "2015-03-11 17:45:47"
"updated_at" => "2015-03-11 17:45:47"
]
#original: array:12 [▶]
#relations: []
#hidden: []
#visible: []
#appends: []
#fillable: []
#guarded: array:1 [▶]
#dates: []
#casts: []
#touches: []
#observables: []
#with: []
#morphClass: null
+exists: true
}
कौन सा सही है मिल गया है। मैं तो यदि मैं मर गया और डंप मैं
Opportunity {#259 ▼
#primaryKey: "OpportunityID"
#table: "opportunitys"
#connection: null
#perPage: 15
+incrementing: true
+timestamps: true
#attributes: array:12 [▼
"opportunityID" => 11
"value" => "25000"
"margin" => "0"
"tender_type" => "Proposal"
"likelihood_of_success" => "0"
"high_level_background" => ""
"scope_of_work" => ""
"deliverables" => ""
"duration" => ""
"projectID" => 6
"created_at" => "2015-03-11 17:45:47"
"updated_at" => "2015-03-11 17:45:47"
]
#original: array:12 [▼
"opportunityID" => 11
"value" => 0
"margin" => 0
"tender_type" => ""
"likelihood_of_success" => 0
"high_level_background" => ""
"scope_of_work" => ""
"deliverables" => ""
"duration" => ""
"projectID" => 6
"created_at" => "2015-03-11 17:45:47"
"updated_at" => "2015-03-11 17:45:47"
]
#relations: []
#hidden: []
#visible: []
#appends: []
#fillable: []
#guarded: array:1 [▶]
#dates: []
#casts: []
#touches: []
#observables: []
#with: []
#morphClass: null
+exists: true
}
मैं केवल मूल्य जो बदलाव को दर्शाता है बदल पाने
$something->margin = $request['margin'];
$something->duration = $request['duration'];
$something->tender_type = $request['tender_type'];
$something->likelihood_of_success = $request['likelihood_of_success'];
$something->scope_of_work = $request['scope_of_work'];
$something->deliverables = $request['deliverables'];
$something->high_level_background = $request['high_level_background'];
अब के साथ इन अद्यतन करें।
मैं अब चलाने
$something->save();
यह सच रिटर्न जब मैं मर जाते हैं और यह डंप।
लेकिन डेटाबेस में कोई रिकॉर्ड नहीं बदला गया है।
कोई विचार? टिंकर
सेदो छवियों
सरणी $ अनुरोध क्या है? इसमें कोई मूल्य है? – Carter
लार्वेल -5 में आप सभी पदों पर अनुरोध कक्षा का उपयोग करते हैं, यह लैरवेल 4.2 –
में पुराने इनपुट का उपयोग करने के समान है, यदि यह अनुरोध का इंजेक्शन उदाहरण है, तो इसके बजाय इनपुट() को कॉल करके मूल्य प्राप्त करने का प्रयास करें, जैसे $ request-> इनपुट ('हाशिया')। – Carter