/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // Role::find($id)->delete(); $ret['meta']['code'] = 1; echo json_encode($ret); }
protected function users() { if (!Schema::hasTable('users')) { $this->info("Creating 'users' table."); Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name')->nullable(); $table->string('username')->unique(); $table->string('email')->nullable(); $table->string('password', 60); $table->string('password_reminder', 100)->nullable(); $table->rememberToken(); $table->timestamps(); }); } if (User::count() == 0) { $this->info("No users found; creating 'admin'."); $adminUser = new User(); $adminUser->username = '******'; $adminUser->name = 'Administrator'; $adminUser->password = bcrypt('admin'); $adminUser->email = config('app.site_email'); $adminUser->save(); } if (!Schema::hasTable('roles')) { $this->info("Creating 'roles' table."); Schema::create('roles', function (Blueprint $table) { $table->increments('id'); $table->string('name')->unique(); $table->timestamps(); }); } if (!Role::find(Role::ADMIN)) { $this->info("Creating admin role."); Role::firstOrCreate(['id' => Role::ADMIN, 'name' => trans_choice('roles.admin', 1)]); } $managerRole = Role::find(Role::MANAGER); if (!$managerRole) { $this->info("Creating manager role."); Role::firstOrCreate(['id' => Role::MANAGER, 'name' => trans_choice('roles.manager', 1)]); } $clerkRole = Role::find(Role::CLERK); if (!$clerkRole) { $this->info("Creating clerk role."); Role::firstOrCreate(['id' => Role::CLERK, 'name' => trans_choice('roles.clerk', 1)]); } if (!Schema::hasTable('role_user')) { $this->info("Creating 'role_user' table."); Schema::create('role_user', function (Blueprint $table) { $table->integer('user_id')->unsigned(); $table->foreign('user_id')->references('id')->on('users'); $table->integer('role_id')->unsigned(); $table->foreign('role_id')->references('id')->on('roles'); $table->primary(['user_id', 'role_id']); }); } // If there are no administrators, make the first user an admin. $adminRole = Role::find(Role::ADMIN); if (count(User::administrators()) === 0) { $adminUser = User::first(); $this->info("Making " . $adminUser->name . " an Administrator."); $adminUser->roles()->save($adminRole); } if (!Schema::hasTable('unavailability_types')) { $this->info("Creating 'unavailability_types' table."); Schema::create('unavailability_types', function (Blueprint $table) { $table->increments('id'); $table->string('name')->unique(); $table->string('background_colour'); $table->string('colour'); }); } if (!Schema::hasTable('user_unavailabilities')) { $this->info("Creating 'user_unavailabilities' table."); Schema::create('user_unavailabilities', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id')->unsigned()->nullable(); $table->foreign('user_id')->references('id')->on('users'); $table->date('start_date')->nullable(); $table->date('end_date')->nullable(); $table->integer('type_id')->unsigned()->nullable(); $table->foreign('type_id')->references('id')->on('unavailability_types'); $table->timestamps(); }); } if (!Schema::hasTable('queued_emails')) { $this->info("Creating 'queued_emails' table."); Schema::create('queued_emails', function (Blueprint $table) { $table->increments('id'); $table->integer('recipient_id')->unsigned()->nullable(); $table->foreign('recipient_id')->references('id')->on('users'); $table->string('subject'); $table->string('template'); $table->text('data'); $table->timestamps(); }); } }