Looks like you just need one catch-all route and one controller to handle them all. The slugs should then be shared between custom pages and the blog posts/articles. An easy way to achieve that would be to hold them in a single table as well.
But how to distinguish between custom pages and blog posts? You could abstract the common settings into a Page model (such as id, slug, some meta data maybe), and then extend those into other types, such as Article, or a CustomPage.
The way I see it is through polymorphic relationships.
Tables:
"pages":
- id
- slug
- title
- pageable_id
- pageable_type
- (timestamps)
"articles":
- id
- content
...
"custom_pages":
- id
- content
...
Models:
class Page extends Model
{
public function pageable()
{
return $this->morphTo();
}
}
class Article extends Model
{
public function page()
{
return $this->morphOne('App\Page', 'pageable');
}
}
class CustomPage extends Model
{
public function page()
{
return $this->morphOne('App\Page', 'pageable');
}
}
Controller:
class HomeController extends Controller
{
public function show($slug)
{
$page = \App\Page::whereSlug($slug)->first();
$page->pageable; // <--- that would be your Article, or a CustomPage, depending on the `pageable_type` field in the `pages` table
}
}
Read more about polymorphic relationships - https://laravel.com/docs/5.7/eloquent-relationships#polymorphic-relationships