for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Install GitHub App
<?php
namespace App\Console\Commands;
use App\Classes\Repositories\MenuRepository;
use App\Classes\Repositories\PageRepository;
use App\Model\Link;
use App\Model\Menu;
use App\Model\Page;
use Illuminate\Console\Command;
class UpgradePageMenuLinks extends Command
{
private $menus;
private $pages;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'upgrade:page_links';
* The console command description.
protected $description = 'Upgrade for version 5.0.1';
* Create a new command instance.
* @return void
@return
Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.
Please refer to the PHP core documentation on constructors.
public function __construct(PageRepository $pages, MenuRepository $menus)
parent::__construct();
$this->pages = $pages;
$this->menus = $menus;
}
* Execute the console command.
* @return mixed
public function handle()
/** @var Menu $menu */
foreach($this->menus->all() as $menu)
$link = new Link;
/** @var Page $page */
$page = $this->pages->whereID($menu->page_id);
if ($menu->getAttribute('parent_id'))
$prefix = str_slug($menu->parent->title);
else
$prefix = "";
$page->setAttribute('prefix', $prefix)->save();
$link->connect($menu, $page)->save();
$this->info($menu->title . " => " . $page->getAttribute('seo_title') . " (" . $page->getAttribute('prefix') . "/" . $page->getAttribute('slug') . ")");
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.