Esempio n. 1
0
 public function storeMessage($message, $event)
 {
     if ($event->room()->first() == null) {
         Chatroom::create(['name' => $event->title, 'event_id' => $event->id]);
     }
     return $event->room()->first()->messages()->create(['message' => $message, 'user_id' => \Auth::user()->id]);
 }
 public function createChatRoom()
 {
     $input = Request::all();
     $data['uid'] = $input[0];
     $data['title'] = $input[1];
     if (Chatroom::create($data)) {
         return 1;
     } else {
         return 0;
     }
 }
Esempio n. 3
0
use Illuminate\Http\Request;
$app->get('/', function () use($app) {
    return $app->welcome();
});
/**
 * Games
 * Sport
 * Finance
 * Animals
 */
$app->get('chatrooms/{category}', function ($category) {
    $chatrooms = Chatroom::where('category', $category)->get();
    return $chatrooms;
});
$app->post('chatrooms', function (Request $request) {
    $chatroom = Chatroom::create($request->all());
    return $chatroom;
});
$app->post('chatrooms/{id}/chat', function (Request $request, $chatroomId) {
    $chatroom = Chatroom::find($chatroomId);
    $chat = new Chat($request->all());
    $chatroom->chats()->save($chat);
    return $chat;
});
$app->get('chatrooms/{id}/chat', function ($chatroomId) {
    return Chat::where('chatroom_id', $chatroomId)->get();
});
$app->post('login', function (Request $request) {
    $username = $request->input('username');
    $password = $request->input('password');
    if (areCredentialsCorrect($username, $password)) {
Esempio n. 4
0
 /**
  *
  */
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 200) as $index) {
         Chatroom::create(['name' => $faker->word, 'event_id' => $index]);
     }
 }