syntax error, unexpected 'else' (T_ELSE) in laravel [duplicate] - php

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 4 years ago.
i am beginner in programming and in laravel, and i have some issue about my code/project.
I want a condition where my main web menu can only be accessed by auth user, but i have an error when make condition in the code.
Please help me fix this problem
*ps sory for bad english
here the views
<!DOCTYPE html>
<html lang="en">
<head>
<title>DOKO MOTOR</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="{{url('/')}}/css/lwd.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div id="top-header" style="background:#FFF;height: 100px;"s>
<div id="header" class="hidden-sm hidden-xs">
<img src="{{url('/')}}/img/logo.png" height="90px" style="position: absolute;">
<div class="bendera"></div>
<div class="hotline pull-right">
<div class="left"><i class="glyphicon glyphicon-earphone" style="
font-size: 50px; color:red;
"></i></div>
<div class="right">
<div class="r-top">hotline :</div>
<div class="r-bot">0896 5200 6229</div>
</div>
<div class="break"></div>
</div><!-- /.hotline -->
<div class="top-wel pull-right">Selamat datang di website kami, Jumat, 11 Mei 2018 </div>
</div><!-- /#header -->
</div>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="{{ url("") }}">DOKO MOTOR</a>
</div>
<ul class="nav navbar-nav">
<!-- #if(Auth::user()) -->
#if(Auth::user())
<li class="{{ request()->is('book') ? 'active' : '' }}"><span class="glyphicon glyphicon-wrench"></span> Book Service</li>
<!-- #endif -->
<li class="{{ request()->is('services') ? 'active' : '' }}"><span class="glyphicon glyphicon-hourglass"></span> Antrian Service</li>
<li class="{{ request()->is('contact') ? 'active' : '' }}"><span class="glyphicon glyphicon-user"></span> Kontak</li>
<li class="{{ request()->is('tentang') ? 'active' : '' }}"><span class="glyphicon glyphicon-earphone"></span> Tentang</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<!-- #if(Auth::user()) -->
<li><a href="{{URL::to('/logout')}}">
<span style="color: blue"> {{ ucwords(Auth::user()->name) }}</span> <span class="glyphicon glyphicon-log-in"></span> Logout</a></li>
<!-- #else -->
#else
<li><span class="glyphicon glyphicon-user"></span> Daftar</li>
<li><span class="glyphicon glyphicon-log-in"></span> Login</li>
<!-- #endif -->
#endif
</ul>
</div>
</nav>
<div class="container">
#yield('content')
</div>
<div id="footer">
<div class="row">
<div class="col-md-12">
<div class="copy">Copyright © 2018 - All rights reserved.</div>
</div>
</div><!-- /.row -->
</div>
</body>
</html>
here the route
Route::get('/signin', function() {
return view('login');
});
Route::get('/register/{date?}', function($date = null) {
return view('register',['date',$date]);
});
Route::post('/register_action/{date?}','RegisterController#store');
Route::post('/login_check','RegisterController#login');
Route::get('logout', function() {
Auth::logout();
return Redirect::to('');
})->middleware("auth");
Route::get('/', function(){
if( auth()->check() ){
return Redirect::to('/');
}else{
return Redirect::to('/auth');
}
});
Route::get('/', 'HomeController#index');
Route::get('/contact','ContactController#index');
Route::get('/tentang','TentangController#index');
Route::get('/book/{date?}', 'ServisController#book');
Route::get('/services/{add?}', 'ServisController#services');
Route::post('/submit_book', 'ServisController#submit_book');
Route::post('/update_service', 'ServisController#update_service');
Route::post('/delete_service', 'ServisController#delete_service');
error message
I'll appreciate anything would help me
Kindly regards

Try changing the way you structure your html:
#if(Auth::user())
<ul class="nav navbar-nav">
<li class="{{ request()->is('book') ? 'active' : '' }}"><span class="glyphicon glyphicon-wrench"></span> Book Service</li>
<li class="{{ request()->is('services') ? 'active' : '' }}"><span class="glyphicon glyphicon-hourglass"></span> Antrian Service</li>
<li class="{{ request()->is('contact') ? 'active' : '' }}"><span class="glyphicon glyphicon-user"></span> Kontak</li>
<li class="{{ request()->is('tentang') ? 'active' : '' }}"><span class="glyphicon glyphicon-earphone"></span> Tentang</li>
</ul>
#endif
<ul class="nav navbar-nav navbar-right">
#if(Auth::user())
<li><a href="{{URL::to('/logout')}}">
<span style="color: blue"> {{ ucwords(Auth::user()->name) }}</span> <span class="glyphicon glyphicon-log-in"></span> Logout</a></li>
#else
<li><span class="glyphicon glyphicon-user"></span> Daftar</li>
<li><span class="glyphicon glyphicon-log-in"></span> Login</li>
#endif
</ul>
The way you write your HTML must make sense after the if statements, to visualise this try removing the code that a situation would create, so if the user isn't there remove that code and see what you are left with, at the moment you would have HTML that wouldn't make sense and the browser wouldn't be able to present it in the way you would like

Related

How to load a controller before connecting to DB or even when MySQL turned off

I wonder if someone can help me to load a "maintanence" controller before the framwork connects to DB.
that will load tpl file.
For example, when the app is under construction and I want to turn the MySQL database off, but I want to show the people who get my web a page (tpl file that is loaded by controller) "we are under construction" page and all this by loading tpl files and not requiring PHP file.
OpenCart core makes the DB connection before any controller is loaded. So if you plan to turn to maintenance mode, before anything is displayed to the user, the DB connection is already established.
It is practically impossible to separate the DB from the core since it is so tightly coupled.
The only solution would be to create a index.html file as a copy of your maintenance mode html like Paul Feakins replied in comments.
here is a clean html you can use. should work for anyone.
in your root directory create index.html and paste this code:
<!DOCTYPE html>
<!--[if IE]><![endif]-->
<!--[if IE 8 ]><html dir="ltr" lang="en" class="ie8"><![endif]-->
<!--[if IE 9 ]><html dir="ltr" lang="en" class="ie9"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<html dir="ltr" lang="en">
<!--<![endif]-->
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Maintenance</title>
<script src="catalog/view/javascript/jquery/jquery-2.1.1.min.js" type="text/javascript"></script>
<link href="catalog/view/javascript/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen" />
<script src="catalog/view/javascript/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<link href="catalog/view/javascript/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,400i,300,700" rel="stylesheet" type="text/css" />
<link href="catalog/view/theme/default/stylesheet/stylesheet.css" rel="stylesheet">
<script src="catalog/view/javascript/common.js" type="text/javascript"></script>
<link href="/image/catalog/cart.png" rel="icon" />
</head>
<body>
<nav id="top">
<div class="container"><div class="pull-left">
<form action="/index.html" method="post" enctype="multipart/form-data" id="form-currency">
<div class="btn-group">
<button class="btn btn-link dropdown-toggle" data-toggle="dropdown"> <strong>$</strong> <span class="hidden-xs hidden-sm hidden-md">Currency</span> <i class="fa fa-caret-down"></i></button>
<ul class="dropdown-menu">
<li>
<button class="currency-select btn btn-link btn-block" type="button" name="EUR">€ Euro</button>
</li>
<li>
<button class="currency-select btn btn-link btn-block" type="button" name="GBP">£ Pound Sterling</button>
</li>
<li>
<button class="currency-select btn btn-link btn-block" type="button" name="USD">$ US Dollar</button>
</li>
</ul>
</div>
<input type="hidden" name="code" value="" />
<input type="hidden" name="redirect" value="/index.html" />
</form>
</div>
<div id="top-links" class="nav pull-right">
<ul class="list-inline">
<li><i class="fa fa-phone"></i> <span class="hidden-xs hidden-sm hidden-md">123456789</span></li>
<li class="dropdown"><i class="fa fa-user"></i> <span class="hidden-xs hidden-sm hidden-md">My Account</span> <span class="caret"></span>
<ul class="dropdown-menu dropdown-menu-right">
<li>Register</li>
<li>Login</li>
</ul>
</li>
<li><i class="fa fa-heart"></i> <span class="hidden-xs hidden-sm hidden-md">Wish List (0)</span></li>
<li><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md">Shopping Cart</span></li>
<li><i class="fa fa-share"></i> <span class="hidden-xs hidden-sm hidden-md">Checkout</span></li>
</ul>
</div>
</div>
</nav>
<header>
<div class="container">
<div class="row">
<div class="col-sm-4">
<div id="logo"> <h1>Your Store</h1>
</div>
</div>
<div class="col-sm-5"><div id="search" class="input-group">
<input type="text" name="search" value="" placeholder="Search" class="form-control input-lg" />
<span class="input-group-btn">
<button type="button" class="btn btn-default btn-lg"><i class="fa fa-search"></i></button>
</span>
</div></div>
<div class="col-sm-3"><div id="cart" class="btn-group btn-block">
<button type="button" data-toggle="dropdown" data-loading-text="Loading..." class="btn btn-inverse btn-block btn-lg dropdown-toggle"><i class="fa fa-shopping-cart"></i> <span id="cart-total">0 item(s) - $0.00</span></button>
<ul class="dropdown-menu pull-right">
<li>
<p class="text-center">Your shopping cart is empty!</p>
</li>
</ul>
</div>
</div>
</div>
</div>
</header>
<div class="container">
<nav id="menu" class="navbar">
<div class="navbar-header"><span id="category" class="visible-xs">Categories</span>
<button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"><i class="fa fa-bars"></i></button>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">Desktops
</li>
<li class="dropdown">Laptops & Notebooks
</li>
<li class="dropdown">Components
</li>
<li>Tablets</li>
<li>Software</li>
<li>Phones & PDAs</li>
<li>Cameras</li>
</ul>
</div>
</nav>
</div>
<div id="common-maintenance" class="container">
<div class="row">
<div class="col-12"><h1 style="text-align:center;">We are currently performing some scheduled maintenance. <br/>We will be back as soon as possible. Please check back soon.</h1></div>
</div>
</div>
<footer>
<div class="container">
<div class="row">
<div class="col-sm-3">
<h5>Information</h5>
<ul class="list-unstyled">
<li>About Us</li>
<li>Delivery Information</li>
<li>Privacy Policy</li>
<li>Terms & Conditions</li>
</ul>
</div>
<div class="col-sm-3">
<h5>Customer Service</h5>
<ul class="list-unstyled">
<li>Contact Us</li>
<li>Returns</li>
<li>Site Map</li>
</ul>
</div>
<div class="col-sm-3">
<h5>Extras</h5>
<ul class="list-unstyled">
<li>Brands</li>
<li>Gift Certificates</li>
<li>Affiliate</li>
<li>Specials</li>
</ul>
</div>
<div class="col-sm-3">
<h5>My Account</h5>
<ul class="list-unstyled">
<li>My Account</li>
<li>Order History</li>
<li>Wish List</li>
<li>Newsletter</li>
</ul>
</div>
</div>
<hr>
<p>Powered By OpenCart<br /> Your Store © 2019</p>
</div>
</footer>
<!--
OpenCart is open source software and you are free to remove the powered by OpenCart if you want, but its generally accepted practise to make a small donation.
Please donate via PayPal to donate#opencart.com
//-->
</body></html>

Laravel : after adding make:auth getting an error in my login/register page

i've made a laravel newswebsite. i've tried to add auth by doing make:auth, but when i click the button login or register it gives me an error like this:
i dont know where it is coming from. it refers to a function in my controller but i dont know why cause it doesnt need that function at all. i usually dont have errors while adding authorization. is there anyone who's had the same problem or anyone who knows how to fix it?
app.blade.php
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<link rel="stylesheet" href="{{asset('css/app.css')}}">
<link rel="stylesheet" href="{{asset('css/custom.css')}}">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<title>{{config('app.name', 'News')}}</title>
</head>
<body>
#include('inc.navbar')
#include('inc.messages')
#yield('content')
#include('inc.footer')
</body>
navbar.blade.php
<header>
<div class="container-fluid">
<div class="row headercontent">
<div class="col-md-3 offset-md-1 borderbottom">
</div>
<div class="col-md-4 borderbottom header-logo bg-white">
<a href="{{url('/')}}"><img class="high-pic"
src="https://upload.wikimedia.org/wikipedia/commons/7/77/The_New_York_Times_logo.png"
style="width: 100%;"></a>
</div>
<div class="col-md-3 search">
<span class="fas fa-search"></span>
<input type="text" class="borderbottom backgroundtextinput"
style="position:absolute; bottom:0; width:80%;outline:none;">
</div>
</div>
<div class="row logo-NY">
<div class="col-md-6 offset-md-3 borderbottom header-logo bg-white">
<div style="z-index:3000;"></div>
<a href="{{url('/')}}"><img class="high-pic"
src="https://upload.wikimedia.org/wikipedia/commons/7/77/The_New_York_Times_logo.png"
style="width: 100%;"></a>
</div>
<div class="col-md-3">
<div id="clickme" class="d-lg-none">
<i class="fas fa-arrow-down"></i>
</div>
</div>
<div class="col-md-3">
</div>
</div>
</div>
<div class="desktop-nav">
<nav class="navbar navbar-expand-lg navbar-light font">
<div class="container">
<div class="" id="navbarSupportedContent" style="margin:auto;">
<div class="navbar-flex fontcolorblack">
#foreach($categories_navbar as $item)
<div class="nav-item">
<a class="nav-link bold" href="{{url($item->naam)}}">{{ucfirst($item->naam)}}</a>
</div>
#endforeach
#guest
<li class="nav-item">
<a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
</li>
#if (Route::has('register'))
<li class="nav-item">
<a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
</li>
#endif
#else
<li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
{{ Auth::user()->name }} <span class="caret"></span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ __('Logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
#csrf
</form>
</div>
</li>
#endguest
</div>
</div>
</div>
</nav>
</div>
<div id="mobile-nav" style="width: 100%; display: none; background-color: #2e3192; color: #fff;">
<div id="closeme" class="d-lg-none">
<i class="fas fa-times fa-2x"></i>
</div>
<nav class="navbar navbar-light bg-light fixed-top d-lg-none" style="z-index:999;">
<ul class="navbar-nav mr-auto">
<a href="{{url('/')}}"><img class="high-pic"
src="https://upload.wikimedia.org/wikipedia/commons/7/77/The_New_York_Times_logo.png"
style="width: 100%;"></a>
#foreach($categories_navbar as $item)
<div class="nav-item">
<a class="nav-link bold" href="{{url($item->naam)}}">{{ucfirst($item->naam)}}</a>
</div>
#endforeach
<form class="form-inline my-2 my-lg-0" id="search_mobile" action="search" method="get">
<input class="form-control mr-sm-2" name="search" type="search" placeholder="Search..."
aria-label="Search">
</form>
#guest
<li class="nav-item">
<a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
</li>
#if (Route::has('register'))
<li class="nav-item">
<a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
</li>
#endif
#else
<li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
{{ Auth::user()->name }} <span class="caret"></span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ __('Logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
#csrf
</form>
</div>
</li>
#endguest
</ul>
</nav>
</div>
</header>
It seems to me that the problem actually is in the above line.
$category = Categorie::where('naam',$category)->first();
This line is not returning any data. Try putting dd($category) after this line to check if there is indeed a category with your query.
Probably you are trying to access non-existing category, this page should return 404 error.
after $category = Categorie::where('naam',$category)->first();
add line
abort_if(is_null($category), 404);
and it will return 404 error as it must be.
Try to debug like this,
public function oversight($category){
try{
$getCategory = Categorie::where('naam',$category)->first();
if($getCategory !== null){
dd("I GOT SELECTED CATEGORY ROW");
}else{
dd("I THINK THERE IS NO DATA AVAIALBLE BASED ON WHERE Condition");
}
dd("ALL FINE I AM GOING BACK TO VIEW WITH DATA");
}catch(\Exception $e){
dd("I GOT THIS ERROR : ".$e->getMessage());
}
}
I'm sure you'll able to fix problem by this.
As Narbil Farhan stated, the problem is in the line:
$category = Categorie::where('naam',$category)->first();
You seem to get no result from the Categorie table. First problem can be that the table does not exist, note that Laravel searches for the table 'Categories' (Searches for model name + s). You should probably catch the error if there is no data returned, like Nevermind23 suggested.
if(isset($category->id) && $category->id != ""){
$artikels = Artikel::where('category_id', $category->id)->get()
}
Personal note, try to prevent programming in your native language. This is harder for non Dutch speakings to understand your code.
There are multiple solutions:
Solution:
$category = Categorie::where('naam', $category)->first();
if(#category){
//you can get the $artikels belonging to the category
}
In this case, if there are no category with the respective name, $category will be null, and the code inside IF statement will not be executed.
Solution:
$category = Categorie::where('naam', $category)->firstOrFail();
//you can get the $artikels belonging to the category
In this case, if the Category is not found, an Illuminate\Database\Eloquent\ModelNotFoundException will be thrown. If the exception is not caught, a 404 HTTP response is automatically sent back to the user.
Solution: Route model binding - see the documentation
public function oversight(Categorie $category) {
return view('pages.oversight', ['category'=>$category]);
}
In this case, if there is no category with the respective name/id, a 404 HTTP response is automatically sent back to the user.
Also, I'd suggest you, to create a( most probably OneToMany) relationship between the Categorie and Artikel model. It will make your life much simpler :)

Blade is not Rendering Laravel

My page was working fine but I worked on different parts then returned to find it with only plain texts.
The extends line is working perfect with all other pages
What I tried so far:
Removed BOM and made sure that file is UTF-8
made sure #extends at the very start of the file
tried adding html tags
checked for any invalid characters
deleted the page and copy-pasted the code in a new one
made sure that other blade files in the same directory are working
the same so no parenting problem or a directory referencing problem
My blade page code (edit.blade.php):
#extends('layouts.app')
<body>
#section('content')
<div class="row col-md-9 col-lg-9 col-sm-9 float-left">
<div class="container">
<form method = "post" action = "{{route('companies.update',[$company->id]) }}">
{{csrf_field()}}
{{-- //work around to post --}}
<input type ="hidden" name= "_method" value = "put">
<div class="form-group">
<label for="comapny-name">Name</label>
<input type="string" class="form-control" name='name' id="comapny-name" aria-describedby="emailHelp" placeholder="Enter company name" required value="{{$company->name}}">
<small id="helpText" class="form-text text-muted">We'll never share your informations with anyone else but Khalood because he is the website devloper :).</small>
</div>
<div class="form-group">
<label for="company-content">Description</label>
<textarea name='description'style = "resize: vertical" class="form-control autosize-target text-left" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter description" rows="5" >
{{$company->description}}</textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
<div class="col-sm-3 col-md-3 col-lg-3 float-right">
<div class="sidebar-module">
<h4>Actions</h4>
<ol class="list-unstyled">
<li>View Companies</li>
<li>All Companies</li>
<li>Delete</li>
<li>Add new member</li>
</ol>
</div>
</div><!-- /.blog-sidebar -->
#endsection
</body>
Route code from the Controller:
public function edit($id)
{
$company = Company::where('id',$id )->first();
return view('companies.edit',['company'=>$company]);
}
Also the action line that transfer you to controller:
<li>Edit</li>
app.blade.php follows. It should be working fine because I'm extending it in many other pages and works fine.
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
{{-- adding the new theme css nad bootstraps we kedh --}}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
{{-- <title>Projects Managment Portal</title> --}}
{{-- <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
Not working favicon
--}}
<!-- Custom fonts for this template -->
<link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
<link href='https://fonts.googleapis.com/css?family=Kaushan+Script' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700' rel='stylesheet' type='text/css'>
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script>
<!-- Bootstrap core CSS -->
<link href="../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
{{-- Favicons css for the nav bar icons--}}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
</head>
<body>
<div id="app">
<nav class="navbar navbar-expand-md navbar-light navbar-laravel">
<div class="container">
<a class="navbar-brand" href="{{ url('/') }}"><i class="fab fa-product-hunt"></i>rojacker</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<!-- Left Side Of Navbar -->
<ul class="navbar-nav mr-auto">
</ul>
<!-- Right Side Of Navbar -->
<ul class="navbar-nav ml-auto">
<!-- Authentication Links -->
#guest
<li class="nav-item">
<a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
</li>
#else
<li class="nav-item">
<a class="nav-link" href="{{ url('/') }}"><i class="fas fa-home"></i> Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('companies.index') }}"><i class="far fa-building"></i> Companies</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('projects.index') }}"><i class="fas fa-project-diagram"></i> Projects</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('tasks.index') }}"><i class="fas fa-tasks"></i> Tasks</a>
</li>
{{-- Admin Panel --}}
#if (Auth::user()->role_id == 1)
<li class="dropdown">
<a id="navbarDropdown" class="nav-link dropdown" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
Admin Panel <span class="caret"></span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="nav-link" href="{{ route('projects.index') }}"><i class="far fa-building"></i>Projects</a>
<a class="nav-link" href="{{ route('projects.index') }}"><i class="far fa-building"></i>Projects</a>
<a class="nav-link" href="{{ route('projects.index') }}"><i class="far fa-building"></i>Projects</a>
</div>
</li>
#endif
<li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre><i class="far fa-user-circle"></i>
{{ Auth::user()->name }} <span class="caret"></span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();"><i class="fas fa-door-open"></i>
{{ __('Logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
#csrf
</form>
</div>
</li>
#endguest
</ul>
</div>
</div>
</div>
</nav>
<div class="container">
#include('partials.errors')
#include('partials.success')
<main class="py-4">
#yield('content')
</main>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="../../dist/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>
And web.php part containing companies part:
Route::middleware(['auth'])->group(function(){
// Creating Special Route to allow adding new project assigned to specific company id
Route::get('/projects/create/{company_id?}', 'ProjectsController#create');
Route::post('/projects/adduser/', 'ProjectsController#adduser')->name('projects.adduser');
Route::resource('companies','CompaniesController');
Route::resource('projects','ProjectsController');
Route::resource('roles','RolesController');
Route::resource('tasks','TasksController');
Route::resource('users','UsersController');
Route::resource('comments','CommentsController');
});
and link to image of page :
Page of the problem sceenshot
I FOUND THE SOLUTION !
it was in the app.blade.php when migrating to new design I (without noticing) got rid of the main css file and used only bootstrap file embedded in the new template, it works for the rest of the website ,but the edit page container (I don't know why specifically) needed the original native css file,just added it and it works like a charm!
Long Answer short, I was missing this line in the header of app.blade.php
<link href="{{ asset('css/app.css') }}" rel="stylesheet">

Sidebar causing vue error laravel

I need some help checking if there is anything wrong with my sidebar menu and also maybe the placing of where I put my sidebar inside my app.blade.php. Since every time I try to add it inside the app.blade.php, I will get a vue error which in this case I did not install vue or update laravel at all. In the past, my sidebar menu was working fine so the code should be okay, so I was thinking is it because of the positioning?
app.blade.php
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<body>
<div id="app">
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<!-- Collapsed Hamburger -->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse" aria-expanded="false">
<span class="sr-only">Toggle Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
#include('layouts.sidebar')
<!-- Branding Image -->
<a class="navbar-brand" href="{{ url('/') }}" style="color: white">
{{ config('app.name', 'Laravel') }}
</a>
</div>
<div class="collapse navbar-collapse" id="app-navbar-collapse">
<!-- Left Side Of Navbar -->
<ul class="nav navbar-nav">
</ul>
<div id="center-text">
<ul class="nav navbar-nav navbar-center" id="nav-center">
<li>
<h3>#yield('title')</h3>
</li>
</ul>
</div>
<!-- Right Side Of Navbar -->
<ul class="nav navbar-nav navbar-right">
<!-- Authentication Links -->
#guest
<li>Login</li>
<li>Register</li>
#else
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true" style="background-color:blue" style="color:white">
<b>{{ Auth::user()->name }}</b> <span class="caret"></span>
</a>
<ul class="dropdown-menu" style="background-color: blue">
<li>
<a href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();" style="background-color: blue" style="color: white">
<b>Logout</b>
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
</li>
</ul>
</li>
#endguest
</ul>
</div>
</div>
</nav>
#yield('content')
</div>
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}"></script>
</body>
</html>
sidebar.blade.php
<html>
<head>
<title>SideBar Menu</title>
<link href="{{ asset('css/style.css') }}" rel="stylesheet">
</head>
<body>
<div id="sidebar">
<ul>
<li>Summary</li>
<li>Deleted Records</li>
<li>Verification</li>
<li>Eval Test</li>
<li class="dropdown">
Edit User Information <span class="caret"></span>
<ul class="dropdown-menu forAnimate" role="menu">
<li>Personal Information Edit</li>
<li><a href="{{ url('/edit0')}}" style="color: red">Driver License
</ul>
</li>
<li class="dropdown">
Evaluation <span class="caret"></span>
<ul class="dropdown-menu forAnimate" role="menu">
<li>Evaluation</li>
<li>Shirt Size</li>
</ul>
</li>
</ul>
<div id="sidebar-btn">
<span></span>
<span></span>
<span></span>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#sidebar-btn').click(function(){
$('#sidebar').toggleClass('visible');
});
});
</script>
</body>
</html>

Using PHP include() inside Bootstrap 3 not working

Edited:
I am trying to use PHP include function to call "Navbar Header", "Navigation" and "Footer" section of my Bootstrap code, so that I do not have to make changes to all my HTML files when something changes in any of the above 3.
I am using Bootstrap 3.
Please assist me here, as I am not able to use the PHP functionality with Bootstrap 3. Thanks..
Below is my code:
--> index.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Test PHP</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link href="css/styles.css" rel="stylesheet">
</head>
<body>
<?php include("includes/header.html");?>
<?php include("includes/navigation.html");?>
<div class="container-fluid">
<!-- START Page Heading -->
<div id="page-wrapper">
<div class="container-fluid">
<!-- Page Heading -->
<div class="row">
<div class="col-lg-10">
<a><h1 class="page-header">Home </h1></a>
<ol class="breadcrumb">
<li class="active">
<i class="glyphicon glyphicon-home"></i> Home
</li>
</ol>
<div class="container">
<div class="jumbotron text-center">
<h1>Sample Website</h1>
<div class="row">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- END Page Heading -->
</div>
</div>
<?php include("includes/footer.html");?>
<!-- Script References -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/scripts.js"></script>
</body>
</html>
1) Navbar Header.html
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><strong>Sample Website</strong></a>
</div>
</div>
</div>
2) Navigation.html
<div class="container-fluid">
<div class="row">
<div class="col-sm-2">
<strong><i class="glyphicon glyphicon-home active"></i> HOME</strong>
<hr>
<ul class="nav nav-pills nav-stacked">
<li class="nav-header"></li>
<li><i class="glyphicon glyphicon-cloud"></i><strong> Overview</strong></li>
<li><i class="glyphicon glyphicon-picture"></i><strong> About</strong></li>
</ul>
<div class="clearfix"></div>
<hr>
<a><strong><i class="glyphicon glyphicon-user"></i> VIEW 1 </strong></a>
<hr>
<ul class="nav nav-stacked">
<li><a><i class="glyphicon glyphicon-list-alt"></i><strong> Type</strong></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel" style="display: block; position: static; margin-bottom: 5px; *width: 180px;">
<li class="dropdown-submenu">
<a tabindex="-1">Type1</a>
<ul class="dropdown-menu">
<li>Description</li>
<li class="divider"></li>
<li class="dropdown-submenu">
<!-- <li role="menu" class="dropdown-header">Schema Type</li> -->
<li class="dropdown-submenu">
<a tabindex="-1">Inner view1</a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<li>About</li>
<li class="divider"></li>
<li class="dropdown-submenu">
<a tabindex="-1">Detail</a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="detail1.html">Detail 1</a></li>
<li><a tabindex="-1" href="detail2.html">Detail 2</a></li>
</ul>
</li>
</ul>
</li>
<li class="dropdown-submenu">
<a tabindex="-1">Type2/a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<li>Description</li>
<li class="divider"></li>
<li class="dropdown-submenu">
<a tabindex="-1">Inner view 2</a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="idetail1.html">Detail 1</a></li>
<li><a tabindex="-1" href="idetail2.html">Detail 2</a></li>
</ul>
</li>
</ul>
</ul>
</li>
</ul>
</ul>
<hr>
</div>
</div>
3) Footer.html
<footer class="row">
<div class="container">
<div class="col-lg-4 col-lg-push-4 col-md-4 col-md-push-4 col-sm-4 col-sm-push-4 col-xs-12">
<div class="text-center">
<p>Copyright © 2015 <a href="http://www.banes.com" title="Banes">
<strong>Banes Ltd.</strong></a>
</p>
</div>
</div>
</div>
</footer>
You have too much duplication in your index.file. Code should only exist once. Look at your include lines and imagine the file being 'included' at that point...
Header.html
<html>
<head>
...tags...
</head>
<body>
Index.php
<?php include("includes/header.html");?>
<div class="container-fluid">
...stuff here..
</div>
<?php include("includes/footer.html");?>
Footer.html
<script>...</script>
<script>...</script>
</body>
</html>
You're including a whole page in every file.
The header footer and navigation files should only contain the parts of the html you want to include
So you have 4 head elements each calling in bootstrap.
This is never going to play nicely. Delete all of the tags in the partial files that do not contain markup specific to that page, and have one page with html>head>body structure that includes the parts of the other files

Categories