all. I have problems after making some new steps. I'm rails developer, but now i have to do some support in php/laravel project. After making some UI + backend in project(adding OpenGraph in project + admin) - i made a command - php artisan migrate:fresh. And now i have this code error.
(1/1) ErrorException Trying to get property 'title' of non-object
in MainController.php line 78
MetaTag.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
/**
* App\Setting
*
* @mixin \Eloquent
*/
class MetaTag extends Model
{
/**
* @var array
*/
protected $table = "meta_tags";
protected $fillable = ['title', 'description', 'keywords','og_type','og_title','og_description'];
}
part of MainController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Jenssegers\Agent\Agent;
use App\Http\Requests;
class MainController extends Controller
{
public function index()
{
$main_banner = \App\Banner::where('type', '1')
->where('page', '1')
->where('active', '1')
->orderBy('order', 'asc')
->first();
$premium_blocks = \App\Banner::where('type', '2')
->where('active', '1')
->orderBy('order', 'asc')
->get();
$active_animations = \App\Setting::where('alias', 'anumations_active')->first();
$active_films = \App\Setting::where('alias', 'films_active')->first();
$active_games = \App\Setting::where('alias', 'games_active')->first();
$active_heroes = \App\Setting::where('alias', 'heroes_active')->first();
$active_news = \App\Setting::where('alias', 'news_active')->first();
$active_soundtracks = \App\Setting::where('alias', 'soundtracks_active')->first();
$animations = \App\Animation::where('active', '1')
->orderBy('order', 'asc')
->get();
$films = \App\Film::where('active', '1')
->where('checked', '1')
->orderBy('order', 'asc')
->get();
$games = \App\Game::where('active', '1')
->where('checked', '1')
->orderBy('order', 'asc')
->get();
$heroes = \App\Hero::where('active', '1')
->where('checked', '1')
->orderBy('order', 'asc')
->get();
$news = \App\News::where('active', '1')
->where('checked', '1')
->orderBy('order', 'asc')
->get();
$soundtracks = \App\Soundtrack::where('active', '1')
->where('checked', '1')
->orderBy('order', 'asc')
->get();
$arr_month_rus = \Config::get('settings.arr_month_rus');
$arr_month_rus_lower = \Config::get('settings.arr_month_rus_lower');
$arr_games_types = \Config::get('settings.arr_games_types');
$arr_news_types = \Config::get('settings.arr_news_types');
$agent = new Agent();
$browser = $agent->browser();
$v = explode('.',$agent->version($agent->browser()));
$version = $v[0];
if (
($browser == "Internet Explorer" && $version > 10) ||
($browser == "Edge" && $version > 11) ||
($browser == "Firefox" && $version > 46) ||
($browser == "Opera" && $version > 38) ||
($browser == "Safari" && $version > 8) ||
($browser == "Chrome" && $version > 51)
)
$outdated = false;
else $outdated = true;
$meta_tags = \App\MetaTag::where('alias', '=', 'main_page')->first();
$title = $meta_tags->title;
$description = $meta_tags->description;
$keywords = $meta_tags->keywords;
$og_title = $meta_tags->og_title;
$og_description = $meta_tags->og_description;
$og_type = $meta_tags->og_type;
return view((($agent->isMobile()) ? 'mobile.home' : 'home'), compact(
'main_banner',
'premium_blocks',
'animations',
'films',
'games',
'heroes',
'news',
'soundtracks',
'active_animations',
'active_films',
'active_games',
'active_heroes',
'active_news',
'active_soundtracks',
'arr_games_types',
'arr_month_rus_lower',
'arr_news_types',
'arr_month_rus',
'outdated',
'title',
'description',
'keywords',
'og_title',
'og_type',
'og_description'
));
}
I expect just solve this little problem. Thanks!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire