wahyun
11 months ago
7 changed files with 263 additions and 104 deletions
@ -0,0 +1,32 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use App\Models\Demo; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class ScheduleDemoController extends Controller |
||||
{ |
||||
public function add(Request $request) |
||||
{ |
||||
$this->validate($request, [ |
||||
'name' => 'required', |
||||
'role' => 'required', |
||||
'email' => 'required', |
||||
'number_phone' => 'required', |
||||
'status' => 'required', |
||||
'message' => 'required' |
||||
]); |
||||
|
||||
$data = $request->all(); |
||||
|
||||
$data['created_by'] = $this->currentName; |
||||
$result = Demo::create($data); |
||||
|
||||
if ($result) { |
||||
return response()->json(['status' => 'success','data' => $result, 'message' => 'add schedule successfully!', 'code' => 200], 200); |
||||
} else { |
||||
return response()->json(['status' => 'failed', 'message' => 'add data schedule failed!', 'code' => 400], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,26 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Demo extends Model |
||||
{ |
||||
protected $table = 'm_demo'; |
||||
|
||||
const CREATED_AT = 'created_at'; |
||||
const UPDATED_AT = 'updated_at'; |
||||
|
||||
protected $fillable = [ |
||||
'name', |
||||
'email', |
||||
'role', |
||||
'number_phone', |
||||
'status', |
||||
'message', |
||||
'created_at', |
||||
'created_by', |
||||
'updated_at', |
||||
'updated_by', |
||||
]; |
||||
} |
Loading…
Reference in new issue