user9461267
user9461267

Reputation:

Laravel view doesn't show anything it'show blank

I have a view in the project but it doesn't show anything, I want to show data in the table but the page is blank.it was working yesterday but its just a blank page,don't know what happened, please help..

1.is it problem of route 2.database issue 3.html error

route

   <?php


Route::get('/', function () {
    return view('welcome');
});


Route::resource('books','BookController');
Route::resource('news','NewsController');
//Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');
Route::get('my-home', 'HomeController@myHome');

Route::get('my-users', 'HomeController@myUsers');

Route::get('/news','NewsController@index');
Route::get('/news','NewsController@create');

Index.blade.php

  @extends('theme.default')

@section('content')

    <div class="row">

        <div class="col-lg-12">

            <h1 class="page-header">ADVERTISEMENT DETAILS</h1>

        </div>

        <!-- /.col-lg-12 -->

    </div>

    <!-- /.row -->

    <div class="row">

        <div class="col-lg-3 col-md-6">

            <div class="panel panel-primary">

                <div class="panel-heading">

                    <div class="row">

                        <a href="#">

                            <div class="panel-footer">

                                <span class="pull-left">Create New News</span>

                                <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>

                                <div class="clearfix"></div>

                            </div>

                        </a>

                    </div>

                </div>


            </div>

        </div>

        <div class="row">
            <div class="col-md-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        Added News
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="table-responsive">
                                    <table class="table table-striped table-bordered table-hover"
                                           id="dataTables-example">
                                        <thead>
                                        <tr>
                                            <th>Slno</th>
                                            <th>News Name</th>
                                            <th>News Details</th>
                                            <th>News Link</th>
                                            <th>News Status</th>
                                            <th>EDIT</th>
                                            <th>DELETE</th>
                                        </tr>
                                        </thead>
                                        <?php $i = 1; ?>
                                        <tbody>

                                        @foreach($news as $news)

                                            <tr>

                                                <td>{{ $news->$id }}</td>
                                                <td>{{ $news->name }}</td>
                                                <td>{{ $news->news }}</td>
                                                <td>{{ $news->alink }}</td>
                                                @if($news->status==0)
                                                    <td>ACTIVE</td>
                                                @else
                                                    <td>INACTIVE</td>
                                                @endif
                                                <td><a href="{{route('news.edit',$news->id)}}"><input type="button"
                                                                                                      name="edit"
                                                                                                      value="EDIT"> </a>
                                                <td><input type="button" name="delete" value="DELETE"></td>
                                            </tr>

                                        @endforeach
                                        </tbody>


                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- /. PAGE INNER  -->
    </div>

@endsection

my controller function

<?php

namespace App\Http\Controllers;

use App\News;
use Illuminate\Http\Request;

class NewsController extends Controller
{

    public function index()
    {
        $news=News::all();
        return view('news.index',['news'=>$news]);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
//        return view('news.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\News  $news
     * @return \Illuminate\Http\Response
     */
    public function show(News $news)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\News  $news
     * @return \Illuminate\Http\Response
     */
    public function edit(News $news)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\News  $news
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, News $news)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\News  $news
     * @return \Illuminate\Http\Response
     */
    public function destroy(News $news)
    {
        //
    }
}

Upvotes: 0

Views: 4036

Answers (6)

Kenneth Sunday
Kenneth Sunday

Reputation: 895

Try to delete the cache stored in the storage -> framework -> cache folder

if still fails, Try to call composer dump-autoload via your cmd to reload your soure code.

Upvotes: 0

Prashant Prajapati
Prashant Prajapati

Reputation: 1015

Your route are replaced by the second route thats why its show empty page because your create() dosn't do anything i.e empty page.

I would suggest you to rename create route as below Try below code :

Route::get('/news','NewsController@index');
Route::get('/news/create','NewsController@create');

Upvotes: 0

Sohel0415
Sohel0415

Reputation: 9853

Remove these lines as you have already declared resource routing:

Route::get('/news','NewsController@index');
Route::get('/news','NewsController@create');

Upvotes: 0

Wreigh
Wreigh

Reputation: 3297

You have overlapping route definitions:

Route::get('/news','NewsController@index');
Route::get('/news','NewsController@create');

The latter is being used.

Probably change the latter to something like:

Route::get('/news/create', 'NewsController@create');

Upvotes: 2

AddWeb Solution Pvt Ltd
AddWeb Solution Pvt Ltd

Reputation: 21681

Problem with your route.Because once you use resource and then use declare the route as a get, First you clear what route you are using.

Here below is the when resource using , example below.

http://www.expertphp.in/article/laravel-5-5-crud-create-read-update-delete-example-from-scratch

Upvotes: 0

Jack Millers
Jack Millers

Reputation: 25

If it doesn't show anything Laravel's error reporting features are probably turned off. Because almost always it says what's wrong. Maybe you should look in to that first.

Upvotes: 0

Related Questions