app/Console/Commands/SwitchCategory.php
/**
     * Execute the console command.
     *
     * @return mixed
     */
Execute the console command.
@return mixed
Execute the console command . @return mixed
public function handle()
    {
        $categories = Link::where('lin_citid',0)->get();
        foreach($categories as $category){
            $category_old = Category::find($category->lin_catid);
            if($category_old){
                $category->lin_short_title = $category_old->cat_meta_title;
                $category->lin_length = strlen($category_old->cat_rewrite);
                $category->lin_md5 = md5($category_old->cat_rewrite);
                $category->lin_rewrite = $category_old->cat_rewrite;
                $category->lin_keyword = $category_old->cat_index_keyword;
                $category->lin_all_parent = $category_old->cat_parent_id;
                $category->lin_parentid = $category_old->cat_parent_id;
                $category->save();
            }
        }
    }
public function handle ( ) { $ categories = Link :: where ( 'lin_citid' , 0 ) -> get ( ) ; foreach ( $ categories as $ category ) { $ category_old = Category :: find ( $ category -> lin_catid ) ; if ( $ category_old ) { $ category -> lin_short_title = $ category_old -> cat_meta_title ; $ category -> lin_length = strlen ( $ category_old -> cat_rewrite ) ; $ category -> lin_md5 = md5 ( $ category_old -> cat_rewrite ) ; $ category -> lin_rewrite = $ category_old -> cat_rewrite ; $ category -> lin_keyword = $ category_old -> cat_index_keyword ; $ category -> lin_all_parent = $ category_old -> cat_parent_id ; $ category -> lin_parentid = $ category_old -> cat_parent_id ; $ category -> save ( ) ; } } }
Execute the console command.
Execute the console command .