Запилил отзывы
This commit is contained in:
		
							parent
							
								
									6fe9a30d75
								
							
						
					
					
						commit
						6616bfff8d
					
				|  | @ -0,0 +1,20 @@ | |||
| <?php | ||||
| 
 | ||||
| namespace App\Http\Controllers; | ||||
| 
 | ||||
| use App\Models\Feedback; | ||||
| use Illuminate\Http\Request; | ||||
| 
 | ||||
| class FeedbackController extends Controller | ||||
| { | ||||
|     public function create(Request $request) | ||||
|     { | ||||
|         $request->validate([ | ||||
|             'user_id' => 'nullable|exists:users,id', | ||||
|             'text' => 'required|string|max:256' | ||||
|         ]); | ||||
| 
 | ||||
|         $wish = Feedback::create($request->all()); | ||||
|         return response()->json($wish, 201); | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,13 @@ | |||
| <?php | ||||
| 
 | ||||
| namespace App\Models; | ||||
| 
 | ||||
| use Illuminate\Database\Eloquent\Factories\HasFactory; | ||||
| use Illuminate\Database\Eloquent\Model; | ||||
| 
 | ||||
| class Feedback extends Model | ||||
| { | ||||
|     use HasFactory; | ||||
| 
 | ||||
|     protected $fillable = ['user_id', 'text']; | ||||
| } | ||||
|  | @ -0,0 +1,30 @@ | |||
| <?php | ||||
| 
 | ||||
| use Illuminate\Database\Migrations\Migration; | ||||
| use Illuminate\Database\Schema\Blueprint; | ||||
| use Illuminate\Support\Facades\Schema; | ||||
| 
 | ||||
| return new class extends Migration | ||||
| { | ||||
|     /** | ||||
|      * Run the migrations. | ||||
|      */ | ||||
|     public function up(): void | ||||
|     { | ||||
|         Schema::create('feedback', function (Blueprint $table) { | ||||
|             $table->id(); | ||||
|             $table->text('text'); | ||||
|             $table->unsignedBigInteger('user_id')->nullable(); | ||||
|             $table->foreign('user_id')->references('id')->on('users'); | ||||
|             $table->timestamps(); | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Reverse the migrations. | ||||
|      */ | ||||
|     public function down(): void | ||||
|     { | ||||
|         Schema::dropIfExists('feedback'); | ||||
|     } | ||||
| }; | ||||
		Loading…
	
		Reference in New Issue