Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected function addBooking(Request $request)
- {
- $data = $request->all();
- if ($this->validator($data)->fails()) {
- return $this->sendError('Validation Error.', $this->validator($data)->errors());
- }
- Booking::create($data);
- return $data;
- }
- public function up()
- {
- Schema::create('bookings', function (Blueprint $table) {
- $table->bigIncrements('id');
- $table->bigInteger('booker_id')->nullable(false)->unsigned();
- $table->bigInteger('classroom_id')->nullable(false)->unsigned();
- $table->string('name');
- $table->string('color')->default("#ff0000");
- $table->string('file')->default(NULL);
- $table->string('start')->nullable(false);
- $table->string('end')->nullable(false);
- $table->timestamps();
- $table->foreign('booker_id')->references('id')->on('users');
- $table->foreign('classroom_id')->references('id')->on('classrooms');
- });
- }
- class Booking extends Model
- {
- protected $fillable = [
- 'booker_id', 'classroom_id', 'name', 'color', 'file', 'start', 'end'
- ];
- protected $hidden = [
- ];
- protected $casts = [
- ];
- }
- {
- "booker_id": 10,
- "classroom_id": 4,
- "name": "Microsoft",
- "start": "2019-04-25 14:45",
- "end": "2019-04-25 16:45",
- "color": "#ff0000",
- "file": "test"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement