1573082685s:7931:"<h1>Version 1.1.1</h1>
<hr />
<ul>
<li><a href="#section-1">Overview</a></li>
<li><a href="#section-2">Features</a></li>
<li><a href="#section-3">Procedures</a>
<ul>
<li><a href="#section-4">Licence</a></li>
</ul></li>
</ul>
<h2>Overview</h2>
<blockquote>
<p>{info} For version 1.1.1, licence product has been introduced and password expiry has been implemented.</p>
</blockquote>
<p><a name="section-2"></a></p>
<h2>Features Introduced</h2>
<li>Licence</li>
<li>Password Expiry</li>
<p><a name="section-3"></a></p>
<h2>Migration</h2>
<p>Run <code>php artisan migrate</code>
<br>
This command will create licence table and add new columns in users table.
<br>
Add new columns in the Model in User &amp; Licence file.</p>
<p>Now make changes in <code>AuthenticatesUsers.php</code>
Copy &amp; paste below codes:</p>
<pre><code class="language-php">    protected function authenticated(Request $request, $user)
    {
        switch (Auth::user()-&gt;role_id) {
            case '1':
                $user = new Logins();
                $user-&gt;ip = $request-&gt;getClientIp();
                $user-&gt;login_type = 'WEB';
                $user-&gt;user_id = Auth::user()-&gt;id;
                $user-&gt;login_date = date('d-m-Y h:i:s A');
                $user-&gt;save();

                break;

            case '2':
                $user = new Logins();
                $user-&gt;ip = $request-&gt;getClientIp();
                $user-&gt;login_type = 'WEB';
                $user-&gt;user_id = Auth::user()-&gt;id;
                $user-&gt;login_date = date('d-m-Y h:i:s A');
                $user-&gt;save();
                break;  

            case '3':
                $user = new Logins();
                $user-&gt;ip = $request-&gt;getClientIp();
                $user-&gt;login_type = 'API';
                $user-&gt;user_id = Auth::user()-&gt;id;
                $user-&gt;login_date = date('d-m-Y h:i:s A');
                $user-&gt;save();
                break;         
        }

        //Check password expiry
        if(ConfigController::check_password_expiry(Auth::user()-&gt;id))
        {
            $password = User::find(Auth::user()-&gt;id);
            $password-&gt;reset = 'on';
            $password-&gt;save();
        }

    }</code></pre>
<p><br>
ConfigController</p>
<pre><code class="language-php">    public function view_licence(Request $request){
        if(ConfigController::check_privilege('ACCESS_LICENCE_MENU'))
        {
            $licences = Licence::all();

            if($request-&gt;ajax()) 
            {
                $view = view('licence.data',compact('licences'))-&gt;render();

                return response()-&gt;json(['html'=&gt;$view]);
            }

            return view('licence.list',compact('licences'));
        }
        else
        {
            return view('errors.not_authorized');
        }
    }

    public function add_licence(Request $request)
    {
        if(ConfigController::check_privilege('ACCESS_LICENCE_MENU'))
        {
            $this-&gt;validate($request,[
                    'licence_type'        =&gt;        'required',
                    'number_authorized'   =&gt;        'required'
                ]);

            try
            {

                $licence = new Licence;
                $licence-&gt;type = $request-&gt;licence_type;
                $licence-&gt;number_allowed = $request-&gt;number_authorized;
                $licence-&gt;updated_by = Auth::user()-&gt;id;
                $licence-&gt;created_by = Auth::user()-&gt;id;
                $licence-&gt;save();

                return response()-&gt;json(['success'=&gt;'Licence added successfully.']);

            }
            catch(\Exception $e)
            {
                Log::ERROR('=============ADD LICENCE ERROR ================');
                Log::ERROR($e);
                Log::ERROR('=============ADD LICENCE ERROR END ================');
                return response()-&gt;json(['error'=&gt;'Sorry, Something went wrong. Please contact Admin.']);
            }

        }
        else
        {
            return response()-&gt;json(['unauthorized_access'=&gt;'Sorry, you do not have access to this service. Please contact Admin.']);
        }
    }

    public function edit_licence(Request $request)
    {
        if(ConfigController::check_privilege('ACCESS_LICENCE_MENU'))
        {
            $this-&gt;validate($request,[
                    'licence_type'        =&gt;        'required',
                    'number_authorized'   =&gt;        'required'
                ]);

            try
            {

                $licence = Licence::find($request-&gt;id);
                $licence-&gt;type = $request-&gt;licence_type;
                $licence-&gt;number_allowed = $request-&gt;number_authorized;
                $licence-&gt;updated_by = Auth::user()-&gt;id;
                $licence-&gt;save();

                return response()-&gt;json(['success'=&gt;'Licence edited successfully.']);

            }
            catch(\Exception $e)
            {
                Log::ERROR('=============EDIT LICENCE ERROR ================');
                Log::ERROR($e);
                Log::ERROR('=============EDIT LICENCE ERROR END ================');
                return response()-&gt;json(['error'=&gt;'Sorry, Something went wrong. Please contact Admin.']);
            }

        }
        else
        {
            return response()-&gt;json(['unauthorized_access'=&gt;'Sorry, you do not have access to this service. Please contact Admin.']);
        }
    }

    public function delete_licence(Request $request)
    {
        if(ConfigController::check_privilege('ACCESS_LICENCE_MENU'))
        {

            try
            {

                $licence = Licence::find($request-&gt;id);
                $licence-&gt;updated_by = Auth::user()-&gt;id;
                $licence-&gt;save();//update
                $licence-&gt;delete();//delete

                return response()-&gt;json(['success'=&gt;'Licence edited successfully.']);

            }
            catch(\Exception $e)
            {
                Log::ERROR('=============Delete LICENCE ERROR ================');
                Log::ERROR($e);
                Log::ERROR('=============Delete LICENCE ERROR END ================');
                return response()-&gt;json(['error'=&gt;'Sorry, Something went wrong. Please contact Admin.']);
            }

        }
        else
        {
            return response()-&gt;json(['unauthorized_access'=&gt;'Sorry, you do not have access to this service. Please contact Admin.']);
        }
    }

    public static function check_licence($type)
    {
        $licences = Licence::select('number_allowed')-&gt;where('type',$type)-&gt;get();

        $number_allowed = 0;
        if(count($licences) == '1')
        {
            foreach($licences as $licence)
            {
                $number_allowed = $licence-&gt;number_allowed;
                return $number_allowed;
            }

        }
    }

    public static function check_password_expiry($user_id)
    {

        $days = ConfigController::check_licence('password');

        $user = User::find($user_id);

        $password_changed_at = $user-&gt;password_changed_at;

        $password_expiry = date('Y-m-d', strtotime($password_changed_at. ' + '.$days.' day'));

        $today = date("Y-m-d");

        if($password_expiry &gt;= $today){
            return true;
        }
        else{
            return false;
        }
    }</code></pre>
<p><br></p>
<p>Add below routes on <code>web.php</code> route</p>
<pre><code class="language-php">
//Licence
Route::get('/licence.list','ConfigController@view_licence');
Route::post('/licence.add','ConfigController@add_licence');
Route::post('/licence.edit','ConfigController@edit_licence');
Route::post('/licence.delete','ConfigController@delete_licence');</code></pre>";