
Laravel
- 34 ответа
- 0 вопросов
16
Вклад в тег
// http://php.net/manual/en/function.file-exists.php#75064
$file = 'http://www.domain.com/somefile.jpg';
$file_headers = @get_headers($file);
if($file_headers[0] == 'HTTP/1.1 404 Not Found') {
$exists = false;
}
else {
$exists = true;
}
// это для формирования верного url через хелпер
public function getRouteKey()
{
return "{$this->id}-{$this->slug}";
}
public function resolveRouteBinding($value)
{
$keys = explode('-', $value);
return Watch::where(['id'=>$keys[0], 'slug'=>$keys[1]])
}
Route::get('/watch/{fullSlug}', 'WatchController@get');
public function get(Watch $fullSlug)
{
// fullSlug обязательно существует или 404 ещё до входа в контроллер
}