0
나는 PHP의 새로운 문서입니다. 나는 laravel로 웹 사이트를 만들고있다. 나는 게시물 작성시 업로드 이미지에 포스트 번호를 추가 할 laravel의 이미지 이름에 게시물 ID 번호를 추가하는 방법 4
내 스토어 컨트롤러 : 가능public function store()
{
$validator = Validator::make(Input::all(), Post::$rules);
if ($validator->passes()) {
$post = new Post;
$post->title = Input::get('title');
$post->body = Input::get('body');
$post->reporter = Input::get('reporter');
$post->meta = Input::get('meta');
$post->slug = Input::get('title');
$post->top = Input::get('top');
$post->pubdate = Input::get('pubdate');
$image = Input::file('image');
if ($image) {
$filename = "image274".$image->getClientOriginalExtension();
Image::make($image->getRealPath())->resize(250, 145)->save('public/images/postimages/'.$filename);
$post->image = 'images/postimages/'.$filename;
}
$categories = Input::get('categories');
$post->save();
$post->categories()->sync($categories);
return Redirect::route('admin.posts.index')
->with('message', 'Product Created');
}
return Redirect::back()
->with('message', 'Something went wrong')
->withErrors($validator)
->withInput();
}
인가? 도와주세요.
감사 사이 풀
$ 파일 이름 변수에 – saiful408