Download the PHP package te7a-houdini/laravel-applicant without Composer
On this page you can find all versions of the php package te7a-houdini/laravel-applicant. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download te7a-houdini/laravel-applicant
More information about te7a-houdini/laravel-applicant
Files in te7a-houdini/laravel-applicant
Package laravel-applicant
Short Description Simple package to allow model applies and receives applications from other models
License MIT
Homepage https://github.com/Te7a-Houdini/laravel-applicant
Informations about the package laravel-applicant
Simple package to allow model applies and receives applications from other models.
for example it will allow you to do something like this:
- Installation
- Usage
- Using Applicant trait
- Using model for creating applications
- Using array for creating applications
- Using null for creating applications
- Using hasAppliedFor()
- Using appliedApplicationsFor()
- Using appliedApplications()
- Using applicantCriteria Attribute
- Using setApplicantCriteria()
- Using ReceivesApplications trait
- Using model for processing applications
- Using array for processing applications
- Using hasReceivedApplicationFrom()
- Using receivedApplicationsFrom()
- Using receivedApplications()
- Using receiverCriteria Attribute
- Using setReceiverCriteria()
- Testing
Installation
You can install the package via composer:
Then publish the configurations and migrations:
After the migration has been published then run the migrations to create required tables:
Usage
let's assume we have User model
& Group model
.
Using Applicant trait
to allow model behaves as applicant add Te7aHoudini\LaravelApplicant\Traits\Applicant
trait to your model
to make User
model applies for Group
model and creates a new application
record in applications
table . we can do this by different ways:
Using model for creating applications
if you didn't specify any application type or status. by default the type
will be applicant
and status
wil be created
Using array for creating applications
in some cases you won't have a model object , but want to manually specify the attributes when creating application.
Using null for creating applications
if you don't want to specify a model for creating applications then no problem.
Using hasAppliedFor()
if we want to check if model has made an application for another model. then we can achieve that with different ways.
note: like appliesFor() the hasAppliedFor() accepts same parameters
Using appliedApplicationsFor()
if you want to get current model applied applications you can do like this:
note: like appliesFor() the appliedApplicationsFor() accepts same parameters
Using appliedApplications()
this is a morphMany relation between current model and Application
model
Using applicantCriteria Attribute
some models maybe applies for specific application type
or status
, so to make it easy for overriding default application type
and status
. just define applicantCriteria
attribute in your model
Using setApplicantCriteria()
if you want to set the applicant criteria dynamically per model. you can do this.
Using ReceivesApplications trait
to allow model behaves as receiver add Te7aHoudini\LaravelApplicant\Traits\ReceivesApplications
trait to your model
to make Group
model process application from User
model and update existing application
record in applications
table . we can do this by different ways:
Using model for processing applications
if you didn't specify any application type or status. by default will query of type
will applicant
and status
of created
Using array for processing applications
in some cases you won't have a model object , but want to manually specify the attributes when processing application.
Using hasReceivedApplicationFrom()
if we want to check if model has received an application from another model. then we can achieve that with different ways.
note: like processApplicationFrom() the hasReceivedApplicationFrom() accepts same parameters except the last parameter of newStatus
Using receivedApplicationsFrom()
if you want to get current model received applications you can do like this:
note: like processApplicationFrom() the receivedApplicationsFrom() accepts same parameters except the last parameter of newStatus
Using receivedApplications()
this is a morphMany relation between current model and Application
model
Using receiverCriteria Attribute
some models maybe applies for specific application type
or status
, so to make it easy for overriding default application type
and status
. just define receiverCriteria
attribute in your model
Using setReceiverCriteria()
if you want to set the receiverCriteria criteria dynamically per model. you can do this.
Testing
Changelog
Please see CHANGELOG for more information what has changed recently.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Ahmed Abd El Ftah
- All Contributors
License
The MIT License (MIT). Please see License File for more information.