restore composer.json, add mysqli extension
This commit is contained in:
32
app/Jobs/Dashboard/User/Create.php
Executable file
32
app/Jobs/Dashboard/User/Create.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\User;
|
||||
|
||||
use App\Models\Staff;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Arr;
|
||||
use \App\Http\Requests\Dashboard\User\Create as Request;
|
||||
|
||||
class Create
|
||||
{
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$user = Staff::create($this->request->validated());
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
50
app/Jobs/Dashboard/User/Edit.php
Executable file
50
app/Jobs/Dashboard/User/Edit.php
Executable file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\User;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
use App\Http\Requests\Dashboard\User\Edit as EditRequest;
|
||||
|
||||
|
||||
|
||||
class Edit
|
||||
{
|
||||
|
||||
protected $user;
|
||||
protected $attr;
|
||||
|
||||
public function __construct(User $user, array $attr = [])
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->attr = Arr::only($attr, ['first_name', 'last_name', 'gender', 'birth_day', 'category_id', 'role_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param EditRequest $request
|
||||
* @return static
|
||||
*/
|
||||
public static function fromRequest(User $user, EditRequest $request)
|
||||
{
|
||||
return new static($user, [
|
||||
'first_name' => $request->first_name,
|
||||
'last_name' => $request->last_name,
|
||||
'gender' => $request->gender,
|
||||
'birth_day' => $request->birth_day,
|
||||
'category_id' => $request->category_id,
|
||||
'role_id' => $request->role_id
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->user->update($this->attr);
|
||||
}
|
||||
}
|
||||
34
app/Jobs/Dashboard/User/Update.php
Executable file
34
app/Jobs/Dashboard/User/Update.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\User;
|
||||
|
||||
use App\Models\Staff;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\User\Update as Request;
|
||||
|
||||
class Update
|
||||
{
|
||||
// protected $attr;
|
||||
protected $staff;
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param User $staff
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(Staff $staff, Request $request)
|
||||
{
|
||||
$this->staff = $staff;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return $this->staff->update($this->request->validated());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user