좋아 내 코드에laravel 4.1 유효성 검사 URL을 입력
과 거의 모든 일이 일을 얻을 후의 i는 사용자의 URL 입력을
을 확인하는 방법에 대한 도움말을 그가 삽입 한 경우에 필요
꽤 좋은 여기에 404 페이지
을에 서문과하는 방법이 아닌 URL이 내 경로 파일입니다
Route::get('/', function()
{
return View::make('hello');
});
Route::post('/', function()
{
$url = Input::get('url');
$record = Url::where('urls', '=', $url)->first();
if ($record) {
return View::make('result')
->with('shortend', $record->shortend);
}
function get_uniqe_short_url()
{
$shortend = base_convert(rand(1000,99999), 10, 36);
if (Url::where('shortend', '=' ,$shortend)->first()){
get_uniqe_short_url();
}
return $shortend;
}
$shortend = get_uniqe_short_url();
// otherwise add new row and return shortned url
$row = new URl;
$row->urls = $url;
$row->shortend = $shortend;
$row->save();
// create a results view and present the short url to the usr
if ($row){
return View::make('result')->with('shortend',$shortend);
}
});
Route::get('{shortend}', function($shortend)
{
// query the DB For the row with that short url
$row = Url::where('shortend', '=', $shortend)->first();
// if not found redirect to home page
if (is_null($row)) return Redirect::to('/');
// else grab the url and redirect
return Redirect::to($row->urls);
});
내 많은 질문에 대해 용서하지만 나는 완전히 laravel에
내가 지금 그것을 시도하고 난 당신이 나에게주는 해당 URL에서 찾게됩니다 도움을 주셔서 감사하고 감사합니다 : 이것은 당신이 PHP에서 정규 표현식을 사용하는 방법입니다 내가 코드를 테스트 한 결과로 말입니다. – Jone
어떻게 진행되는지 알려주고 문제에 대한 조언을 계속 할 수 있습니다. 후반 재생 죄송 – Sam
좋아 샘 하지만 나는 그것의 오늘 – Jone