flavors.append(`<div class='col l6 flavor animated fadeIn'>
<div class='flavor-bottle'></div>
<div class='flavor-desrc'><div class='input-field'>
<input type='text' id='autocomplete-input' class='autocomplete' name='names[]'>
<label for='autocomplete-input'>name</label> </div> <div> <input name='group' type='radio' id='inPG' checked/>
<label for='inPG'>PG</label> <input name='group1' type='radio' id='inVG'/> <label for='inVG'>VG</label>
</div>
</div>
</div>`);
public function showCategory(Request $request, $id)
{
$recipes = Tag::find($id)->recipes()->where('public', '=', 1)->get();
$tags = Tag::with('recipes')->get();
if ($request->ajax()) {
return view('site.recipe_load', ['recipes' => $recipes])->render();
}
return view('site.recipe_load', ['recipes' => $recipes]);
}
class Recipe extends Model
{
public function tag_links()
{
return $this->hasMany('Recipe_Tag', 'recipe_id');
}
}
class Recipe_Tag extends Model
{
public function tag()
{
return $this->hasOne('Tag', 'tag_id');
}
}
class Tag extends Model
{
}
$receipes = Recipe::with('tag_links')->get();
foreach ($receipes as $receipe)
{
echo '<h1>'.$receipe->title.'</h1>';
echo 'Категории: ';
foreach ($receipe->tag_links as $tag_link)
{
echo $tag_link->tag->name;
}
}
$flavours = collect($request->name)->map(function ($value) {
return ['name' => $value];
})->all();
DB::table('flavours')->insert($flavours);
Route::group(['middleware' => 'admin', 'prefix' => 'admin'], function () {
Route::get('', function()
{
return view('admin.dashboard');
});
Route::resource('articles','ArticlesController');
Route::resource('categories','CategoriesController');
});
var value;
if (!$(".f_value").data('baseVal')){ //проверяем есть ли сохраненное значение
value = $(".f_value").val(); //присваиваем значение переменной
$(".f_value").data('baseVal',value); //тк сохраненного нет - сохраняем
} else {
value = $(".f_value").data('baseVal'); //тк сохраненное есть - присваиваем переменной его
}
// Правила можешь вынести в функцию в модели
$rules = [
'file' => 'required|mimes:jpg,png,mp4,webm',
];
$validation = Validator::make($request->all(), $rules);
if( $validation->fails() ) {
$errors = $validation->messages()->toJson();
}
return response()->json([ "errors" => $errors ]);