本文整理汇总了PHP中app\models\Tag::whereClave方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::whereClave方法的具体用法?PHP Tag::whereClave怎么用?PHP Tag::whereClave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Tag
的用法示例。
在下文中一共展示了Tag::whereClave方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
public function store()
{
$rules = array('titulo' => 'required|max:25', 'descripcion' => 'required|max:40', 'imagen' => 'required|image', 'tags' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return redirect(route('post.create'))->withErrors($validator)->withInput(Input::all());
} else {
$image = Input::file('imagen');
$filename = time() . '.' . $image->getClientOriginalExtension();
$pathS = public_path('images\\portfolio\\small\\' . $filename);
$pathL = public_path('images\\portfolio\\large\\' . $filename);
$rps = 'images\\portfolio\\small\\' . $filename;
$rpl = 'images\\portfolio\\large\\' . $filename;
\Intervention\Image\Facades\Image::make($image->getRealPath())->resize(290, 217)->save($pathS);
\Intervention\Image\Facades\Image::make($image->getRealPath())->save($pathL);
$post = $this->savePost(Input::get(), $rps, $rpl);
if (Input::get('tags') != '') {
$tags = explode(',', Input::get('tags'));
foreach ($tags as $tag) {
$tag_ref = \App\Models\Tag::whereClave($tag)->first();
if (is_null($tag_ref)) {
$tag_ref = new \App\Models\Tag();
$tag_ref->clave = $tag;
$post->tags()->save($tag_ref);
} else {
$post->tags()->attach($tag_ref->id_tag);
}
}
}
return redirect('post/create')->with('ok', 'Elemento Insertado Correctamente');
}
}