Skip to content
This repository was archived by the owner on Jan 10, 2020. It is now read-only.
This repository was archived by the owner on Jan 10, 2020. It is now read-only.

How can i extend blog, default quarx module, by adding and displaying blog categories ? #75

@Mariana-Marica

Description

@Mariana-Marica

I need to add image, author, blog category, comments to blog, etc.
I am not sure what can i do to add blog categories (dynamically) to blog & display them, because:

  • i need in admin panel (when creating/editing a blog) to have loaded all blog categories(in a select) that previously are defined in a new custom module; i tried to find a way by doing these:
    • add select directly in files from resources/views/vendor/quarx/modules but this means that after updating & publishing quarx, all modifs will be discarded;
    • try to add dynamically values to select config/quarx.php (this does not work because here is no database connexion) and cannot do this:
     'category' => [
                'type' => 'select',
                'options' => Quarx\Modules\Blogcategories\Models\Blogcategory::pluck('name', 'id')->toArray()
            ],
    
    • i ended up trying to override blog create method in a my blog controller, with the outcome of writing dynamically in config file the blog categories, but i can't override the create route for blog (to call method from my controller), as nothing happens:
 $blogCategories = Blogcategory::pluck('name', 'id')->toArray();
 $blogCategories->each(function($value, $key) {
             Illuminate\Support\Facades\Config::set('quarx.forms.blog.category.options', [$value, $key]);
         });

and

Route::group(['prefix' => 'quarx'], function () {
    Route::group(['middleware' => ['auth', 'quarx']], function () {
        Route::resource('blog', \App\Http\Controllers\Quarx\BlogController::class, ['as' => 'quarx', 'except' => ['show']]);
        Route::post('blog/search', 'BlogController@search');
        Route::get('blog/{id}/history', 'BlogController@history');
    });
});
  • i also need to retrieve all blog categories for front display, thus using
    $blog = $this->blogRepository->findBlogsByURL($url);
    in show method from controller ; in this way i end up using BlogRepository from vendor and the method findBlogsByUrl returns blog or translated blog & also uses Blog vendor model which does not have the relation with custom module BlogCategories;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions