In my Web.php I have :
Route::get('/regions' , 'RegionsController#show');
Route::get('/regions/{region}' ,'RegionsController#getDetail');
Route::get('/login' , function(){
return view('users');
});
Route::get('/regions/create',function(){
return view('/regions/create');
});
Route::get('create',function(){
return view('regions/create');
});
Route::post('/regions' , 'RegionsController#store');
Route::get('users' , function(){
return view('users');
});
But When I want to get the create View , the page is not found , and I know it is due to the GetDetail Method in RegionsController, So my Question is What to do to get the create view when I Type /regions/create ?
Try to switch the placese of routes. Put regions/create before regions/{parameter}
Make folder regions in views folder. Then make file create.blade.php in regions folder.
Related
So i have folder 'posts' where i have 3 blade templates. I want to use some variable in all this templates. Therefore i added array of my templates. How can i set a folder with this files instead of array ?
What i have:
view()->composer(['admin.posts.index' , 'admin.posts.edit' , 'admin.posts.create'], function($view){
$view->with('current_user', Auth::user());
});
What i want:
view()->composer('folder_name', function($view){
$view->with('current_user', Auth::user());
});
Perhaps you can try with a wildcard:
view()->composer('admin.posts.*', ...);
Whenever there is a call to Controller inside View, I want the Controller to return some variables to the View and do not refresh the View.
Already know:
return view("webpage" , compact('variable1', 'variable2') );
What I expect to achieve:
return compact('variable1', 'variable2');
This will not return the Webpage but only some of the variables.
Edit:
Thinking it from a complete different perspective, The question maybe rephrased as such
Is there a way to manipulate REQUEST variables of a web page from the controller? This way, i would be able to get new variables from the Controller without the web page being Refreshed.
With out much to work with, here is an example:
Ajax call:
$.ajax({
url: '/your/route/',
type: 'GET',
data: {getVariable: formInputValue},
})
.done(function (data) {
console.log(data);
})
.fail(function () {
console.log('Failed');
});
Controller Function:
public function getVariable(Request $request){
$resault = $request->getVariable;
return response()->json($results);
}
Update: as per comments on this answer try this and see if it works for you.
In your controller where you fetch records instead of using a ->get();
change it to paginate(5); this will return 5 records per page. and on your view at the bottom of your </table> add {{ $variable->links() }}
I have a simple Nova integration like this :
I want somehow to make the Name field to be an anchor. So, to make it a link the same way that view button does. Any ideas? (Nothing on docs)
Text::make('name')
->asHtml()
->displayUsing(function ($name) {
return {{$name}}
})
Text::make('Name', function () {
return ''.$this->name.'';
})->asHtml()
I am trying to make via hi in view but its give me white page display. I have created controller and view ... path is also set in web.php
ROUTE:
Route::post('/member/add-single-trade/import_single_trades_parse', 'trades\ImportSingleTradesController#tradesImport');
CONTROLLER:
public function tradesImport()
{
return view('member.add-single-trade.import-excel.import_fields', compact( ''));
}
BLADE: import_fields.blade.php
hi
why dont you just return 'hi' in tradesImport() to see whether the route works fine
SOLVED: underscore does not work in route: /member/add-single-trade/import_single_trades_parse
It's working with : /member/add-single-trade/import-single-trades-parse
This is the function that I am using in my controller
public function homeList()
{
//Get all the franchises
$franchises = Franchise::all();
//Load the view and pass the franchises
return View::make('frontend.layouts.footer')->with('franchises', $franchises);
}
and I keep getting this error. I don't know how to pass it or what to put on the routes.php file
You should be able to do #include('frontend.layouts.footer')->with('franchises', Franchise::all()).
Update:
To avoid the model in the view, you should use a view composer, as it was stated in a previous answer.
View::composer('frontend.layouts.footer', function($view)
{
$view->with('franchises', Franchise::all());
});
Now you have $franchises available in the view. This code you can place in routes.php or you can create a composers.php and autoload it.