I have a problem with seeing a view.
Well, I went to url that will take me to the view and I added the link
<a href="{{URL::to('/view_product/'.$v_published_product->product_id)}}">
<p>{{$v_published_product ->product_name}}</p>
</a>
then I went to the routing file and I added the route :
Route::get('/view_product/{product_id}', 'HomeController#product_details_by_id');
I went to the controller and I wrote the product_details_by_id method :
public function product_details_by_id($product_id) {
$product_by_details=DB::table('tbl_products')
->join('tbl_category','tbl_products.category_id','=','tbl_category.category_name')
->join('tbl_manufacture','tbl_products.manufacture_id','=','tbl_manufacture.manufacture_name')
->select('tbl_products.*','tbl_category.category_name','tbl_manufacture.manufacture_name')
->where('tbl_products.product_id',$product_id)
->where('tbl_products.publication_status',1)
->limit(18)
->first();
$manage_product_by_details=view('pages.product_details')
->with('product_by_details',$product_by_details);
return view('layout')
->with('pages.product_details',$manage_product_by_details);
When I go the link /view-product/32 as an example: I found just the layout without the page pages.product_details.
Ps : I did not forget to put #extends('layout') #section('content') and #endsection.
edit 1 :
i tried to make the method simple:
public function product_details_by_id($product_id) {view('pages.test')}
test is a view i created in pages folder with "hello!!". Normally i have to see a white page with Hello!! but all I see is a white page.
Thank you in advance!
Try this code in the controller:
public function product_details_by_id($product_id) {
$product_by_details=DB::table('tbl_products')
->join('tbl_category','tbl_products.category_id','=','tbl_category.category_name')
->join('tbl_manufacture','tbl_products.manufacture_id','=','tbl_manufacture.manufacture_name')
->select('tbl_products.*','tbl_category.category_name','tbl_manufacture.manufacture_name')
->where('tbl_products.product_id',$product_id)
->where('tbl_products.publication_status',1)
->limit(18)
->get();
return view('pages.product_details')
->with('product_by_details',$product_by_details);
}
make sure that the pages folder is inside resources/views
and return view('pages.test');
Related
I want to pass a parameter to my controller from an URL, my code is:
In web.php:
Route::get('infoPatient/{id}','patientController#infoPatient');
In my controller patienController.php:
public function infoPatient($id){
$d=patientModel::find($id);
return view('/patient')->with('d',$d);
}
As a result, the view show data without any style.
the view: https://ibb.co/GCr66zk
Try This.
public function infoPatient($id){
$d=patientModel::find($id);
return view('patient',compact('d'));
}
and in your patient.blade file use variable $d to get the data
the probleme was solved, the issue was that I forget "/" in all link of bootstrap files.
Thank's.
I have folder "aboutus" which contains 'index.blade.php' file and folder "thanks".
Folder "thanks"contains also 'index.blade.php'
My route for both of them:
Route::resource('admin/aboutus', 'AdminAboutusController',['names'=>[
'index'=>'admin.aboutus.index',
'create'=>'admin.aboutus.create',
'store'=>'admin.aboutus.store',
'edit'=>'admin.aboutus.edit'
]]);
Route::resource('admin/aboutus/thanks', 'AboutThanksController',['names'=>[
'index'=>'admin.aboutus.thanks.index',
'create'=>'admin.aboutus.thanks.create',
'store'=>'admin.aboutus.thanks.store',
'edit'=>'admin.aboutus.thanks.edit'
]]);
I have created controller for aboutus and thanks separately (AdminAboutusController and AboutThanksController)
AdminAboutusController index funnction returns view which i am able to see
public function index() { return view('admin.aboutus.index'); }
But controller AboutThanksController doesn`t shows me my page, it shows me white blank
public function index() { return view('admin.aboutus.thanks.index'); }
on php artisan route:list i can see that route is aviable.
Why it happens and how can I fix it?
Put thanks route above about us route
Route::resource('admin/aboutus/thanks', 'AboutThanksController',['names'=>[
'index'=>'admin.aboutus.thanks.index',
'create'=>'admin.aboutus.thanks.create',
'store'=>'admin.aboutus.thanks.store',
'edit'=>'admin.aboutus.thanks.edit'
]]);
Route::resource('admin/aboutus', 'AdminAboutusController',['names'=>[
'index'=>'admin.aboutus.index',
'create'=>'admin.aboutus.create',
'store'=>'admin.aboutus.store',
'edit'=>'admin.aboutus.edit'
]]);
Posting as an answer to close the question:
You have admin.aboutus.thnx.index but your folder is admin/aboutus/thanks/index
Please change to admin.aboutus.thanks.index and it should work
using route:list you are able to see list of routes but return view() function don't take route as a parameter. You have to give the file name and path.For example you want to show thanks.blade.php file which is inside admin/aboutus of your view folder. So you have to write:
return view('admin.aboutus.thanks');
I am having a problem using Laravel Framework. I am trying to build a layout, but no mater how much I've tried I am getting the same error on my browser :
View [layouts.adminLayout.admin_design] not found. (View:
E:\xampp\htdocs\laravel\ecom2\resources\views\admin\dashboard.blade.php)
m following this tutorial
https://www.youtube.com/watch?v=bzYBu0iez3s
here is code of admin_design.blade.php
#include('layouts.adminLayout.admin_header')
#include('layouts.adminLayout.admin_sidebar')
#yield('content')
#include('layouts.adminLayout.admin_footer')
and this is in dashboard.blade.php
#extends('layouts.adminLayout.admin_design')
#section('content')
this is the code of its controller
public function dashboard(){
return view('admin.dashboard');
}
if i write echo "test"; die;
then it shows die but is not showing the desired page... is there any solution for this prblm
Based on your usage this should be your structure:
resources
views
admin
dashboard.blade.php
layouts
adminLayout
admin_header.blade.php
admin_sidebar.blade.php
admin_footer.blade.php
admin_design.blade.php
if you have the layouts folder within your admin folder then you should use admin.layouts.adminLayout.VIEW_NAME
Im new to laravel, but im trying to integrate an existing php script that I have into the laravel app. I understand everything happens in a MVC based architecture. However,im trying to link this page into the header page whose path is application/view/templates/header.php.
For example, there is a controller present in application/controller/LoginController.php and that has a function called public function index() and the way which it is called from headertemplate is:
<li <?php if (View::checkForActiveControllerAndAction($filename, "login/register")) { echo ' class="active" '; } ?> >
Register
</li>
<li>
Administrator Login
</li>
As you can see when i try to call a script which is in the root directory, called admin.php it gives me a 404 - Page not found.
Im really struggling I hope someone can help me figure out the problem. A 404 error is never fun as it is only a tiny error.
If you really want to run a basic PHP script then you can always chuck it in the public directory or try routing it from somewhere else. You're using it as a login script for admins so I would highly suggest just reprogramming it to be a part of your laravel site. Totally up to you though, this may not be the best answer but it will work.
I would suggest do it step by step
Route
In your /app/Http/routes.php
Route::get('/login/register', 'LoginController#index');
Controller
Let make sure you create a LoginController.php in /app/Http/Controllers/
Function
In your /app/Http/Controllers/LoginController.php , create a function call index to return a view.
public function index(){
return view('templates.header); // <-------- /templates/header.blade.php
}
View
inside your /resources/views/templates create header.blade.php
Place all the HTML code needed in it
Test
go to http://localhost/login/register
should load what you place in side your header.blade.php
You shouldn't get 404 anymore.
I'm trying to add a view just a simple contact page, I already have other views.
Here's what I've done so far:
added 'contact' in my routes file here
$route['^(?!/|site|ajax|gallery|contact).*'] = "site/view/$1";
added contact.php to my application/views folder
added contact() to my site controller (whole controller here http://pastebin.com/CCjjrV8R)
function contact() {
$this->load->model('Site_model');
$this->load->view('contact');
}
When I visit the correct url for the view (domain.com/contact), I get a page with partial content and "404" in the
Can anyone see a problem? This is very puzzling.
I don’t think you need the view part of the URL in the route?