Extending Modules
Overwriting views
If you want to extend one of the modules and add new fields (or remove some) you will need to overwrite the views first. To do that just copy a view from the vendor folder to the resources folder:
Extending the user module
If you need to add more fields in the user module you first have to copy the user.blade.php from vendor/taffovelikoff/hotcoffee/resources/views/admin to resources/views/vendor/hotcoffee/admin and add your new field where you desire (for example right after "job title"):
<!-- Job Title -->
<div class="col-lg-6">
<div class="form-group">
<label class="form-control-label" for="input-last-name">{{ __('hotcoffee::admin.user_job') }}</label>
<div @if($errors->has('job_title')) class="has-danger" @endif>
<input type="text" name="job_title" id="input-last-name" class="form-control form-control-alternative @if($errors->has('job_title')) is-invalid-alt @endif" @if(session('post')) value="{{ session('post.job_title') }}" @elseif(isset($edit)) value="{{ $edit->address->job_title }}" @endif>
</div>
</div>
</div>
<!-- NEW FIELD -->
<!-- Phone -->
<div class="col-lg-6">
<div class="form-group">
<label class="form-control-label" for="input-phone">Phone Number</label>
<div @if($errors->has('phone')) class="has-danger" @endif>
<input type="text" name="phone" id="input-phone" class="form-control form-control-alternative @if($errors->has('phone')) is-invalid-alt @endif" @if(session('post')) value="{{ session('post.phone') }}" @elseif(isset($edit)) value="{{ $edit->address->phone}}" @endif>
</div>
</div>
</div>It's recommended to keep the user information in the user_address table, instead of the users table. Now create a migration to add the new fields to the table.
Now you need to publish the user configuration file:
In this file you can change some user configurations, but most importantly you can change the UserAddress namespace.
Now create a new UserAddress model and populate the fillable attribute.
If you need to do some validations you can add the rules and messages again in the users.php config file:
If you need to do something very specific you can copy the UserController.php from vendor/taffovelikoff/hotcoffee/src/Http/Controllers/Admin to app/Http/Controllers/Admin and re-define all the routes in your routes/web.php:
Now the admin panel will use the controller from the app/Http/Controllers/Admin folder, instead the one in vendor/taffovelikoff/hotcoffee/src/Http/Controllers/Admin meaning you can edit the controller.
Extending the article and info page modules
You can extend or change the article or info page modules in a very similar way.
You can create new models, that will extend the ones from the package.
Now change model in the configuration:
Last updated