Customers Add+Edit, API WP

This commit is contained in:
Kevin Adametz 2020-06-12 14:46:51 +02:00
parent dc63fa9fb2
commit 75a0f9a38a
120 changed files with 11894 additions and 6134 deletions

View file

@ -3,6 +3,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* App\Models\ShoppingUser
@ -75,11 +76,39 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereOrders($value)
* @property int|null $abo_options
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereAboOptions($value)
* @property int|null $member_id
* @property int|null $number
* @property bool $is_like
* @property array|null $notice
* @property-read \App\User|null $auth_user
* @property-read \App\User|null $member
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereIsLike($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereMemberId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereNotice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereNumber($value)
* @property bool|null $has_buyed
* @property bool|null $subscribed
* @property int|null $wp_order_number
* @property string|null $wp_order_date
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereHasBuyed($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereSubscribed($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereWpOrderDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereWpOrderNumber($value)
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property string|null $user_deleted_at
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingUser onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereUserDeletedAt($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingUser withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingUser withoutTrashed()
*/
class ShoppingUser extends Model
{
protected $table = 'shopping_users';
use SoftDeletes;
protected $dates = ['deleted_at'];
protected $fillable = [
@ -110,7 +139,12 @@ class ShoppingUser extends Model
'shipping_city',
'shipping_country_id',
'shipping_phone',
'has_buyed',
'subscribed',
'notice',
'mode',
'wp_order_number',
'wp_order_date',
];
protected $casts = [
@ -118,6 +152,9 @@ class ShoppingUser extends Model
'is_like' => 'bool',
'accepted_data_checkbox' => 'bool',
'same_as_billing' => 'bool',
'has_buyed' => 'bool',
'subscribed' => 'bool',
'wp_order_number' => 'int',
];
//can null
@ -168,4 +205,23 @@ class ShoppingUser extends Model
$this->notice = $notice;
$this->save();
}
public function firstEntryByNumber(){
if($this->number>0){
if($shopping_user = ShoppingUser::where('number', $this->number)->orderBy('created_at', 'ASC')->first()){
return $shopping_user;
}
}
return $this;
}
public function lastEntryByNumber(){
if($this->number>0){
if($shopping_user = ShoppingUser::where('number', $this->number)->orderBy('created_at', 'DESC')->first()){
return $shopping_user;
}
}
return $this;
}
}