DEV Community

Anonymus
Anonymus

Posted on

Laravel helper for you

laravel new "név"
cd "név"
php artisan make:model "név" --all
DATABASE->MIGRATION
L>$table->string("type") + softDeletes;
APP->MODELS->"név" ->
use softDeletes;

L> protected $fillable =
[
"felsorolás",
];

DATABASE->SEEDER->névseeder:

RUN FUNCTION
1.DB Hat::create(["brand" => "Stetson",
"type" => "Cowboy Kalap",
"Size" => 59,
"Color" => "Barna"]);

2.DB Hat::create(["brand" => "Stetson",
"type" => "Cowboy Kalap",
"Size" => 59,
"Color" => "Barna"]);

terminal:
php artisan install:api

ROUTE:
Api->route:
Route::resource('/hats', HatController::class);

NévController:

INDEX FUNCTION->

$keres=Hat::all();
return response()->json([$keres, "msg"=> "Lekérés Sikeres"]);

STORE FUNCTION ->

$hat=Hat::create($request->all());
return response()->json([$hat, "msg" => "Hat create was successfully"]);

UPDATE FUNCTION ->
$hat->update($request->all());
return response()->json([$hat, "msg" => "Hat update was successfully"]);

DESTROY FUNCTION ->
$hat->delete();
return response()->json(["msg"=> "Törlés Sikeres"]);

REQUEST - írd át true-ra

Top comments (0)