Hello .
Important
I found something very important : I dont think that this problem is related to the DB or model because
Route::get('tst4', function () {
return 'http://test https://';
}) ;
returns : //test //
Laravel 5.8 PHP 7.2 PostgeSQL 10.10
Here the result from Tinker :
>>> App\training::find(7);
=> App\training {#3142
id: 7,
title: "training https: test after adding the permission: https",
begin_date: "2019-11-05 00:00:00",
end_date: "2019-11-05 00:00:00",
...
}
From Controller:
{
"id": 7,
"title": "training test after adding the permission: https",
"begin_date": "2019-11-05 00:00:00",
"end_date": "2019-11-05 00:00:00",
"created_at": "2019-11-05 15:19:35",
...
As you can see in Tinker result the field title contains the string https: unlike in the result from the controller.
This problem is also with the word http:
I dont know if it's a kind of security in Laravel to prevent links maybe, but how to solve this ?
Training controller :
public function show($id)
{
$training = Training::with([
'trainers', 'categories', 'participants'
])->findOrFail($id);
return $training;
}
Training model :
protected $casts = [
'external_urls' => 'object'
];
protected $appends = ["levelName"];
public function getLevelNameAttribute()
{
if ($this->level == null) return null;
return level::find($this->level_id)->name;
}
public function categories()
{
return $this->belongsToMany(category::class);
}
public function level()
{
return $this->belongsTo('App\level');
}
public function participants()
{
return $this->belongsToMany(User::class, 'participants_training')
->select([DB::raw("CONCAT(last_name,' ', first_name) AS name"),
'last_name', 'first_name'
]);
}
public function trainers()
{
return $this->belongsToMany(User::class, 'trainers_training')
->select([
DB::raw("CONCAT(last_name,' ', first_name) AS name"),
'last_name', 'first_name'
]);
}
}
Thanks