SHARE
TWEET

Untitled

a guest Jun 25th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. protected function addBooking(Request $request)
  2. {
  3.  
  4.     $data = $request->all();
  5.  
  6.  
  7.     if ($this->validator($data)->fails()) {
  8.         return $this->sendError('Validation Error.', $this->validator($data)->errors());
  9.     }
  10.  
  11.     Booking::create($data);
  12.  
  13.     return $data;
  14.  
  15. }
  16.      
  17. public function up()
  18. {
  19.     Schema::create('bookings', function (Blueprint $table) {
  20.         $table->bigIncrements('id');
  21.         $table->bigInteger('booker_id')->nullable(false)->unsigned();
  22.         $table->bigInteger('classroom_id')->nullable(false)->unsigned();
  23.         $table->string('name');
  24.         $table->string('color')->default("#ff0000");
  25.         $table->string('file')->default(NULL);
  26.         $table->string('start')->nullable(false);
  27.         $table->string('end')->nullable(false);
  28.         $table->timestamps();
  29.         $table->foreign('booker_id')->references('id')->on('users');
  30.         $table->foreign('classroom_id')->references('id')->on('classrooms');
  31.     });
  32. }
  33.      
  34. class Booking extends Model
  35.     {
  36.     protected $fillable = [
  37.         'booker_id', 'classroom_id', 'name', 'color', 'file', 'start', 'end'
  38.     ];
  39.  
  40.     protected $hidden = [
  41.     ];
  42.  
  43.     protected $casts = [
  44.     ];
  45. }
  46.      
  47. {
  48.   "booker_id": 10,
  49.   "classroom_id": 4,
  50.   "name": "Microsoft",
  51.   "start": "2019-04-25 14:45",
  52.   "end": "2019-04-25 16:45",
  53.   "color": "#ff0000",
  54.   "file": "test"
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top