Last active
August 29, 2015 14:13
-
-
Save davidhemphill/28af11ef71c12cc8f462 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Currently, you just register your model namespace, and Bumble loops through the folder | |
and makes a list of models that way. I'm moving it to where the user has to register | |
the models they want to show. It's more reliable/explicit that way. | |
The question is now how to associate the Admin class with the Model. In this first | |
example, behind the scenes I was decorating the model with the admin class and forwarding any | |
call that wasn't on the admin class to the model. That would theoretically allow me | |
to act like an Admin class was a model. However it's problematic. | |
*/ | |
// Config | |
return [ | |
'page' => [ | |
'Monarkee\Models\Page' => 'Monarkee\ModelAdmin\PageAdmin' | |
], | |
// Or this | |
['Monarkee\Models\Page' => 'Monarkee\ModelAdmin\PageAdmin'] | |
]; | |
// ================================================================ | |
/* | |
Here's the second approach. Smaller configuration. Instead of decorating I just maintain | |
an admin property on the model and the user implements a bumble() method which points | |
to the admin class. This means I can use the Eloquent class like before and requires | |
a lot less hand holding. | |
*/ | |
// Config | |
return [ | |
'page' => 'Monarkee\Models\Page' | |
]; | |
// Model | |
public function bumble() | |
{ | |
return $this->hasAdmin('Monarkee\ModelAdmin\PageAdmin'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Page extends BumbleModel | |
{ | |
public function bumble() | |
{ | |
return $this->hasAdmin('Monarkee\ModelAdmin\PageAdmin'); | |
} | |
} |
I.e. the admin has knowledge of the model but the model doesn't have knowledge of the admin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do we ever need to know that a particular Model has a particular Admin? Or can an admin HaveModel and then all the system cares about is the Admin classes?