Laravel 5.4 make:auth logging out in refresh or view change

So I have a problem which is very confusing.

I make authentication with php artisan make:auth. And I only change the controller in the router and the redirect in the LoginController as the documentation write. Before it is working perfectly but now it has a big problem. After I refresh the page or go to an other view it’s loout all the time.

I red a lot of stackoverflow question and answer but those not helped me out as well.


Source: stackoverflow-php

found error in laravel 5.4, Trying to get property of non-object

In the admin area, I am trying to display the products in a listing page. Each product has category, color, size and type of the material
My tables structure

categories
id   | category_name  
1    | Cat1  
2    | Cat2 

colors
id   |  color_name  
1    |  Color1   
2    |  Color2

materials
id   | material_type  
1    | material1  
2    | material2 

 sizes
id   | size_name  
1    | size1  
2    | size2 

My product table

products
id  name  description category_id  color_id   material_id   size_id
1   pro1  product 1        1          1           1            1
2   pro2  product 2        2          2           2            2

Category Model

namespace App;

use IlluminateDatabaseEloquentModel;
use AppProduct;


class Category extends Model
{
    protected $table = 'categories';

    public function products(){
      return $this->hasOne(Product::class);
    }
}

color, size and material Models have the same structure

namespace App;

use IlluminateDatabaseEloquentModel;
use AppProduct;

class Color extends Model
{
    protected $table = 'colors';
    public function products(){
      return $this->hasMany(Product::class);
    }
}

In the product controller, I have the following index function to display the products

public function index()
    {
      $products = Product::with('categories', 'colors' , 'sizes', 
      'materials', 'fantasias')->get();
      return view('backend.product.product-library', compact('products'));
    }

I would like the output to be

products
name  description  category   color    material   size 
pro1  product 1      cat1    color1    mateial1   size1
pro2  product 2      cat2    color2    material2  size2

My View is

  @foreach( $products as $item )
      <tbody>
        <tr>
          <td class="thumbnail" ><img src="{!! '/images/product-feature/'.$item->product_preview !!}" alt=""></td>
          <td><h3>{{ $item->product_name }}</h3></td>
          <td><p>{{ $item->product_description }}</p></td>
          <td><p>{{ $item->categories->category_name }}</p></td>
          <td><p>{{ $item->colors->color_name }}</p></td>
          <td><p>{{ $item->materials->color_name }}</p></td>
          <td><p>{{ $item->sizes->color_name }}</p></td>
          <td rowspan="2">
            <a class="btn transparent" href="{{ route('products.edit', ['product'=>$item->id]) }}">Edit</a>
            <form action="{{ route('products.destroy', ['product'=>$item->id]) }}" method="POST" enctype="multipart/form-data">
              <input name="_method" type="hidden" value="DELETE">
              <button type="submit" class="btn transparent">Delete</button>
              <input type="hidden" name="_token" value="{{Session::token()}}">
            </form>
          </td>
        </tr>
      </tbody>
    @endforeach

The following error appears

ErrorException in b5a959a09cc5b7e6abf71778d058119094681a2d.php line 28:
Trying to get property of non-object (View: /var/www/html/pet/resources/views/backend/product/product-library.blade.php)

Thank you so much for the help,


Source: stackoverflow-php

List all the users with the count of drivers they registered

i have tow models Userand Driver the user can register any number of drivers drivers

in drivers table i have agent_id, i want to list all the users with the count of the drivers they registered

in my Usercontroller i want to get the count of the drivers registered by the agents

public function index(Request $request) 
{
    $users = User::all();

    $registration_centers = RegistrationCenter::all();

    $drivers_registered = Driver::where('agent_id' , $agent_id)->count();  //something like this but i don't have agent_id to query with

    return view('agents', compact('users', 'registration_centers', drivers_registered));
}

thank you


Source: stackoverflow-php