Added email and password reset
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
|
||||
use App\Models\SiteDetails;
|
||||
|
||||
@@ -40,16 +42,29 @@ class AdminHomeController extends Controller
|
||||
|
||||
} else {
|
||||
try {
|
||||
if ($key == 'site_logo' AND $value instanceof UploadedFile)
|
||||
{
|
||||
$path = $value->storePubliclyAs('site/'.config('SITE_SETUP')->id,$value->getClientOriginalName());
|
||||
|
||||
SiteDetails::updateOrCreate([
|
||||
'site_id'=>config('SITE_SETUP')->id,
|
||||
'key'=>$key,
|
||||
],[
|
||||
'value'=>$path,
|
||||
]);
|
||||
|
||||
} else {
|
||||
// Update or create our config record.
|
||||
SiteDetails::updateOrCreate([
|
||||
'site_id'=>config('SITE_SETUP')->id,
|
||||
'key'=>$key,
|
||||
],[
|
||||
'value'=>$value,
|
||||
]);
|
||||
}
|
||||
|
||||
// Update or create our config record.
|
||||
SiteDetails::updateOrCreate([
|
||||
'site_id'=>config('SITE_SETUP')->id,
|
||||
'key'=>$key,
|
||||
],[
|
||||
'value'=>$value,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
dd($e);
|
||||
Log::debug($e->getMessage(),['k'=>$key,'v'=>$value]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -29,4 +29,9 @@ class ForgotPasswordController extends Controller
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
public function showLinkRequestForm()
|
||||
{
|
||||
return view('adminlte::auth.passwords.email');
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
@@ -36,4 +37,11 @@ class ResetPasswordController extends Controller
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
public function showResetForm(Request $request, $token = null)
|
||||
{
|
||||
return view('adminlte::auth.passwords.reset')->with(
|
||||
['token' => $token, 'email' => $request->email]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ class Invoice extends Model
|
||||
{
|
||||
protected $table = 'ab_invoice';
|
||||
protected $dates = ['date_orig','due_date'];
|
||||
protected $with = ['items.taxes','items.product','items.service','account.country.currency','paymentitems'];
|
||||
protected $with = ['account.country.currency','items.product','items.service','items.taxes','paymentitems'];
|
||||
|
||||
protected $appends = [
|
||||
'date_due',
|
||||
|
@@ -12,16 +12,16 @@ class InvoiceItem extends Model
|
||||
|
||||
private $_tax = 0;
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo(Invoice::class);
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
|
@@ -39,31 +39,54 @@ class Site extends Model
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$detail = $this->details->where('key',$key)->first();
|
||||
$detail = $this->getSiteDetailValue($key);
|
||||
|
||||
if ($detail) {
|
||||
return $detail->value;
|
||||
}
|
||||
return $detail->exists ? $detail->value : $this->getDefaultValue($key);
|
||||
}
|
||||
|
||||
// Suppress some default values
|
||||
$optional = [
|
||||
'block_quotes',
|
||||
'clients',
|
||||
'page_tabs',
|
||||
'services',
|
||||
'site_description',
|
||||
'site_fax',
|
||||
private function getDefaultValue($key)
|
||||
{
|
||||
$okblank = [
|
||||
'site_address2',
|
||||
'site_slider',
|
||||
'steps',
|
||||
'testimonials',
|
||||
'site_fax',
|
||||
'social',
|
||||
'top_menu'
|
||||
];
|
||||
|
||||
if (in_array($key,$optional))
|
||||
return '';
|
||||
if (! in_array($key,$okblank))
|
||||
Log::alert('Returning Default Value for Key:',['key'=>$key]);
|
||||
|
||||
Log::alert('Calling unknown Site Key:',['key'=>$key]);
|
||||
return array_get($this->_sampledata(),$key);
|
||||
// Suppress some default values
|
||||
$default = [
|
||||
'block_quotes' => '',
|
||||
'clients' => '',
|
||||
'page_tabs' => '',
|
||||
'services' => '',
|
||||
'site_description' => '',
|
||||
'site_fax' => '',
|
||||
'site_address2' => '',
|
||||
'site_slider' => '',
|
||||
'social' => [],
|
||||
'steps' => '',
|
||||
'testimonials' => '',
|
||||
'top_menu' => [],
|
||||
];
|
||||
|
||||
return array_get($default,$key);
|
||||
}
|
||||
|
||||
public function getSiteLogoAttribute()
|
||||
{
|
||||
$return = $this->getSiteDetailValue('site_logo')->value;
|
||||
|
||||
return $return ? 'storage/'.$return : '/image/generic/150/20/fff';
|
||||
}
|
||||
|
||||
private function getSiteDetailValue($key)
|
||||
{
|
||||
$return = $this->details->where('key',$key)->first();
|
||||
|
||||
return $return ?: (new SiteDetails);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,10 +192,7 @@ class Site extends Model
|
||||
//'button'=>['text'=>'Purchase Now','url'=>'#'],
|
||||
],
|
||||
],
|
||||
'site'=>[
|
||||
'id'=>NULL,
|
||||
'logo'=>route('image',['width'=>128,'height'=>32,'color'=>'eee']),
|
||||
],
|
||||
'site_logo'=>route('image',['width'=>128,'height'=>32,'color'=>'eee']),
|
||||
'site_address1'=>'Building Name',
|
||||
'site_address2'=>NULL,
|
||||
'site_city'=>'City',
|
||||
@@ -237,7 +257,7 @@ class Site extends Model
|
||||
|
||||
public function sample()
|
||||
{
|
||||
return $this->forceFill(array_get($this->_sampledata(),'site'));
|
||||
return $this->forceFill($this->_sampledata());
|
||||
}
|
||||
|
||||
public function aboutus()
|
||||
@@ -279,9 +299,4 @@ class Site extends Model
|
||||
return join("\n",$this->_address());
|
||||
}
|
||||
}
|
||||
|
||||
public function logo_url()
|
||||
{
|
||||
return url($this->logo ? $this->logo : '/image/generic/150/20/fff');
|
||||
}
|
||||
}
|
||||
}
|
52
app/Notifications/ResetPasswordNotification.php
Normal file
52
app/Notifications/ResetPasswordNotification.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class ResetPasswordNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public $token;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($token)
|
||||
{
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$logo = config('SITE_SETUP')->site_logo;
|
||||
$site_name = config('SITE_SETUP')->site_name;
|
||||
$reset_link = route('password.reset', $this->token, true);
|
||||
|
||||
return (new MailMessage)
|
||||
->markdown('email.user.passwordreset',compact('logo','site_name','reset_link'));
|
||||
}
|
||||
}
|
10
app/User.php
10
app/User.php
@@ -8,6 +8,7 @@ use Laravel\Passport\HasApiTokens;
|
||||
|
||||
use Leenooks\Carbon;
|
||||
use Leenooks\Traits\UserSwitch;
|
||||
use App\Notifications\ResetPasswordNotification;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
@@ -164,14 +165,19 @@ class User extends Authenticatable
|
||||
return sprintf('<a href="/u/account/view/%s">%s</a>',$this->id,$this->user_id);
|
||||
}
|
||||
|
||||
public function scopeActive()
|
||||
{
|
||||
return $this->where('active',TRUE);
|
||||
}
|
||||
|
||||
public function isAdmin($id)
|
||||
{
|
||||
return $id AND in_array($this->role(),['wholesaler','reseller']) AND in_array($id,$this->all_accounts()->pluck('id')->toArray());
|
||||
}
|
||||
|
||||
public function scopeActive()
|
||||
public function sendPasswordResetNotification($token)
|
||||
{
|
||||
return $this->where('active',TRUE);
|
||||
$this->notify(new ResetPasswordNotification($token));
|
||||
}
|
||||
|
||||
// List all the agents, including agents of agents
|
||||
|
Reference in New Issue
Block a user