foreach(\App\Menu::all() as $menu){
Route::get($menu->module_slug, $menu->module_slug.'Controller@index');
Route::get($menu->module_slug.'/{slug}', $menu->module_slug.'Controller@by_slug');
}
// хотя если пунктов меню не слишком много лучше сделать как предложено выше
...
// module_slug = 'Brand'
class BrandController{
... index(){}
.... by_slug(\App\Brand $slug){}
}
+ использовать https://laravel.com/docs/5.6/routing#route-model-b... class AppServiceProvider extends ServiceProvider
{
public function boot()
{
\URL::forceScheme('https');
<li><label><input name="question[{{$question->id}}]" type="radio" value="a">Постоянно</label></li>
<li><label><input name="question[{{$question->id}}]" type="radio" value="b">Иногда</label></li>
<li><label><input name="question[{{$question->id}}]" type="radio" value="c">Время от времени</label></li>
Route::get('/robots.txt',function(){
return response()->streamDownload(function () {
echo \App\Block::where('kind', 'robots.txt')->first()->code;
}, 'robots.txt', ['Content-Type'=>'text/plain'],'inline');
});
class ReportRepository{
function __construct(ReportableModelInterface $model){}
function getSimpleReportData($id){}
function getCustomReportData($id, $any){}
}
// GET site.ru/seo_friendly_article_name
Route::get('/{article_slug}', 'ArticleController@article');
// в контроллере
public function article(Article $article_slug){
// определяете нужное представление
return view("articles.categories.{$article_slug->category_id}.show", ['article' => $article_slug]);
}
скрипт перестает работать- это не диагноз. это магия.
выбором опций, за которые отвечают скриптовые файлы- что за файлы? когда они подгружаются? может там события на элементах которые появляются на странице только после загрузки модального окна?
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
})
namespace App\Http\Middleware;
use Closure;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
class AjaxOnly
{
public function handle($request, Closure $next)
{
if(!$request->ajax()){
throw new BadRequestHttpException('This resource only accepts an ajax requests');
}
return $next($request);
}
}
class CustomAuthController {
public function validate (Request $request) {
$rules = [
'username' => 'required|string|max:255',
'email' => 'required|string|email|max:255',
'password' => 'required|string|min:6',
'invite' => 'required|integer|min:6',
];
// Внимание
$request->validate($rules);
}
}
'lifetime' => env('SESSION_LIFETIME', 120),
'expire_on_close' => false,
SESSION_LIFETIME=120
Route::get('/x/{user?}', 'HomeController@index');
Route::get('/xxxxxxx', 'HomeController@index');
@dd(
action('HomeController@index'),
action('HomeController@index',['im_a_guest']),
)
/*
"http://laravel.local/xxxxxxx"
"http://laravel.local/xxxxxxx/im_a_guest"
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],