Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Harman committed Aug 15, 2019
2 parents 6e2ae49 + 7b6b774 commit c352bec
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
6 changes: 4 additions & 2 deletions src/InertiaModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
use Illuminate\Database\Eloquent\Model;
use harmonic\InertiaTable\Traits\InertiaTable;

class InertiaModel extends Model {
class InertiaModel extends Model
{
use InertiaTable;

public function resolveRouteBinding($value) {
public function resolveRouteBinding($value)
{
return $this->where('id', $value)->withTrashed()->first() ?? abort(404);
}
}
37 changes: 21 additions & 16 deletions src/InertiaTableServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;

class InertiaTableServiceProvider extends ServiceProvider {
class InertiaTableServiceProvider extends ServiceProvider
{
protected $commands = [
'harmonic\InertiaTable\Commands\MakeInertiaTable',
];
Expand All @@ -15,7 +16,8 @@ class InertiaTableServiceProvider extends ServiceProvider {
*
* @return void
*/
public function boot() {
public function boot()
{
// $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'harmonic');
// $this->loadViewsFrom(__DIR__.'/../resources/views', 'harmonic');
// $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
Expand All @@ -24,18 +26,18 @@ public function boot() {
// Easily create all the inertia routes
Route::macro('inertia', function ($routeName) {
$routeName = strtolower($routeName);
$controller = ucfirst($routeName) . 'Controller';
$controller = ucfirst($routeName).'Controller';

Route::group([
'prefix' => '/' . $routeName,
'prefix' => '/'.$routeName,
], function () use ($controller, $routeName) {
Route::get('/')->name($routeName)->uses($controller . '@index')->middleware('remember');
Route::get('/create')->name($routeName . '.create')->uses($controller . '@create');
Route::post('/')->name($routeName . '.store')->uses($controller . '@store');
Route::get('/' . $routeName . '/edit')->name($routeName . '.edit')->uses($controller . '@edit');
Route::put('/' . $routeName . '')->name($routeName . '.update')->uses($controller . '@update');
Route::delete('/' . $routeName . '')->name($routeName . '.destroy')->uses($controller . '@destroy');
Route::put('/' . $routeName . '/restore')->name($routeName . '.restore')->uses($controller . '@restore');
Route::get('/')->name($routeName)->uses($controller.'@index')->middleware('remember');
Route::get('/create')->name($routeName.'.create')->uses($controller.'@create');
Route::post('/')->name($routeName.'.store')->uses($controller.'@store');
Route::get('/'.$routeName.'/edit')->name($routeName.'.edit')->uses($controller.'@edit');
Route::put('/'.$routeName.'')->name($routeName.'.update')->uses($controller.'@update');
Route::delete('/'.$routeName.'')->name($routeName.'.destroy')->uses($controller.'@destroy');
Route::put('/'.$routeName.'/restore')->name($routeName.'.restore')->uses($controller.'@restore');
});
});

Expand All @@ -50,8 +52,9 @@ public function boot() {
*
* @return void
*/
public function register() {
$this->mergeConfigFrom(__DIR__ . '/../config/inertiatable.php', 'inertiatable');
public function register()
{
$this->mergeConfigFrom(__DIR__.'/../config/inertiatable.php', 'inertiatable');

$this->commands($this->commands);

Expand All @@ -66,7 +69,8 @@ public function register() {
*
* @return array
*/
public function provides() {
public function provides()
{
return ['inertiatable'];
}

Expand All @@ -75,10 +79,11 @@ public function provides() {
*
* @return void
*/
protected function bootForConsole() {
protected function bootForConsole()
{
// Publishing the configuration file.
$this->publishes([
__DIR__ . '/../config/inertiatable.php' => config_path('inertiatable.php'),
__DIR__.'/../config/inertiatable.php' => config_path('inertiatable.php'),
], 'inertiatable.config');

// Publishing the views.
Expand Down

0 comments on commit c352bec

Please sign in to comment.