Пример #1
0
 public static function generateId($length)
 {
     $idExists = true;
     while ($idExists) {
         $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
         $id = '';
         for ($i = 0; $i < $length; $i++) {
             $id .= $chars[rand(0, strlen($chars) - 1)];
         }
         $idExists = ChannelPost::exists(array('id' => $id));
     }
     return $id;
 }
Пример #2
0
 public function destroy($id, $request)
 {
     if (Session::isActive()) {
         $user = Session::get();
         if (ChannelPost::exists($id)) {
             $post = ChannelPost::find($id);
             if (UserChannel::find($post->channel_id) && UserChannel::find($post->channel_id)->belongToUser($user->id)) {
                 $post->erase();
             }
         }
     }
     return new Response(200);
 }