我在这里使用 laravel 和 html。无论如何,通过这样做,我从控制器获取了数据以查看并在下拉列表中显示。现在下一部分是为此进行 crud 操作。所以每当我从下拉列表中选择选项时,应该显示特定的 ID 元素。这是我的视图代码:<div class="form-row"> <div class="form-group col-md-6"> <label>Name</label> <select name="id" class="form-control"> @foreach($clients as $client) <option value="{{ $client->Cid }}" {{ $selectedclients == $client->Cid ? selected="selected" : '' }}>{{ $client->name }}</option> @endforeach </select> </div> </div>这是我的控制器: $Clients = Client::all(); $selectedClients = Client::first()->Cid;当我运行它时,我收到此错误:语法错误,意外的“=”(视图:/home/prasanna/Billing-master/resources/views/Qtcreate.blade.php)。请帮我解决这个问题。提前谢谢你
2 回答
Qyouu
TA贡献1786条经验 获得超11个赞
class Client extends Model
{
protected $table = 'client';
protected $primaryKey = 'Cid';
protected $guarded = ['Qid'];
protected $fillable = ['name', 'address', 'contact', 'created_at', 'updated_at' ];
public function client()
{
return $this->hasMany('App\qt',Qid,Cid);
}
}
class qt extends Model
{
protected $table = 'qts';
protected $primaryKey = 'Qid';
protected $guarded = ['Cid'];
protected $fillable=['Itemname','Quantity','Price','Tax','Total','GrandTotal','created_at', 'updated_at'];
public function qts()
{
return $this->belongsTo('App\Client',Cid,Qid);
}
}
- 2 回答
- 0 关注
- 194 浏览
添加回答
举报
0/150
提交
取消